Closed yangmh66 closed 3 years ago
When I tried to build project and Install on my android phone, I have encountered problem, the log as below:
2021-01-22 18:58:26.093 18112-18343/org.tensorflow.lite.examples.detection E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: org.tensorflow.lite.examples.detection, PID: 18112 java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 2535, 4] and a Java object with shape [1, 10647, 4]. at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:412) at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:369) at org.tensorflow.lite.Tensor.copyTo(Tensor.java:247) at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:166) at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:314) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.getDetectionsForFull(YoloV4Classifier.java:392) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.recognizeImage(YoloV4Classifier.java:544) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.recognizeImage(YoloV4Classifier.java:61) at org.tensorflow.lite.examples.detection.MainActivity.lambda$null$1$MainActivity(MainActivity.java:52) at org.tensorflow.lite.examples.detection.-$$Lambda$MainActivity$OxNL7NrV0ct8jl4zEsUXaD27RnY.run(Unknown Source:4) at java.lang.Thread.run(Thread.java:923)
Any idea?
change variable OUTPUT_WIDTH_FULL
from
private static final int[] OUTPUT_WIDTH_FULL = new int[]{10647, 10647};
to
private static final int[] OUTPUT_WIDTH_FULL = new int[]{2535, 2535};
Thanks for your reply!! When I modified the variable: isTiny from false to true, this error was gone!! The yolo-model file in assets directory was tiny model, but current configure in source code was full yolo!! If anyone wants to run this android project, he needs to take care of that by himself! (or download source code with the commit_id: 087052f, which's android project was workable)
When I tried to build project and Install on my android phone, I have encountered problem, the log as below:
2021-01-22 18:58:26.093 18112-18343/org.tensorflow.lite.examples.detection E/AndroidRuntime: FATAL EXCEPTION: Thread-2 Process: org.tensorflow.lite.examples.detection, PID: 18112 java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 2535, 4] and a Java object with shape [1, 10647, 4]. at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:412) at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:369) at org.tensorflow.lite.Tensor.copyTo(Tensor.java:247) at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:166) at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:314) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.getDetectionsForFull(YoloV4Classifier.java:392) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.recognizeImage(YoloV4Classifier.java:544) at org.tensorflow.lite.examples.detection.tflite.YoloV4Classifier.recognizeImage(YoloV4Classifier.java:61) at org.tensorflow.lite.examples.detection.MainActivity.lambda$null$1$MainActivity(MainActivity.java:52) at org.tensorflow.lite.examples.detection.-$$Lambda$MainActivity$OxNL7NrV0ct8jl4zEsUXaD27RnY.run(Unknown Source:4) at java.lang.Thread.run(Thread.java:923)
Any idea?