Check im.format during dataset caching (#2042)

* Check im.format during dataset caching

* Update datasets.py
pull/2046/head
Glenn Jocher 2021-01-25 20:55:35 -08:00 committed by GitHub
parent a41d910c5d
commit 8fcbe43423
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -445,7 +445,8 @@ class LoadImagesAndLabels(Dataset): # for training/testing
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):