flutter tensorflow lite
a flutter project for demonstrating usage of tensorflow lite model created with teachablemachine.
the “tensorflow” model is trained using teachable machines. the model is trained with different texture colors of walls. app will recognize the color and classify the color according to best match. this app will load a pre-trained model and start classification on frames received from camera controller. app will show results in real-time along with confidence percentages.
model can be downloaded from this download link and re-loaded on “teachable machines” website.
labels
class id | label name |
---|---|
0 | black texture |
1 | blue texture |
2 | green texture |
3 | orange texture |
4 | pink texture |
5 | purple texture |
6 | red texture |
7 | white texture |
8 | yellow texture |
tflite helper class
// load model
static future<string> loadmodel() async{
apphelper.log("loadmodel", "loading model..");
return tflite.loadmodel(
model: "assets/model_unquant.tflite",
labels: "assets/labels.txt",
);
}
//start classification on cameraimage frames
static classifyimage(cameraimage image) async {
await tflite.runmodelonframe(
byteslist: image.planes.map((plane) {
return plane.bytes;
}).tolist(),
numresults: 5)
.then((value) {
//send results
tfliteresultscontroller.add(_outputs);
});
}
Comments are closed.