android-demo-app
android-demo-app copied to clipboard
Caused by: com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 ()
Hi, I made video classfication model convert by build.py but this error comes out...
Caused by: com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 ()
2021-12-09 14:29:19.733 29182-29182/org.pytorch.demo.torchvideo E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pytorch.demo.torchvideo, PID: 29182
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.torchvideo/org.pytorch.demo.torchvideo.MainActivity}: com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 ()
Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:320 (most recent call first):
(no backtrace available)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 ()
Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:320 (most recent call first):
(no backtrace available)
at org.pytorch.LiteNativePeer.initHybrid(Native Method)
at org.pytorch.LiteNativePeer.<init>(LiteNativePeer.java:23)
at org.pytorch.LiteModuleLoader.load(LiteModuleLoader.java:29)
at org.pytorch.demo.torchvideo.MainActivity.onCreate(MainActivity.java:82)
at android.app.Activity.performCreate(Activity.java:7136)
at android.app.Activity.performCreate(Activity.java:7127)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
... 11 more
2021-12-09 14:29:19.764 29182-29182/? I/Process: Sending signal. PID: 29182 SIG: 9
How to resolve this error? thx.
I'm working with 'SpeechRecognition' demo app, and I got the same error message 🥲
2021-12-10 13:13:44.250 10430-10461/org.pytorch.demo.speechrecognition E/AndroidRuntime: FATAL EXCEPTION: Thread-2
Process: org.pytorch.demo.speechrecognition, PID: 10430
com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 ()
Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:320 (most recent call first):
(no backtrace available)
at org.pytorch.LiteNativePeer.initHybrid(Native Method)
at org.pytorch.LiteNativePeer.<init>(LiteNativePeer.java:23)
at org.pytorch.LiteModuleLoader.load(LiteModuleLoader.java:29)
at org.pytorch.demo.speechrecognition.MainActivity.recognize(MainActivity.java:197)
at org.pytorch.demo.speechrecognition.MainActivity.run(MainActivity.java:183)
at java.lang.Thread.run(Thread.java:923)
https://github.com/pytorch/android-demo-app/issues/202#issuecomment-972664735 This (in issue #202) worked for me. hope it helps :)
I fix it by adding changing dependencies to
implementation 'org.pytorch:pytorch_android_lite:1.10.0'
The torch.jit.mobile has a _backport_for_mobile function to "backport" a model to a given version
from torch.jit.mobile import (
_backport_for_mobile,
_get_model_bytecode_version,
)
MODEL_INPUT_FILE = "model_v7.ptl"
MODEL_OUTPUT_FILE = "model_v5.ptl"
print("model version", _get_model_bytecode_version(f_input=MODEL_INPUT_FILE))
_backport_for_mobile(f_input=MODEL_INPUT_FILE, f_output=MODEL_OUTPUT_FILE, to_version=5)
print("new model version", _get_model_bytecode_version(MODEL_OUTPUT_FILE))
The torch.jit.mobile has a _backport_for_mobile function to "backport" a model to a given version
from torch.jit.mobile import ( _backport_for_mobile, _get_model_bytecode_version, ) MODEL_INPUT_FILE = "model_v7.ptl" MODEL_OUTPUT_FILE = "model_v5.ptl" print("model version", _get_model_bytecode_version(f_input=MODEL_INPUT_FILE)) _backport_for_mobile(f_input=MODEL_INPUT_FILE, f_output=MODEL_OUTPUT_FILE, to_version=5) print("new model version", _get_model_bytecode_version(MODEL_OUTPUT_FILE))
this lines solve model version issue But I facing similar error like below logcast
please anyone give solution about issue ... thanks in advanced.
@NeighborhoodCoding Hello. Were you able to fix the issue? If yes, can you please share your experience what did you modify. Thanks a lot in advance!
It's git source is updated about 6 month ago, and I noticed the problem is solved.
I fix it by adding changing dependencies to
implementation 'org.pytorch:pytorch_android_lite:1.10.0'
I am getting, Duplicate Class errors if i change version to any version than existing. How to resolve this issue?
The torch.jit.mobile has a _backport_for_mobile function to "backport" a model to a given version
from torch.jit.mobile import ( _backport_for_mobile, _get_model_bytecode_version, ) MODEL_INPUT_FILE = "model_v7.ptl" MODEL_OUTPUT_FILE = "model_v5.ptl" print("model version", _get_model_bytecode_version(f_input=MODEL_INPUT_FILE)) _backport_for_mobile(f_input=MODEL_INPUT_FILE, f_output=MODEL_OUTPUT_FILE, to_version=5) print("new model version", _get_model_bytecode_version(MODEL_OUTPUT_FILE))
this lines solve model version issue But I facing similar error like below logcast
please anyone give solution about issue ... thanks in advanced.
I am getting similar error, what is the solution ?