From fd6a2a69e1d779d030f942e5933f932588916681 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 25 Jan 2021 20:55:35 -0800 Subject: [PATCH] Check im.format during dataset caching (#2042) * Check im.format during dataset caching * Update datasets.py --- utils/datasets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/datasets.py b/utils/datasets.py index a6e3d3f56b9f..d87952c9b61d 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -445,7 +445,8 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''): im = Image.open(im_file) im.verify() # PIL verify shape = exif_size(im) # image size - assert (shape[0] > 9) & (shape[1] > 9), 'image size <10 pixels' + assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels' + assert im.format.lower() in img_formats, f'invalid image format {im.format}' # verify labels if os.path.isfile(lb_file):