Skip to content
Advertisement

Tensorflow: Error when trying transfer learning: Invalid JPEG data or crop window

I am trying to shape my own custom image dataset into the correct input shape for the pretrained MobileNet model on Tensorflow using their tutorial here. My code:

JavaScript

After which I continue with the TF tutorial on transfer learning here. However, I ran into this problem where I suspect the JPEG image is corrupted or there is a lack of/problem with the iterator?:

JavaScript

Thank you for your time! Edit: After re-running the code a few times, it seems it will produce the same errors with different data sizes like 16384….

Edit: Yes, the problem lies with the fact that some .jpeg are actually .png in disguise, or they are just plain corrupted. I highly recommend checking data integrity before training any model with the data.

Advertisement

Answer

I faced similar problem. there is a problem in some of your training data. you can use code below to check which jpeg image is corrupted and delete it.

JavaScript

I used yasoob script to decode jpeg image.

Advertisement