diff --git a/data/get_coco_dataset.sh b/data/get_coco_dataset.sh index 625ed414..b6b4fc9a 100755 --- a/data/get_coco_dataset.sh +++ b/data/get_coco_dataset.sh @@ -36,4 +36,4 @@ paste <(awk "{print \"$PWD\"}" = 1.1.0 diff --git a/utils/datasets.py b/utils/datasets.py index 5b9a9860..e8db5531 100755 --- a/utils/datasets.py +++ b/utils/datasets.py @@ -223,6 +223,16 @@ class LoadImagesAndLabels(Dataset): # for training/testing pass # print('Warning: missing labels for %s' % self.img_files[i]) # missing label file assert len(np.concatenate(self.labels, 0)) > 0, 'No labels found. Incorrect label paths provided.' + # Detect corrupted images https://medium.com/joelthchao/programmatically-detect-corrupted-image-8c1b2006c3d3 + detect_corrupted_images = False + if detect_corrupted_images: + from skimage import io # conda install -c conda-forge scikit-image + for file in tqdm(self.img_files, desc='Detecting corrupted images'): + try: + _ = io.imread(file) + except: + print('Corrupted image detected: %s' % file) + def __len__(self): return len(self.img_files)