简体   繁体   中英

Tensorflow Lite Custom Object detection Model Error in Android app

could you please help to solve this error?

I am testing a custom Object Detection model using TensorFlow Lite in Android App according to the documentation, but I have an error when the library tries to recognize an image.

I am using the Tensorflow lite sample app: https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android

Using Task Library: https://www.tensorflow.org/lite/inference_with_metadata/task_library/object_detector

dependency version implementation 'org.tensorflow:tensorflow-lite-task-vision:0.1.0'

When this method is executed, this error is obtained:

method List<Detection> results = objectDetector.detect(TensorImage.fromBitmap(bitmap));

error

Abort message: 'JNI DETECTED ERROR IN APPLICATION: JNI NewStringUTF called with pending exception java.lang.NoSuchMethodError: no static method Lorg/tensorflow/lite/support/label/Category;.create(Ljava/lang/String;Ljava/lang/String;F)Lorg/tensorflow/lite/support/label/Category;"
        at java.util.List org.tensorflow.lite.task.vision.detector.ObjectDetector.detectNative(long, java.nio.ByteBuffer, int, int, int) (ObjectDetector.java:-2)
        at java.util.List org.tensorflow.lite.task.vision.detector.ObjectDetector.detect(org.tensorflow.lite.support.image.TensorImage, org.tensorflow.lite.task.core.vision.ImageProcessingOptions) (ObjectDetector.java:312)
        at java.util.List org.tensorflow.lite.task.vision.detector.ObjectDetector.detect(org.tensorflow.lite.support.image.TensorImage) (ObjectDetector.java:292)
        at java.util.List org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.recognizeImage(android.graphics.Bitmap) (TFLiteObjectDetectionAPIModel.java:87)
        at void org.tensorflow.lite.examples.detection.DetectorActivity$2.run() (DetectorActivity.java:187)
        at void android.os.Handler.handleCallback(android.os.Message) (Handler.java:938)
        at void android.os.Handler.dispatchMessage(android.os.Message) (Handler.java:99)
        at void android.os.Looper.loop() (Looper.java:223)
        at void android.os.HandlerThread.run() (HandlerThread.java:67)
    
        in call to NewStringUTF
        from java.util.List org.tensorflow.lite.task.vision.detector.ObjectDetector.detectNative(long, java.nio.ByteBuffer, int, int, int)'```

This issue has been fixed in the Jan, 2021, which is not included in 0.1.0. Please try the nightly version from Jcenter (not Maven), and see if it works.

org.tensorflow:tensorflow-lite-task-vision:0.0.0-nightly-SNAPSHOT

And we'll release a new stable version very soon in April. Please stay tuned!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM