Tflite Flutter Cat/Dog detection

print

libraries

tflite: ^1.1.2
image_picker: ^0.8.4+10

Download training datasets from kaggle

Train your model at Teachable Machine

https://teachablemachine.withgoogle.com/train/image

Import the exported tflite model and labels to your flutter project, load them and start using them.

https://github.com/shadowmanpat/artificial_flutter

loadModel() async {
    await Tflite.loadModel(model: 'assets/model_cat_dog.tflite', labels: "assets/model_cat_dog.txt");
  }

  detectImage(File image) async {
    _loading = true;
    var output = await Tflite.runModelOnImage(path: image.path,
      numResults: 2,
      threshold: 0.6,
      imageMean: 127.5,
      imageStd: 127.5
    );
    setState(() {
      _output = output!;
      _loading = false;
    });
  }

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.