Flutter reading tflite module from assets failes

23 Views Asked by At

I am trying to implement image recognition with Flutter libs

  tflite_flutter: ^0.9.0
  tflite_flutter_helper: ^0.3.1

and my pre-trained Yolov7 module converted to a .tflite file

I am getting this kind of log:

flutter: image processed

flutter: image buffered

Didn't find op for builtin opcode 'MUL' version '5' Registration failed.

The code looks like this:

void _analizeImage() async {
        try {
      // Ensure the camera is initialized
      await controller.initialize();

      // Attempt to take a picture and get the file `image`
      final image = await controller.takePicture();

      debugPrint("picture taken: ${image.path}");

      // Use mounted to check if the widget is still in the widget tree
      if (!mounted) return;

      ImageProcessor imageProcessor =
          ImageProcessorBuilder().add(ResizeOp(224, 224, ResizeMethod.NEAREST_NEIGHBOUR)).build();

      debugPrint("image processed");

      TensorImage tensorImage = TensorImage.fromFile(File(image.path));
      tensorImage = imageProcessor.process(tensorImage);

      TensorBuffer probabilityBuffer = TensorBuffer.createFixedSize(<int>[1, 1001], TfLiteType.uint8);

      debugPrint("image buffered");

      Interpreter interpreter = await Interpreter.fromAsset('/model/yolov7.tflite');
      interpreter.run(tensorImage.buffer, probabilityBuffer.buffer);
      var output = probabilityBuffer.getDoubleList();
      debugPrint("result ${output.toString()}");
      _showResultDialog(context, output.toString());
    } catch (e) {
      debugPrint(e.toString());
      _showResultDialog(context, e.toString());
    }
}

It seems that tensor lite lib does not support this library, but is there anything that could be done?

0

There are 0 best solutions below