Actually, my question is very simple. I would like to use my own data in tensorflow lite model. So, i wrote these line of codes:
JavaScript
x
5
1
root_path = r"C:Users90531Desktopdatasetb"
2
image_path = os.path.join(os.path.dirname(root_path), '1602854451425')
3
4
data = DataLoader.from_folder(image_path)
5
Also, this is the error that I encountered:
JavaScript
1
5
1
File "C:Users90531AppDataRoamingPythonPython39site-packagestensorflow_exampleslitemodel_makercoredata_utilimage_dataloader.py", line 73, in from_folder
2
raise ValueError('Image size is zero')
3
4
ValueError: Image size is zero
5
Advertisement
Answer
This happens when the Dataloader
cannot infer the labels of your images. The images should be divided into subfolders according to the class they belong to:
JavaScript
1
7
1
from tflite_model_maker.image_classifier import DataLoader
2
import seedir as sd
3
4
image_path = '/content/images'
5
sd.seedir(image_path, style='spaces', indent=4, anystart='- ')
6
data = DataLoader.from_folder(image_path)
7
JavaScript
1
8
1
- images/
2
- class1/
3
- result_image.png
4
- class2/
5
- result_image1.png
6
7
INFO:tensorflow:Load image with size: 2, num_label: 2, labels: class1, class2.
8