Search code examples
tensorflowkerastf.kerastensorflow-litegoogle-mlkit

ValueError: Expect x to be a non-empty array or dataset (Tensor Flow lite model maker on Collab)


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.

enter image description here

Am I doing something wrong? The data set provided in the example works fine though. Why?


Solution

  • I just did some manual tests. Don't exactly know why, but for this binary classifier, when I increase the amount of data to make sure at least 16 image per label are used for training, it starts working.

    For your case, because you split the train/test by a factor of 0.5, you need 32 images per label. Could you try if that solve your issue?