'Is it possible to create labels.txt manually?
I recently convert my model to tensorflow lite but I only got the .tflite file and not a labels.txt for my Android project. So is it possible to create my own labels.txt using the classes that I used to classify? If not, then how to generate labels.txt?
Solution 1:[1]
You should be able to generate and use your own labels.txt. The file needs to include the label names in the order you provided them in training, with one name per line.
Solution 2:[2]
Run the following code after installing the TFLite Model Maker library and pass the dataset for classification:
data = ImageClassifierDataLoader.from_folder('folder/')
train_data, test_data = data.split(0.8)
model = image_classifier.create(train_data)
loss, accuracy = model.evaluate(test_data)
model.export('image_classifier.tflite', 'imageLabels.txt')
On running it in Colab or locally, the labels files would be auto-generated with the categories from each of the subfolders.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pete Warden |
Solution 2 | AnupamChugh |