Keras-retinanet: Image file is truncated - TypeError: 'NoneType' object is not callable

Created on 29 Nov 2018  路  4Comments  路  Source: fizyr/keras-retinanet

After training the network for a while it crashes with this error but I have no idea how to solve this.
What does this exactly mean?

Epoch 12/100 56/100 [===============>..............] - ETA: 23s - loss: 0.9776 - regression_loss: 0.8144 - classification_loss: 0.1633Traceback (most recent call last): File "/home/username/.local/bin/retinanet-train", line 11, in <module> sys.exit(main()) File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/bin/train.py", line 488, in main callbacks=callbacks, File "/home/username/anaconda3/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/username/anaconda3/lib/python3.5/site-packages/keras/engine/training.py", line 1418, in fit_generator initial_epoch=initial_epoch) File "/home/username/anaconda3/lib/python3.5/site-packages/keras/engine/training_generator.py", line 181, in fit_generator generator_output = next(output_generator) File "/home/username/anaconda3/lib/python3.5/site-packages/keras/utils/data_utils.py", line 709, in get six.reraise(*sys.exc_info()) File "/home/username/anaconda3/lib/python3.5/site-packages/six.py", line 693, in reraise raise value File "/home/username/anaconda3/lib/python3.5/site-packages/keras/utils/data_utils.py", line 685, in get inputs = self.queue.get(block=True).get() File "/home/username/anaconda3/lib/python3.5/multiprocessing/pool.py", line 644, in get raise self._value File "/home/username/anaconda3/lib/python3.5/multiprocessing/pool.py", line 119, in worker result = (True, func(*args, **kwds)) File "/home/username/anaconda3/lib/python3.5/site-packages/keras/utils/data_utils.py", line 626, in next_sample return six.next(_SHARED_SEQUENCES[uid]) File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/generator.py", line 287, in __next__ return self.next() File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/generator.py", line 298, in next return self.compute_input_output(group) File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/generator.py", line 269, in compute_input_output image_group = self.load_image_group(group) File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/generator.py", line 160, in load_image_group return [self.load_image(image_index) for image_index in group] File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/generator.py", line 160, in <listcomp> return [self.load_image(image_index) for image_index in group] File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/preprocessing/csv_generator.py", line 197, in load_image return read_image_bgr(self.image_path(image_index)) File "/home/username/.local/lib/python3.5/site-packages/keras_retinanet/utils/image.py", line 32, in read_image_bgr image = np.asarray(Image.open(path).convert('RGB')) File "/home/username/anaconda3/lib/python3.5/site-packages/PIL/Image.py", line 892, in convert self.load() File "/home/username/anaconda3/lib/python3.5/site-packages/PIL/ImageFile.py", line 232, in load "(%d bytes not processed)" % len(b)) OSError: image file is truncated (32 bytes not processed) Exception ignored in: <bound method BaseSession.__del__ of <tensorflow.python.client.session.Session object at 0x7feabace1048>> Traceback (most recent call last): File "/home/username/anaconda3/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 696, in __del__ TypeError: 'NoneType' object is not callable

Most helpful comment

It was indeed caused by corrupted images.
For the people who are facing this problem I recommend to install the package "jpeginfo"
and run this command: find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"

It will look for corrupted images and warns you given with the image name when it founds one.

All 4 comments

I've never seen this error before, but I read on the slack channel that this can happen if your image is corrupted. I'm guessing if you would debug to find out which image it is loading and try to open that image, it would fail.

Alright, then I will debug it to see if one of the images is indeed corrupted. Thank you for your fast response.

It was indeed caused by corrupted images.
For the people who are facing this problem I recommend to install the package "jpeginfo"
and run this command: find . -name "*jpg" -exec jpeginfo -c {} \; | grep -E "WARNING|ERROR"

It will look for corrupted images and warns you given with the image name when it founds one.

Glad to see it's resolved and thanks for getting back to let us know.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sumeetssaurav picture sumeetssaurav  路  4Comments

mayur-who picture mayur-who  路  5Comments

ChienLiu picture ChienLiu  路  6Comments

xyiaaoo picture xyiaaoo  路  5Comments

fernandocamargoti picture fernandocamargoti  路  4Comments