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

TFLite Android ArrayIndex outofBound Exception length=40, index=-7 #22278

Closed
DeepakSridhar opened this issue Sep 14, 2018 · 8 comments · May be fixed by tensorflow/examples#121
Closed

TFLite Android ArrayIndex outofBound Exception length=40, index=-7 #22278

DeepakSridhar opened this issue Sep 14, 2018 · 8 comments · May be fixed by tensorflow/examples#121
Labels
comp:lite TF Lite related issues

Comments

@DeepakSridhar
Copy link

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Partially modified TFLite Android code

Describe the problem

Describe the problem clearly here. Be sure to convey here why it's a bug in TensorFlow or a feature request.
I converted mobilenet_v2_ssd trained using my data to tflite following the instructions in the blog post:
https://medium.com/tensorflow/training-and-serving-a-realtime-mobile-object-detector-in-30-minutes-with-cloud-tpus-b78971cf1193

I did not quantize the model since I didn't train it using quantized training. To run on mobile I set the
IS_QUANTIZED variable in Detector.Activity to false. When I run the app, i get the error
java.lang.ArrayIndexOutOfBoundsException: length=40; index=-8
at java.util.Vector.elementAt(Vector.java:326)
at java.util.Vector.get(Vector.java:442)
at org.tensorflow.demo.TFLiteObjectDetectionAPIModel.recognizeImage(TFLiteObjectDetectionAPIModel.java:214)

I thought the issue is due to the length of the output vector. So I changed the NUM_DETECTIONS in TFLiteObjectDetectionAPIModel.java to 40, then I get another error saying
Cannot copy between a TensorFlowLite tensor with shape [1, 10] and a Java object with shape [1, 40].

Is the length of output vector fixed? Please help me with the issue.Thanks!

@ymodak ymodak added the comp:lite TF Lite related issues label Sep 14, 2018
@idrissbellil
Copy link

idrissbellil commented Oct 29, 2018

The android demo app was made for one specific case this issue comment the last part of the last comment may solve your issue, you don't have to switch branch or anything, just do boundary checks like he did.

@suharshs
Copy link

suharshs commented Feb 8, 2019

Closing due to inactivity and since this is answered above.

@suharshs suharshs closed this as completed Feb 8, 2019
@aravindchaluvadi
Copy link

aravindchaluvadi commented Mar 5, 2019

ERROR : W/System.err: java.lang.ArrayIndexOutOfBoundsException: length=10; index=-2147483648

Even I am facing the same issue could you brief on the solution?

@suharshs

@patrick-ucr
Copy link

I am having similar issues when using custom trained models converted by https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/running_on_mobile_tensorflowlite.md

but don't see the problem with default models automatically downloaded.

@kiad4631
Copy link

I have it too.does not any one help us?
it is force for me

@HaFred
Copy link

HaFred commented Oct 27, 2019

I have it too.does not any one help us?
it is force for me

I suggest you refer to #22106 #22106 (comment) for solution.
It would help change the input tensor.

@codulers
Copy link

codulers commented Feb 21, 2020

@patrick-ucr Have you resolve this ?
I'm also facing same issue while working with custom models.

@karuneshpalekar
Copy link

karuneshpalekar commented Feb 7, 2021

@DeepakSridhar @HaFred I am facing the same issue . If there is any legitimate solution found until now ,Please forward .
Also let me know if this issue is caused mostly due to tflite model instead of a bad written code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:lite TF Lite related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.