eg4000 / SKU110K_CVPR19

771 stars 182 forks source link

OSError: image file is truncated (corrupted images?) #23

Closed wiamadaya closed 5 years ago

wiamadaya commented 5 years ago

i received the following error when training using the SKU110K images, i assume there is/are corrupted images, but i couldn't identify which one.

Traceback (most recent call last): File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/bin/train.py", line 448, in <module> main() File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/bin/train.py", line 443, in main validation_steps=validation_generator.size() File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/engine/training.py", line 1418, in fit_generator initial_epoch=initial_epoch) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/engine/training_generator.py", line 181, in fit_generator generator_output = next(output_generator) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/utils/data_utils.py", line 709, in get six.reraise(*sys.exc_info()) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/six.py", line 693, in reraise raise value File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/utils/data_utils.py", line 685, in get inputs = self.queue.get(block=True).get() File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/multiprocessing/pool.py", line 657, in get raise self._value File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/multiprocessing/pool.py", line 121, in worker result = (True, func(*args, **kwds)) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/keras/utils/data_utils.py", line 626, in next_sample return six.next(_SHARED_SEQUENCES[uid]) File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/generator.py", line 287, in __next__ return self.next() File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/generator.py", line 298, in next return self.compute_input_output(group) File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/generator.py", line 269, in compute_input_output image_group = self.load_image_group(group) File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/generator.py", line 147, in load_image_group return [self.load_image(image_index) for image_index in group] File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/generator.py", line 147, in <listcomp> return [self.load_image(image_index) for image_index in group] File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/preprocessing/csv_generator.py", line 270, in load_image return read_image_bgr(self.image_path(image_index)) File "/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/utils/image.py", line 32, in read_image_bgr image = np.asarray(Image.open(path).convert('RGB')) File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/PIL/Image.py", line 912, in convert self.load() File "/home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.7/site-packages/PIL/ImageFile.py", line 239, in load len(b)) OSError: image file is truncated (23 bytes not processed)

yfe404 commented 5 years ago

I solved it by editing this file:

/home/ubuntu/SKU110K_CVPR19/object_detector_retinanet/keras_retinanet/utils/image.py,

Just append the following two lines in the imports at the beginning

from PIL import ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True

wiamadaya commented 5 years ago

@yafeunteun thanks again for your help

eg4000 commented 5 years ago

Hi, We apologize for that. the distributed dataset does contain a couple of corrupted or rotated images. You can either skip them or process them. Their number is negligible and it hardly effects the training and evaluation process.