train_data = object_detector.DataLoader.from_pascal_voc( 'images_jpg_splitted/train/img', 'images_jpg_splitted/train/xml', ['bat'] )
val_data = object_detector.DataLoader.from_pascal_voc( 'images_jpg_splitted/test/img', 'images_jpg_splitted/test/xml', ['bat'] )
I am trying to detect bat from images. I have labeled the data using labelImg. While trying to load the data from tflite_model_maker, object_detector.DataLoader.from_pascal_voc returns empty data. I have tried not splitting the image and XML file and it still did not work.
The error was in the image file. The file supported was only jpeg but although the extension was a jpeg, it was not recognizing the images as jpeg maybe because it was a png file and the extension was renamed. So, I used PIL to convert them to jpeg.
import PIL.Image
import glob
import os
if not "converted" in os.listdir():
os.mkdir("converted")
lst_imgs = [i for i in glob.glob("*.jpeg")]
print(lst_imgs)
for i in lst_imgs:
img = PIL.Image.open(i)
img = img.convert("RGB")
img.save("converted\\"+i, "JPEG")
print("Done.")
os.startfile("converted")