4
votes

I have been trying this for a last few days. I have downloaded a sample from here. I have replaced the model Detect.tflite and label file and put my own instead, but ended up with several errors as shown below:

java.lang.IllegalArgumentException: Cannot convert between a TensorFlowLite buffer with 1080000 bytes and a ByteBuffer with 270000 bytes.

And this one:

java.lang.IllegalArgumentException: Cannot copy between a TensorFlowLite tensor with shape [1, 1917, 4] and a Java object with shape [1, 10,4].

Kindly help.

2
With what did you replace the model? Can you share both versions, please? - Phash
The sample have detect.tflite model and label.txt. I have changed that with my .tflite model and label.txt - Vir Rajpurohit
please update your question with the contents you changed. - Phash
It seems, you have changed the data with different dimensions, There is mismatch in the input shape [older and the new] - Gaurav
@Gaurav, might be the model have done so. Don't know where exactly the problem lies. - Vir Rajpurohit

2 Answers

0
votes

The issue is all about the mismatch of input tensor from the model and the array we mention in the code(Android).

Changing in the input tensor did the trick and model worked well in this case.

The input tensor shape array was changed to [1, 10,4] from python side.

0
votes

In my case I was using teachable machine to generate my .tflite file, and when you need to install it you'll have punch of options like: Floating point or Quantized or EdgeTPU.

And Floating point was the only one which works without causing the issue mentioned.