1

I was traying to integrate my custom YOLO models (I try with YOLOv3 and YOLOv4) to flutter like was show in https://stackoverflow.com/a/62990869/9420938. However when I call Tflite.detectObjectOnFrame() the model is always returning an empty array. If I call Tflite.runModelOnFrame() it return the labels of objects, but not the bounding box. Does anyone know what maight be happening?

    Tflite.loadModel(
          model: "assets/yolov3-tiny-416.tflite",
          labels: "assets/labels.txt",
          numThreads: 1, // defaults to 1
          isAsset: true, // defaults to true, set to false to load resources outside assets
          useGpuDelegate: false // defaults to false, set to true to use GPU delegate
        ).then((res){
          _initialized = res;
        });

var recognitions = await Tflite.detectObjectOnFrame(
          model: "YOLOv3",
          bytesList: image.planes.map((plane) {return plane.bytes;}).toList(),// required
          imageHeight: image.height,
          imageWidth: image.width,
          imageMean: 0,   
          imageStd: 255.0,     
          numResultsPerClass: 2,
          numBoxesPerBlock: 5, 
          threshold: 0.3,     
          blockSize: 32,       
          asynch: true        
        );

1 Answers1

0

Make sure you are using the tflite_flutter_plugin with tflite_flutter_helper: https://pub.dev/packages/tflite_flutter

and not tflite (which currently only supports yolov2): https://pub.dev/packages/tflite

Edit: In order to get Yolo above v2 working in the tflite_flutter_plugin you should follow these instructions: https://github.com/TexMexMax/object_detection_flutter

note: when editing the tflite_flutter_helper plugin, make sure to delete the example inside of it, because that will cause errors and crash your app (which is what happened to me).

greenzebra
  • 412
  • 1
  • 5
  • 18