Image corruption during model training

Hi Guys
I am getting this error while training my model:
File “/usr/local/lib/python3.9/site-packages/keras/src/preprocessing/”, line 156, in next
return*args, **kwargs)

File “/usr/local/lib/python3.9/site-packages/keras/src/preprocessing/”, line 168, in next
return self._get_batches_of_transformed_samples(index_array)

File “/usr/local/lib/python3.9/site-packages/keras/src/preprocessing/”, line 370, in _get_batches_of_transformed_samples
img = image_utils.load_img(

File “/usr/local/lib/python3.9/site-packages/keras/src/utils/”, line 479, in load_img
img = img.resize(width_height_tuple, resample)

File “/usr/local/lib/python3.9/site-packages/PIL/”, line 2163, in resize

File “/usr/local/lib/python3.9/site-packages/PIL/”, line 266, in load
raise OSError(msg)

OSError: image file is truncated (136 bytes not processed)

     [[{{node PyFunc}}]]
     [[IteratorGetNext]] [Op:__inference_train_function_20953]

Could you guys tell me the possible cause of this issue.

Hi @Soap, The error was thrown by PIL libray. could you please try by adding

from PIL import ImageFile

Thank You.

Ya it works, Thank you so much :slight_smile: