1. Are you ready for the Galaxy S20? Here is everything we know so far!

Problem with Android Image classification app start

Discussion in 'Android Development' started by JuliaZ, Jul 22, 2019.

  1. JuliaZ

    JuliaZ Newbie
    Thread Starter

    Hello everyone! While I try to run my custom Image classification app, I am getting a mistake:
    Code (Text):
    1.  
    2. java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 30] and a Java object with shape [1, 1].
    3.  at org.tensorflow.lite.Tensor.throwIfShapeIsIncompatible(Tensor.java:282)
    4.  at org.tensorflow.lite.Tensor.throwIfDataIsIncompatible(Tensor.java:249)
    5.  at org.tensorflow.lite.Tensor.copyTo(Tensor.java:141)
    6.  at org.tensorflow.lite.NativeInterpreterWrapper.run(NativeInterpreterWrapper.java:161)
    7.  at org.tensorflow.lite.Interpreter.runForMultipleInputsOutputs(Interpreter.java:275)
    8.  at org.tensorflow.lite.Interpreter.run(Interpreter.java:249)
    9.  at com.example.android.tflitecamerademo.ImageClassifier.classifyFrame(ImageClassifier.java:117)
    10.  at com.example.android.tflitecamerademo.Camera2BasicFragment.classifyFrame(Camera2BasicFragment.java:663)
    11.  at com.example.android.tflitecamerademo.Camera2BasicFragment.access$900(Camera2BasicFragment.java:69)
    12.  at com.example.android.tflitecamerademo.Camera2BasicFragment$5.run(Camera2BasicFragment.java:558)
    13.  at android.os.Handler.handleCallback(Handler.java:873)
    14.  at android.os.Handler.dispatchMessage(Handler.java:99)
    15.  at android.os.Looper.loop(Looper.java:201)
    16.  at android.os.HandlerThread.run(HandlerThread.java:65)
    17.  
    My model parameters are:
    Code (Text):
    1. == Input details ==
    2. name: x shape: [  1 256 256   3]
    3. type: <class 'numpy.float32'>
    4.  == Output details ==
    5. name: Identity shape: [ 1 30]
    6. 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.
     


    #1 JuliaZ, Jul 22, 2019
    Last edited: Jul 22, 2019
  2. 23tony

    23tony Well-Known Member

    Please share, it would be helpful to see the context of the error.
     
  3. JuliaZ

    JuliaZ Newbie
    Thread Starter

    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 (Text):
    1.  
    2. static final int DIM_IMG_SIZE_X = 224;
    3. static final int DIM_IMG_SIZE_Y = 224;
    4.  
    5. private static final int IMAGE_MEAN = 128;
    6. private static final float IMAGE_STD = 128.0f;
    7.  
    In this case:
    Code (Text):
    1.  
    2. static final int DIM_IMG_SIZE_X = 256;
    3. static final int DIM_IMG_SIZE_Y = 256;
    4.  
    5. private static final int IMAGE_MEAN = 128;
    6. private static final float IMAGE_STD = 128;
    7.  
    I don't understand, why I have a mistake mentioned above...
     
  4. 23tony

    23tony Well-Known Member

    I would say the clue is here:
    Code (Text):
    1. 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.
     
  5. JuliaZ

    JuliaZ Newbie
    Thread Starter

    Thank you! So, I need to find a string where I can change this Java object with shape [1, 1] to shape [1, 30]...
     
Loading...

Share This Page

Loading...