sumn2u / flutter_tflite

Flutter plugin for TensorFlow Lite.
MIT License
2 stars 1 forks source link

FLutter Android Issue: MissingPluginException(No implementation found for method loadModel on channel tflite) #2

Open kalpeshTOPS opened 1 month ago

kalpeshTOPS commented 1 month ago

i am facing issue with loading models in android devices. Its working on ios device.

i have implemented below method

initTiflite() async { try { await Tflite.loadModel( model: "assets/yolov2_tiny.tflite", labels: "assets/yolov2_tiny.txt", numThreads: 1, isAsset: true, useGpuDelegate: false, ); print("Model loaded successfully"); } catch (e) { print("Error loading TensorFlow Lite model: $e"); } }

Can you anyone help me with this?

sumn2u commented 1 month ago

Can you share your pubspec.yaml file that contains tflite?

kalpeshTOPS commented 1 month ago

pubsspec.zip

here is attached file.

sumn2u commented 1 month ago

pubsspec.zip

here is attached file.

Thanks.

I see that you haven't added the assets for your model and library. Could you please include them as outlined in the README.md file?

You can link the library like this.


tflite:
    git:
      url: https://github.com/sumn2u/flutter_tflite.git
      ref: main
sumn2u commented 1 month ago

I added an example application in the repo for reference.

kalpeshTOPS commented 1 month ago

Thanks.

I am able to load model success fully but i got android app crash while object detection.

i tried below code variation to detect object from live stream

1) var detector = await Tflite.detectObjectOnFrame( bytesList: image.planes.map((plane) { return plane.bytes; }).toList(), model: "YOLO", imageHeight: image.height, imageWidth: image.width, imageMean: 0, imageStd: 255, numResultsPerClass: 1, threshold: 0.3, );

2) var detector = await Tflite.runModelOnFrame( bytesList: image.planes.map((plane) { return plane.bytes; }).toList(), imageHeight: image.height, imageWidth: image.width, // imageMean: 127.5, // imageStd: 127.5, // rotation: 90, numResults: 6, threshold: 0.05, asynch: true);

error i am getting is like below

PlatformException (PlatformException(Failed to run model, Interpreter busy, java.lang.RuntimeException: Interpreter busy at sq.flutter.tflite.TflitePlugin$TfliteTask.(TflitePlugin.java:486) at sq.flutter.tflite.TflitePlugin$RunYOLO.(TflitePlugin.java:777) at sq.flutter.tflite.TflitePlugin.detectObjectOnFrame(TflitePlugin.java:675) at sq.flutter.tflite.TflitePlugin.onMethodCall(TflitePlugin.java:169) at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267) at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292) at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319) at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8919) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) , null))

Can you please help me with this?

sumn2u commented 1 month ago

It's really hard to detect the issue based on the provided error message. Can you try running example application attached in this repo?

kalpeshTOPS commented 1 month ago

Ok I will try. But the example only contains the object detected over the image not on the camera live frame.

On Fri, Sep 20, 2024 at 7:49 AM Suman Kunwar @.***> wrote:

It's really hard to detect the issue based on the provided error message. Can you try running example application attached in this repo?

— Reply to this email directly, view it on GitHub https://github.com/sumn2u/flutter_tflite/issues/2#issuecomment-2362575346, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALFMYFWVGBPEBRP336OWSS3ZXOA37AVCNFSM6AAAAABONUWJ56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRSGU3TKMZUGY . You are receiving this because you authored the thread.Message ID: @.***>

-- Thanks & Regards Kalpesh Pipaliya | iOS Developer

Tops Infosolutions Pvt. Ltd. Mobile: +91 8460026268 Skype: kalpesh_257