2

I downloaded ssd_mobilenet_v2_mnasfpn_coco and untar it, found there is already a tflite file called model.tflite, I want to know how to use it in android app, can I replace original detect.tflite at object_detection android demo app with this model.tflite.

If can, is there anywhere I need to modify too?

Wade Wang
  • 536
  • 6
  • 11

1 Answers1

0

Yes, assuming you mean this but you need to change few things ... In TFLiteObjectDetectionAPIModel.java change the following values to

  • input size = 320
  • NUM_DETECTIONS = 100

P.S: You also need to add some missing label values in labelmap.txt which are wrongly added as ???

Community
  • 1
  • 1
Abdalkhalik
  • 16
  • 1
  • 2
  • Yeah, you got me, i mean that demo app. I have changed `input size = 320` and `NUM_DETECTIONS = 100`, but run it emulator, it reports error : `Cannot copy to a TensorFlowLite tensor (normalized_input_image_tensor) with 1228800 bytes from a Java Buffer with 307200 bytes.` Did you try it successfully ? – Wade Wang Jun 03 '20 at 17:24
  • @WadeWANG try to set the value of TF_OD_API_IS_QUANTIZED (located in DetectorActivity.java) to false, it should solve this problem – Abdalkhalik Jun 03 '20 at 18:55
  • After i set TF_OD_API_IS_QUANTIZED = false; it is still wrong, but the error became `Cannot copy from a TensorFlowLite tensor (WeightSharedConvolutionalBoxPredictor_3/BoxPredictor/BiasAdd) with shape [1, 5, 5, 36] to a Java object with shape [1, 100, 4].`. If you use netron to check these two tflite model, you can see their output is different, so i think there should be more codes need to change – Wade Wang Jun 04 '20 at 12:04
  • @WadeWANG Yes i ran it successfully .. did you remove the "download_model.gradle" content? as its maybe re-downloading the default tflite model everytime you replace it with mnasfpn model – Abdalkhalik Jun 04 '20 at 16:23
  • I disabled "download_model.gradle", but it still got the same error, would you mind sending the app project to my email box : wadewang96@outlook.com, then i will compare yours and mine to see on earth what the diffrence is. – Wade Wang Jun 05 '20 at 17:08
  • @WadeWANG https://drive.google.com/file/d/1854Ly-1CHwY0q0Ee3q_FFGgol_WbIkyG/view?usp=sharing I posted here in case anyone has the same problem – Abdalkhalik Jun 06 '20 at 08:06
  • Great ! I hava sent the request ~ – Wade Wang Jun 06 '20 at 10:42
  • @WadeWANG sorry, now you can download it without a request (https://drive.google.com/file/d/1854Ly-1CHwY0q0Ee3q_FFGgol_WbIkyG/view?usp=sharing) .. the new ui in GDrive is confusing – Abdalkhalik Jun 06 '20 at 11:45
  • I found our model.tflite are different ! My used `ssd_mobilenet_v2_mnasfpn_coco` model.tflite is older. Just now i go to model zoo page to redownload it, and find it is the same with yours, so that is to say, the official has updated the model file ! – Wade Wang Jun 06 '20 at 13:02