Failed to Load Custom Model in Android #19
Comments
same question |
1 similar comment
same question |
@junjuew thanks for your feedback and it does look similar as #26764. |
@ljk53 I reproduced this error using an open-sourced neural style transfer network from here. The original repo is a bit convoluted, so I created a simple repo here to demonstrate the problem. The DNN definition is here. The README.md shows the steps of tracing in python and loading successfully in C++. However, when using the saved model in the android app, the error mentioned above occurs. |
@junjuew thanks for creating the easy repro steps. We are working on a fix now. I reopened #26764 and will keep updating there. |
@junjuew my fixes were landed and available in 1.4-snapshot build. You can update your build.gradle to try 1.4-snapshot, like this: ljk53@443b524 Please let me know if it fixes your problem, thanks! |
@ljk53 It fixed my problem. Thank you. I'll go ahead and close this issue then. |
@ljk53 When I switch my dependencies to those found in the changes you linked "1.4.0-SNAPSHOT," i get the following errors "ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform artifact 'pytorch_android.aar (org.pytorch:pytorch_android:1.4.0-SNAPSHOT:20191115.103440-37)' to match attributes {artifactType=jar}" |
I also get those errors when using 1.4.0-SNAPSHOT. |
@ljk53 The first few weeks, my project is OK when I used the "1.4.0-SNAPSHOT", but now it go wrong.The error is same to @IsaacBerman . |
@IsaacBerman You find any method to solve your question, if you have solved it , please tell me, thanks. |
@Joyako No fix as of yet, will let you know if I find something. |
@Joyako A project clean fixed the "Unable to resolve dependency error," but the original error still stands for me. |
We had some issues with snapshot uploads that should be resolved now. I just downloaded this repo, made these changes, and was able to run diff --git i/PyTorchDemoApp/app/build.gradle w/PyTorchDemoApp/app/build.gradle
index c0226ed..8ca451e 100644
--- i/PyTorchDemoApp/app/build.gradle
+++ w/PyTorchDemoApp/app/build.gradle
@@ -2,6 +2,9 @@ apply plugin: 'com.android.application'
repositories {
jcenter()
+ maven {
+ url "https://oss.sonatype.org/content/repositories/snapshots"
+ }
}
android {
@@ -35,6 +38,6 @@ dependencies {
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation 'com.google.android.material:material:1.0.0-beta01'
- implementation 'org.pytorch:pytorch_android:1.3.0'
- implementation 'org.pytorch:pytorch_android_torchvision:1.3.0'
+ implementation 'org.pytorch:pytorch_android:1.4.0-SNAPSHOT'
+ implementation 'org.pytorch:pytorch_android_torchvision:1.4.0-SNAPSHOT'
} |
Hello,
I'm trying to deploy a custom model in python to Android using pytorch mobile. I used torch.jit.trace to trace and then save the model. The saved model is working correctly when I load it in both C++ and python. However, when using pytorch_android, the following error occurred when loading the module (inside Module.load(modelFileAbsolutePath) function). The only thing different from the PyTorchDemoApp is the model file path. And I've confirmed that the model file path is correct and the file exists. I'm using pytorch 1.3.0 in both python and android.
Any suggestions on why the model loading would fail? Would this be related to this issue? Any suggestions on how to get more debugging information? Thank you!
The text was updated successfully, but these errors were encountered: