From 9c227dd2b434ea290a46322e5a33dc48c7500cb4 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Tue, 9 Jul 2019 14:18:19 +0200 Subject: [PATCH] updates --- data/get_coco_dataset.sh | 2 +- requirements.txt | 4 +++- utils/datasets.py | 10 ++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) 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)