pytorch / android-demo-app

PyTorch android examples of usage in applications
1.47k stars 607 forks source link

Failed to load Custom LSTM pytorch model in android #67

Open abhi111q opened 4 years ago

abhi111q commented 4 years ago

As i am trying to load custom pytorch lstm model in android studio using torch.load() .. it is throwing error which is mentioned below. Would anyone mind helping me out in this. What is the right way to load any custom model using torch.load() function.

Process: org.pytorch.helloworld, PID: 31234 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: open file failed, file path: torchmoji.pt (FileAdapter at ../caffe2/serialize/file_adapter.cc:11) (no backtrace available) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) Caused by: com.facebook.jni.CppException: open file failed, file path: torchmoji.pt (FileAdapter at ../caffe2/serialize/file_adapter.cc:11) (no backtrace available) at org.pytorch.NativePeer.initHybrid(Native Method) at org.pytorch.NativePeer.(NativePeer.java:18) at org.pytorch.Module.load(Module.java:23) at org.pytorch.helloworld.MainActivity.onCreate(MainActivity.java:94) at android.app.Activity.performCreate(Activity.java:6672) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612) ... 9 more

anbo724 commented 4 years ago

Same question

LiaoSS07 commented 3 years ago

Have you resolved this problem ?

aniruddhbansal2000 commented 3 years ago

I am facing the same issue, is there a way to resolve it