Closed aravinthk00 closed 1 year ago
if I load the custom model in Object Detection APP, I am facing issues , my logcast 👍
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pytorch.demo.objectdetection, PID: 8597
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 ()
Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:317 (most recent call first):
(no backtrace available)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3676)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3813)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: 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 ()
Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:317 (most recent call first):
(no backtrace available)
at org.pytorch.LiteNativePeer.initHybrid(Native Method)
at org.pytorch.LiteNativePeer.
Already I read and try that repo issue given solutions, But I can't get solution .. please help me out ... Advanced in thanks...
**I am working on android-demo-apps/ObjectDetection/). I fellow the given steps to train and export pt to ptl, after I get best.torchscript.ptl but import in android app facing issue on model version above mentioned, then model version issue resolve refer that solution, so please give step by step instruction about that how to train and export the compatible custom model for Object Detection Pytorch App. till now I am struggling in error like below
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.pytorch.demo.objectdetection, PID: 4679
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: isTuple()INTERNAL ASSERT FAILED at "../aten/src/ATen/core/ivalue_inl.h":1396, please report a bug to PyTorch. Expected Tuple but got String ()
Exception raised from toTuple at ../aten/src/ATen/core/ivalue_inl.h:1396 (most recent call first):
(no backtrace available)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3676)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3813)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2308)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7898)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: com.facebook.jni.CppException: isTuple()INTERNAL ASSERT FAILED at "../aten/src/ATen/core/ivalue_inl.h":1396, please report a bug to PyTorch. Expected Tuple but got String ()
Exception raised from toTuple at ../aten/src/ATen/core/ivalue_inl.h:1396 (most recent call first):
(no backtrace available)
at org.pytorch.LiteNativePeer.initHybrid(Native Method)
at org.pytorch.LiteNativePeer.
I can't get idea about that, please give clear solution about, anyone guide me, It is very important to my career. Thanks lot..
I fix this issue, just I upadate on " implementation 'org.pytorch:pytorch_android_lite:1.12.1' implementation 'org.pytorch:pytorch_android_torchvision_lite:1.10.0' in my build.gradle file. it's work for me . you also check once, It will helps for others.
Thankyou :-)
thanks man, spending days searching for some error, and some of my error ends here. here is my condition using : YOLOv5s
to comeout with solution in this issue need to convert your model, in my case it is in version 8 to version 5 using this code
''' from torch.jit.mobile import ( _backport_for_mobile, _get_model_bytecode_version, )
MODEL_INPUT_FILE = "best.torchscript.ptl" MODEL_OUTPUT_FILE = "bestv5.torchscript.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)) '''
hope this help
Please give me brief detail about How do train the custom model for Object Detection Pytorch App & HelloWorld App ?