pytorch / android-demo-app

PyTorch android examples of usage in applications
1.45k stars 593 forks source link

com.facebook.jni.CppException: Lite Interpreter version number does not match. The model version must be between 3 and 7 but the model version is 8 () #283

Closed HripsimeS closed 1 year ago

HripsimeS commented 1 year ago

Hello. Thank you for the nice work you provided. I work on a project that uses yolov5s on android device. I converted my trained .pt model to .torchscript.ptl with this export file https://github.com/jeffxtang/yolov5/blob/master/models/export.py and did all modification mentioned in https://github.com/pytorch/android-demo-app/tree/master/ObjectDetection

When I launch the app with my model I receive the following errors

E/QT: [QT]file does not exist E/MiuiMultiWindowUtils: initFreeFormResolutionArgs failed, device is eos E/ion: ioctl c0044901 failed with code -1: Invalid argument E/AndroidRuntime: FATAL EXCEPTION: main Process: org.pytorch.demo.objectdetection, PID: 28987 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: Lite Interpreter version number does not match. The model version must be between 3 and 7 but the model version is 8 ()

I can guess that this error is from LiteModuleLoader, but I have no idea how to fix the interpreter version. I would be glad if you could help me to fix this issue, thanks a lot in advance! @romovpa @kostmo @smacke @kit1980 @jeffxtang @IvanKobzarev @nairbv

vccheng2001 commented 1 year ago

Hello, what was the fix to this issue? Thanks!

AdamFonagy commented 1 year ago

Hi @vccheng2001,

You just need to change the build dependencies in the build.gradle from

    implementation 'org.pytorch:pytorch_android_lite:1.10.0'
    implementation 'org.pytorch:pytorch_android_torchvision_lite:1.10.0'

to

    implementation 'org.pytorch:pytorch_android_lite:1.13.1'
    implementation 'org.pytorch:pytorch_android_torchvision_lite:1.13.1'

and rebuild the project.