I am following this tutorial on creating a custom Model using TensorFlow lite Model Maker on Collab.
import pathlib
path = pathlib.Path('/content/employee_pics')
count = len(list(path.glob('*/*.jpg')))
count
data = ImageClassifierDataLoader.from_folder(path)
train_data, test_data = data.split(0.5)
I have an issue with step 2:
model = image_classifier.create(train_data)
I get an error: ValueError: Expect x to be a non-empty array or dataset.
Am I doing something wrong? The data set provided in the example works fine though. Why?
This Error is caused by the size of training data is smaller than batch_size
which is not allowed.
The default batch_size is 32, which means the number of training images should be no less than 32. There's no need to count the number of images per label, just need to make sure that the total training images to be at least 32.
You need to choose one of the following solutions to solve it.
batch_size
smaller than training data size, e.g:image_classifier.create(train_data, batch_size=4)