pytorch / android-demo-app

PyTorch android examples of usage in applications
1.46k stars 604 forks source link

Try to use pytorch_android:1.10.0 #216

Open l-atome opened 2 years ago

l-atome commented 2 years ago

Hello, from yolov5s, i created my own model and try to integrate it to "ObjectDetection" but I have the following error:

The model version must be between 3 and 5But the model version is 7 ()

I think that i use pytorch:1.10 on my computer (??)

So, i try to change the next two lines of "build:gradle:app" :

implementation 'org.pytorch:pytorch_android_lite:1.10.0' implementation 'org.pytorch:pytorch_android_torchvision:1.10.0'

But during the compilation of "ObjectDetection", i have the following error :

Duplicate class org.pytorch.BuildConfig found in modules jetified-pytorch_android-1.10.0-runtime (org.pytorch:pytorch_android:1.10.0) and jetified-pytorch_android_lite-1.10.0-runtime (org.pytorch:pytorch_android_lite:1.10.0)

What can i do to use my proper yolov5s model with ObjectDetection

Thanks for your help L'Atome

cloveropen commented 2 years ago

I think this is what you want :https://github.com/jeffxtang/android-demo-app/tree/pt1.10

l-atome commented 2 years ago

Thanks for all

phillies commented 2 years ago

To make things easier here is the direct solution: The pytorch guys changed torchvision to torchvision_lite from 1.9.0 to 1.10.0 which breaks the build when you just update the version number. You need to replace the dependency implementation 'org.pytorch:pytorch_android_torchvision:1.10.0' with implementation 'org.pytorch:pytorch_android_torchvision_lite:1.10.0' (adding the _lite).

kartikpodugu commented 1 year ago

To make things easier here is the direct solution: The pytorch guys changed torchvision to torchvision_lite from 1.9.0 to 1.10.0 which breaks the build when you just update the version number. You need to replace the dependency implementation 'org.pytorch:pytorch_android_torchvision:1.10.0' with implementation 'org.pytorch:pytorch_android_torchvision_lite:1.10.0' (adding the _lite).

This worked for me, but classification results are coming wrong with ptl file generated from the script given along with HelloWorld app.