glenn-jocher commited on
Commit
8fcbe43
1 Parent(s): a41d910

Check im.format during dataset caching (#2042)

Browse files

* Check im.format during dataset caching

* Update datasets.py

Files changed (1) hide show
  1. utils/datasets.py +2 -1
utils/datasets.py CHANGED
@@ -445,7 +445,8 @@ class LoadImagesAndLabels(Dataset): # for training/testing
445
  im = Image.open(im_file)
446
  im.verify() # PIL verify
447
  shape = exif_size(im) # image size
448
- assert (shape[0] > 9) & (shape[1] > 9), 'image size <10 pixels'
 
449
 
450
  # verify labels
451
  if os.path.isfile(lb_file):
 
445
  im = Image.open(im_file)
446
  im.verify() # PIL verify
447
  shape = exif_size(im) # image size
448
+ assert (shape[0] > 9) & (shape[1] > 9), f'image size {shape} <10 pixels'
449
+ assert im.format.lower() in img_formats, f'invalid image format {im.format}'
450
 
451
  # verify labels
452
  if os.path.isfile(lb_file):