Hi everyone,
I'm training some faster rcnn models with only one class on
my own data set. The training goes fine but when I export
model for inference and try to used it on android sample app
(TF Detect), I'm getting the following exception:
11-28 10:56:27.002 15666 16593 E AndroidRuntime: FATAL EXCEPTION: inference
11-28 10:56:27.002 15666 16593 E AndroidRuntime: Process: org.tensorflow.demo, PID: 15666
11-28 10:56:27.002 15666 16593 E AndroidRuntime: java.nio.BufferOverflowException
11-28 10:56:27.002 15666 16593 E AndroidRuntime: at java.nio.HeapFloatBuffer.put(HeapFloatBuffer.java:179)
11-28 10:56:27.002 15666 16593 E AndroidRuntime: at org.tensorflow.Tensor.writeTo(Tensor.java:488)
11-28 10:56:27.002 15666 16593 E AndroidRuntime: at org.tensorflow.contrib.android.TensorFlowInferenceInterface.fetch(TensorFlowInferenceInterface.java:478)
11-28 10:56:27.002 15666 16593 E AndroidRuntime: at org.tensorflow.contrib.android.TensorFlowInferenceInterface.fetch(TensorFlowInferenceInterface.java:432)
11-28 10:56:27.002 15666 16593 E AndroidRuntime: at org.tensorflow.demo.TensorFlowObjectDetectionAPIModel.recognizeImage(TensorFlowObjectDetectionAPIModel.java:167)
at the following line of code from TensorFlowObjectDetectionAPIModel class:
inferenceInterface.fetch(outputNames[0], outputLocations);
I tried these two models:
faster_rcnn_resnet101_pets
faster_rcnn_inception_v2_pets
Do you have any idea about what is causing this exception?
Regards,
Hi,
I tried to use other meta architectures with the android demo as well. But except for SSD no other architecture is working. I get the same exception like you. Maybe the proposal networks of faster r-cnn and r-fcn have too many processing requirements?
It can't be the size of the graph because the faster r-cnn with inception v2 is 54,5 MB compared to the working SSD inception model with 97,2 MB.
Maybe you can ask for a feature request on other meta architectures?
Hi @chrza,
Same as you. Only SSD mobile net is working on the android sample. I'm testing other meta architectures right now and let you know the results after testing them.
Thanks
@petewarden might know the latest status of various models on Android.
Found this same error while trying to use SSD mobile net trained for pascal dataset.
Hi @oldschool69,
Can you tell us, how did other meta architectures work out?
@oldschool69 found my problem! The BufferOverflowException was happening because my model was making more predictions that the defined length of outputLocations (same for outputScores and outputClasses). Either make this arrays longer or limit the amount of predictions made by model (in config file).
Good luck!
@andersskog can you please elaborate on how you did this? I am encountering the same problem atm, Thanks!
@aldrin233 take a look at your model config file, near the end you will find:
post_processing {
batch_non_max_suppression {
score_threshold: 0.2
iou_threshold: 0.6
max_detections_per_class: 30
max_total_detections: 30
}
score_converter: SIGMOID
}
Here I have set max detections to 30. The problem was that in the android app, Tensorflow Object Detection API file line 45 set max results to 20. When inference was made, 30 results were returned for an array expecting just 20 results. This causes the BufferOverflowException.
Hope this helps!
Please try new instructions here for a better experience
https://medium.com/tensorflow/training-and-serving-a-realtime-mobile-object-detector-in-30-minutes-with-cloud-tpus-b78971cf1193
Try to increase the value of max results in TensorFlowObjectDetectionAPIModel.java, I have changed it from 100 to 500 and I don't get the exception anymore.
net
did you find any solution ?if yes pls share
For me, increasing the number of max_detections for Faster-RCNN did not work. but changing the model to SSD, made the error go away.
@andersskog My frozen_inference_graph.pb is 190MB, and it seems too big, and the app run out of memory and crashes. What is the size of your .pb file?
Most helpful comment
@oldschool69 found my problem! The BufferOverflowException was happening because my model was making more predictions that the defined length of outputLocations (same for outputScores and outputClasses). Either make this arrays longer or limit the amount of predictions made by model (in config file).
Good luck!