tflite-support icon indicating copy to clipboard operation
tflite-support copied to clipboard

Error occurred when initializing ObjectDetector: AllocateTensors() failed.

Open yangqinjiang opened this issue 3 years ago • 1 comments

I used the PT file trained by yolov5, converted it to tflite file, and ran it with the official android code. An error was reported

java.lang.IllegalStateException: Error occurred when initializing ObjectDetector: AllocateTensors() failed. at org.tensorflow.lite.task.vision.detector.ObjectDetector.initJniWithModelFdAndOptions(Native Method)

the tflite added metadata by https://github.com/ultralytics/yolov5 tflite file see attach files: assets.zip

image

the command: cd yolov5 dir; python3 export.py --weight runs/train/exp4/weights/best.pt --include tflite --int8 --nms --agnostic-nms --data /mnt/yolov5-beev2/bee-linux.yaml --imgsz 320

the android code, like ImageClassifier https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android_java

image

But when I run it, I get an error assets.zip

Can someone help me with this problem? !! 3q I'll show you the source code. android_java.zip

yangqinjiang avatar Nov 21 '22 06:11 yangqinjiang

May you please try if the model works with TFLite Interpreter? You can feed some dummy input to see if it can run. Once it's verified, we can further debug it from Task Library side.

lu-wang-g avatar Aug 08 '23 00:08 lu-wang-g