How To Use TensorFlow lite in Flutter?

Assuming that we have the tflite model, then:

1.Adding this package in pubspec file:

tflite: ^1.0.5

2.add model in the assets folder and update pubspec file:

- assets/model_unquant.tflite
- assets/labels.txt

3.Load the model:

static Future<String> loadModel() async{  return Tflite.loadModel(
model: "assets/model_unquant.tflite",
labels: "assets/labels.txt",
void initState() {
//Load TFLite Model
TFLiteHelper.loadModel().then((value) {
setState(() {
modelLoaded = true;

4.use the output from Camera Controller to feed to provide frames to TensorFlow lite.

await Tflite.runModelOnFrame(
bytesList: {
return plane.bytes;
numResults: 5)
.then((value) {
if (value.isNotEmpty) {
//Do something with the results

Written by

Machine Learning / Deep Learning / Python / Flutter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store