From fe8dac6cfc8734c7d754e7418463aeaac289eb04 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 25 Jan 2021 20:42:12 -0800 Subject: [PATCH 1/2] Check im.format during dataset caching --- utils/datasets.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/datasets.py b/utils/datasets.py index a6e3d3f56b9f..124d123f48e8 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 format {im.format}' # verify labels if os.path.isfile(lb_file): From b7d7a595070207e6a26806a0a08e765b62b6cb33 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Mon, 25 Jan 2021 20:48:33 -0800 Subject: [PATCH 2/2] Update datasets.py --- utils/datasets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/datasets.py b/utils/datasets.py index 124d123f48e8..d87952c9b61d 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -446,7 +446,7 @@ def cache_labels(self, path=Path('./labels.cache'), prefix=''): im.verify() # PIL verify shape = exif_size(im) # image size assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels' - assert im.format.lower() in img_formats, f'invalid format {im.format}' + assert im.format.lower() in img_formats, f'invalid image format {im.format}' # verify labels if os.path.isfile(lb_file):