Closed NeighborhoodCoding closed 1 year ago
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 ?
Hi, I made video classfication model convert by build.py but this error comes out...
How to resolve this error? thx.