tensorflow / tflite-support

TFLite Support is a toolkit that helps users to develop ML and deploy TFLite models onto mobile / ioT devices.
Apache License 2.0
378 stars 128 forks source link

Error occurred when initializing ObjectDetector: AllocateTensors() failed. #900

Open yangqinjiang opened 1 year ago

yangqinjiang commented 1 year ago

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

lu-wang-g commented 1 year ago

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.