OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.5k stars 2.19k forks source link

OSError: image file is truncated (custom object training issue) #200

Closed deepakmallya closed 5 years ago

deepakmallya commented 5 years ago

Hello!

I am trying to train the model to detect images of tigers and I am running into the following error:

Using Enhanced Data Generation Found 2635 images belonging to 2 classes. Found 950 images belonging to 2 classes. JSON Mapping for the model classes saved to tigdetect/json/model_class.json Number of experiments (Epochs) : 200 2019-05-07 11:51:13.608070: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA Epoch 1/200 60/83 [====================>.........] - ETA: 6:03 - loss: 0.7342 - acc: 0.7746/Users/deepak/anaconda3/lib/python3.6/site-packages/PIL/Image.py:969: UserWarning: Palette images with Transparency expressed in bytes should be converted to RGBA images 'to RGBA images') 72/83 [=========================>....] - ETA: 2:53 - loss: 0.6744 - acc: 0.7841Traceback (most recent call last): File "/Users/deepak/Documents/RCA IDE1/Solo Major/Code/Pangolinyolo/tigertrain.py", line 6, in model_trainer.trainModel(num_objects=2, num_experiments=200, enhance_data=True, batch_size=32, show_network_summary=True) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/imageai/Prediction/Custom/init.py", line 249, in trainModel validation_steps=int(num_test / batch_size), callbacks=[checkpoint, lr_scheduler]) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1426, in fit_generator initial_epoch=initial_epoch) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 177, in model_iteration batch_data = _get_next_batch(output_generator, mode) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/engine/training_generator.py", line 258, in _get_next_batch generator_output = next(output_generator) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/utils/data_utils.py", line 655, in get six.reraise(sys.exc_info()) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise raise value File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/utils/data_utils.py", line 649, in get inputs = self.queue.get(block=True).get() File "/Users/deepak/anaconda3/lib/python3.6/multiprocessing/pool.py", line 644, in get raise self._value File "/Users/deepak/anaconda3/lib/python3.6/multiprocessing/pool.py", line 119, in worker result = (True, func(args, kwds)) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/tensorflow/python/keras/utils/data_utils.py", line 445, in get_index return _SHARED_SEQUENCES[uid][i] File "/Users/deepak/anaconda3/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py", line 65, in getitem return self._get_batches_of_transformed_samples(index_array) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/keras_preprocessing/image/iterator.py", line 226, in _get_batches_of_transformed_samples interpolation=self.interpolation) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/keras_preprocessing/image/utils.py", line 126, in load_img img = img.resize(width_height_tuple, resample) File "/Users/deepak/anaconda3/lib/python3.6/site-packages/PIL/Image.py", line 1804, in resize self.load() File "/Users/deepak/anaconda3/lib/python3.6/site-packages/PIL/ImageFile.py", line 238, in load len(b)) OSError: image file is truncated (77 bytes not processed)**

Process finished with exit code 1

could you please let me know what i'm doing wrong here? thank you so much!

OlafenwaMoses commented 5 years ago

Kindly follow the link below on this issue. The issue arose due a an affected image in your dataset.

https://stackoverflow.com/questions/12984426/python-pil-ioerror-image-file-truncated-with-big-images