Hi,
I want create my Android app by using my convolutional model written in Pytorch 1.4.0.
I was following the guidelines written in https://pytorch.org/mobile/android/ 2, in detail I was following example code indicating here: https://github.com/pytorch/android-demo-app/tree/master/HelloWorldApp 3.
I have problem when I import my model. Error is:
Process: org.pytorch.helloworld, PID: 15383
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.MainActivity}: com.facebook.jni.CppException: [enforce fail at inline_container.cc:143] . PytorchStreamReader failed reading zip archive: failed finding central directory
(no backtrace available)
on Android studio (versione 4.0). I read that this can be due to erroneous procedure to save model_traced.pt.
I saved Mymodel.pt  as below:
model.load_state_dict(torch.load(Mymodel.pt)
model.eval()
example_inputs=torch.rand(1,1,66,100)
Mymodel_traced=torch.jit.trace(model,example_inputs=example_inputs)
Mymodel_traced.save(“model_traced.pt”)
In my gradle I have:
dependencies {
implementation ‘androidx.appcompat:appcompat:1.1.0’
implementation ‘org.pytorch:pytorch_android:1.4.0’
implementation ‘org.pytorch:pytorch_android_torchvision:1.4.0’
}
How can I solve? Thank you.