Flutter Image Classification
This app classifies images based on any TFLite image classification model.
A sample model has been provided to classify cats vs. dogs.
Instructions to use on your tflite model
- Install flutter & clone repository.
- Modify the model in assets/tflite/[name].tflite.
- Modify the class names in assets/tflite/[name].txt represent your classes (see example below).
- Modify both [name].tflite and [name].txt in pubspec.yaml (see example below).
- Change the loadModel function in lib/main.dart to load your [name].tflite and [name].txt (see example below).
- Run Flutter app. The tflite package uses v1 embeddings so we need to pass in –ignore-deprecation.
flutter run --ignore-deprecation
cats_dogs.txt
Cat
Dog
pubspec.yaml
assets {
- assets/tflite/[name].tflite
- assets/tflite/[name].txt
}
lib/main.dart
String res = await Tflite.loadModel(
model: "assets/tflite/[name].tflite",
labels: "assets/tflite/[name].txt",
) ?? '';