However, as I run the cell, I see an error that says, ValueError: Image format not JPEG despite the images being of the said format. Here’s a snapshot of the same.
From the image you have posted I see also .xml files inside the folder. Maybe the DataLoader tries to use .jpg images and finds .xml files. Check again the folder or the link you have downloaded the dataset.
Hi @George_Soloupis,
I even tried using separate folders for images and annotations but the error persists. So, the suspicion of the DataLoader finding the .xml files instead of .jpg is ruled out too. With respect to the dataset, I manually scraped images from online sources and annotated them using LabelImg in PascalVOC format. Still wondering what’s going wrong.
Your error is coming from the autoML PIL.Image.open function call so strictly speaking it’s autoML PIL issue, but I guess since you’re trying to run it based on a tensorflow sample I guess it is worth raising here as well perhaps.
Have you tried writing a simple piece of code to loop through the images individually using PIL library within a try except and see if any particular image itself is causing an issue?
@Keith_Hall, thanks for your response. I’d like to share that I have resolved the issue successfully. I explicitly and programmatically converted all the images in ‘RGB’ format using PIL library and it worked just fine afterwards. Thanks for the support.
If someone still has this problem, try to check the tag image_name.format the filename inside .xml file needs to match with the format, so convert the image only works if also your .xml has the filename tag with .jpg
Hi all. Sometimes images that have a .jpg extension are recognized by PIL as PNG format. To correct this, you need to isolate the images in your dataset that have this issue and convert them to RGB and then save them as JPEG. Here is the code for doing this:
import glob
from PIL import Image
files = glob.glob(“training_data_02/valid/*”)
len(files)
for file in files:
if “.jpg” in file:
image = PIL.Image.open(file)
if image.format not in [“JPG”, “JPEG”]:
print (file)
image.convert(‘RGB’).save(file, “JPEG”)