kalaspuffar/tensorflow-data

I am trying to use my model on object detection but it is not detecting the object at all and this this the error am having

Closed this issue · 2 comments

2019-11-18 09:42:02.704 8365-8365/org.tensorflow.lite.examples.detection E/tensorflow: CameraActivity: Exception!
java.lang.RuntimeException: java.lang.IllegalArgumentException: ByteBuffer is not a valid flatbuffer model
at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.create(TFLiteObjectDetectionAPIModel.java:132)
at org.tensorflow.lite.examples.detection.DetectorActivity.onPreviewSizeChosen(DetectorActivity.java:109)
at org.tensorflow.lite.examples.detection.CameraActivity.onPreviewFrame(CameraActivity.java:200)
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1181)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6524)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
Caused by: java.lang.IllegalArgumentException: ByteBuffer is not a valid flatbuffer model
at org.tensorflow.lite.NativeInterpreterWrapper.createModelWithBuffer(Native Method)
at org.tensorflow.lite.NativeInterpreterWrapper.(NativeInterpreterWrapper.java:60)
at org.tensorflow.lite.Interpreter.(Interpreter.java:223)
at org.tensorflow.lite.Interpreter.(Interpreter.java:211)
at org.tensorflow.lite.examples.detection.tflite.TFLiteObjectDetectionAPIModel.create(TFLiteObjectDetectionAPIModel.java:130)
at org.tensorflow.lite.examples.detection.DetectorActivity.onPreviewSizeChosen(DetectorActivity.java:109) 
at org.tensorflow.lite.examples.detection.CameraActivity.onPreviewFrame(CameraActivity.java:200) 
at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1181) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6524) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888) 

Hi @Realdeve

I've not seen the code but from the error message, I can read that you are trying to use the raw ByteBuffer for your detection.

Try to change it over to a flat buffer. I have some demo code that describes this.

Look at line 27 to 32 at

https://github.com/kalaspuffar/tensorflow-mnist-test/blob/968420b08d82ed307fe891b4e6534443d8bfb02e/src/main/java/org/ea/tensorflow/App.java#L27

Hope this helps.

Best regards
Daniel

Thanks, I have solved the issue days ago... I really appreciate your help :)