• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Problem with Android Image classification app start

JuliaZ

Newbie
Hello everyone! While I try to run my custom Image classification app, I am getting a mistake:
Code:
java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 30] and a Java object with shape [1, 1].
 at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:282)
 at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:249)
 at org.tensorflow.lite.Tensor.copyTo(Tensor.java:141)
 at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:161)
 at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:275)
 at org.tensorflow.lite.Interpreter.run(Interpreter.java:249)
 at com.example.android.tflitecamerademo.ImageClassifier.classifyFrame(ImageClassifier.java:117)
 at com.example.android.tflitecamerademo.Camera2BasicFragment.classifyFrame(Camera2BasicFragment.java:663)
 at com.example.android.tflitecamerademo.Camera2BasicFragment.access$900(Camera2BasicFragment.java:69)
 at com.example.android.tflitecamerademo.Camera2BasicFragment$5.run(Camera2BasicFragment.java:558)
 at android.os.Handler.handleCallback(Handler.java:873)
 at android.os.Handler.dispatchMessage(Handler.java:99)
 at android.os.Looper.loop(Looper.java:201)
 at android.os.HandlerThread.run(HandlerThread.java:65)

My model parameters are:
Code:
== Input details ==
name: x shape: [  1 256 256   3]
type: <class 'numpy.float32'>
 == Output details ==
name: Identity shape: [ 1 30]
type: <class 'numpy.float32'>

I use .lite format with quantization.
If you know how to help me, please, write! Also, I can show all my codes for rewriting.
 
Last edited:
I used this repo: https://github.com/googlecodelabs/tensorflow-for-poets-2/tree/master/android/tflite
But I add my graph.lite model and labels.txt. Also I changed this strings:

Code:
static final int DIM_IMG_SIZE_X = 224;
static final int DIM_IMG_SIZE_Y = 224;

private static final int IMAGE_MEAN = 128;
private static final float IMAGE_STD = 128.0f;

In this case:
Code:
static final int DIM_IMG_SIZE_X = 256;
static final int DIM_IMG_SIZE_Y = 256;

private static final int IMAGE_MEAN = 128;
private static final float IMAGE_STD = 128;

I don't understand, why I have a mistake mentioned above...
 
I would say the clue is here:
Code:
Cannot copy between a TensorFlowLite tensor with shape [1, 30] and a Java object with shape [1, 1].
It looks like the shapes are different, preventing the copy.

I don't know anything about Tensorflow, unfortunately, and this seems to be an error specific to that library. Hopefully someone with more knowledge of it can chime in.
 
Thank you! So, I need to find a string where I can change this Java object with shape [1, 1] to shape [1, 30]...
 
Back
Top Bottom