hunglc007 / tensorflow-yolov4-tflite

YOLOv4, YOLOv4-tiny, YOLOv3, YOLOv3-tiny Implemented in Tensorflow 2.0, Android. Convert YOLO v4 .weights tensorflow, tensorrt and tflite
https://github.com/hunglc007/tensorflow-yolov4-tflite
MIT License
2.23k stars 1.24k forks source link

How to deploy in Android #175

Open Julius-ZCJ opened 4 years ago

Julius-ZCJ commented 4 years ago

I have trained one model, and I generate the .tflite file, How to deploy that model in Android

Julius-ZCJ commented 4 years ago

When I use Android studio to run in the mobile phone, I get follow error:

E/AndroidRuntime: FATAL EXCEPTION: main Process: org.tensorflow.lite.examples.detection, PID: 12865 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.tensorflow.lite.examples.detection/org.tensorflow.lite.examples.detection.MainActivity}: java.lang.RuntimeException: java.lang.IllegalArgumentException: Internal error: Cannot create interpreter: Didn't find op for builtin opcode 'LEAKY_RELU' version '2'

Registration failed.

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
    at android.app.ActivityThread.-wrap11(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
 Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Internal error: Cannot create interpreter: Didn't find op for builtin opcode 'LEAKY_RELU' version '2'

Registration failed.

what I do to run :

  1. modify android/app/build.gradle comment out line 44 : apply from: 'download_model.gradle'
  2. modify app\src\main\java\org\tensorflow\lite\examples\detection/MainActivity.java line 77: TF_OD_API_MODEL_FILE = "yolov3-416-int8.tflite" line 79: TF_OD_API_LABELS_FILE = "file:///android_asset/labelmap.txt"

What should I do to fix this bug?

josephbiko commented 4 years ago

Change the gradle version to nightly

czy9987 commented 4 years ago

Hello, have you implemented your own tflite model deployment? I trained a tiny version of tflite model, but when I replaced the original model and label file, the program always crashed when opened.

How did you achieve it?

josephbiko commented 4 years ago

What error did you get? I have indeed trained my own versions. (did you change the isTiny label flag?)

czy9987 commented 4 years ago

What error did you get? I have indeed trained my own versions. (did you change the isTiny label flag?)

The problem I encountered is here, take a look(https://github.com/hunglc007/tensorflow-yolov4-tflite/issues/204

FlavorDots commented 3 years ago

What error did you get? I have indeed trained my own versions. (did you change the isTiny label flag?)

How did you deploy yolov4-tiny? Upon following the instructions the app always crashes.