Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot copy between a TensorFlowLite tensor with shape [1, 2535, 4] and a Java object with shape [1, 10647, 4]. #301

Closed
yangmh66 opened this issue Jan 22, 2021 · 2 comments

Comments

@yangmh66
Copy link

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?

@AndrzejKRK
Copy link

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};

@yangmh66
Copy link
Author

yangmh66 commented Jan 26, 2021

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)

yangmh66 added a commit to yangmh66/tensorflow-yolov4-tflite that referenced this issue Jan 28, 2021
For current android demo's configuration, the "isTiny"  should be true, otherwise, it will prompt error like  issue hunglc007#301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants