TannerGilbert / TFLite-Object-Detection-with-TFLite-Model-Maker

Custom object detection with the TFLite Model Maker
https://gilberttanner.com/blog/tflite-model-maker-object-detection
30 stars 14 forks source link

from_pascal_voc train_data size is 0 error #1

Open SimrnGupta opened 3 years ago

SimrnGupta commented 3 years ago

Hello, I am trying to train a custom dataset of tennis balls using TF model maker on Google Colab. I have annotated the images using labelImg and I am trying to load the images using the from_pascal_voc format. However, when I pass train_data to the create method, it gives an error saying train_data size is 0. It would be great if I could get help on this.

Code:

train_data = object_detector.DataLoader.from_pascal_voc('./train/', './train/', label_map={1: "tennis ball", 2: "no ball"}) validation_data = object_detector.DataLoader.from_pascal_voc('./valid/', './valid/', label_map={1: "tennis ball", 2: "no ball"})

model = object_detector.create(train_data, model_spec=spec, epochs=80, batch_size=8, train_whole_model=True, validation_data=validation_data)

Screenshot 2021-06-21 at 2 43 12 PM

train and valid contains the images and annotations in jpg and xml formats respectively, and are placed in the content directory of Colab.

NSTiwari commented 3 years ago

@SimrnGupta, when I try to load the PascalVOC dataset, it gives an error that says, "Image format not JPEG", although all the images are of the said format. May be you could help me with this and I can help you with the error you're facing.

TannerGilbert commented 3 years ago

These kind of errors are hard for me to solve. Maybe open a thread on the Tensorflow forum.

VIS-WA commented 1 year ago

This worked for me. I have removed the trailing '/' from the images and annotations folder. The new command would look like:

train_data = object_detector.DataLoader.from_pascal_voc('./train', './train', label_map={1: "tennis ball", 2: "no ball"})
validation_data = object_detector.DataLoader.from_pascal_voc('./valid', './valid', label_map={1: "tennis ball", 2: "no ball"})