-
Notifications
You must be signed in to change notification settings - Fork 611
Getting Lite Interpreter #202
Comments
I have the same issue. I follow the steps exactly, use their own model and get this error. |
Any fix/workarounds found? |
@Treshank No I am making this issue just to let author know this codes are not working properly... |
Same issue also in TorchVideo as well. |
I am getting the same issue as well. |
@Treshank @andreanne-lemay |
I've tried resetting my local repo to this commit - cd35a009ba964331abccd30f6fa0614224105d39 as suggested but it doesn't exist (as far as I can see). |
@Michael97, i think they mean in model making, try setting the yolov5 repo to that, if you are using a custom model. I guess it doesn't apply to you otherwise |
Ah yeah, that makes sense. I'm using the provided one right now, well at least trying to use it. |
I tried it @Michael97, no luck.. |
The last git version that is sorta working for me is #141. It uses older PyTorch, still yet to test with custom model. |
I can't seem to be able to use my trained model with #141. If anyone has been able use/train a model, some instructions would be great |
Any news on this issue? @Treshank were you able to fix this? |
@Treshank @stefan-falk I was able to run my custom model (classification densenet) without the version number error by reverting to the commit @Treshank indicated (#141) on the HelloWorld demo. This also implicates going back to implementation 'org.pytorch:pytorch_android:1.8.0'
implementation 'org.pytorch:pytorch_android_torchvision:1.8.0' |
@andreanne-lemay thanks! I didn't try this with a pytorch model though. I was using a Tensorflow model (tflite).
But I guess I'll give pytorch a try then. 👍 |
@andreanne-lemay, what version of pytorch did you use to make the object detection model? |
@Treshank I used pytorch 1.10.0 and the following lines to convert my model: https://github.com/andreanne-lemay/cervical_mobile_app/blob/main/mobile_model_conversion.py |
@andreanne-lemay Thanks!! your solution works! Didnt have to use the converter tho, used the standard export.py with torchscript include option. #141 version uses .pt not .plt keep that in mind |
I can run the speech recognition example now with:
Thanks @andreanne-lemay for pointing me there 👍 |
yes @stefan-falk. Your solution is also working. Using the latest master branch, and simply changing in build.gradle |
I think I already tried that and it didn't work for some (probably other) reason. But never mind as long as it works now :) |
The
|
hi raedle, Is there any solution that we can apply without increasing the size of the model? |
It seems to be working, but I suppose it is better to change build.gradle to
|
Even I faced the similar issue, Moving to torch version 1.11.0 resolved the issue for me |
@MaratZakirov I'm getting this error on doing the backport RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
|
when i try to run ImageSegmentation demo, i get "model version must be between 3 and 7 but the model version is 8 ()" |
Don't know if this case still open, but I guess this will fix it: Make sure you use in the android build.gradle implementation 'org.pytorch:pytorch_android_lite:1.12.2' or any other higher pytorch library version on the android side. |
@JosephKKim Hello. Were you able to fix the issue? If yes, can you please share your experience what did you modify. |
Sharing what I experienced.. I've trained a Model using YOLOv5s with latest torch version, and export it to torchscript -- probably made as version 8 (in my case). To fix the error which @JosephKKim initially presented (which I had as well) -- I just changed the library on the build.gradle used to : I used the same Model on the iOS ObjectDetection -- https://github.com/pytorch/ios-demo-app/tree/master/ObjectDetection -- it ran flawlessly.. I had to change the code of the Podfile to use: So, I guess, the Model was trained and exported properly. But the android libraries are out-of-date? don't know exactly, still checking that. |
@nighthawk2032 thanks for your quick reply. Can you please share the link for export.py file you used to convert .pt model to .torchscript.ptl ? |
export.py is part of the YOLOv5 git repo https://github.com/ultralytics/yolov5/ |
@nighthawk2032 thanks for your reply. The initial yolov5s.torchscript.ptl model mentioned in Prepare the model part works good on both PyTorch lib versions 1.10.0, but with 1.12.2. As the export.py in official YOLO5 does not really convert pt model to torchscript.ptl (in converts to torchscript) https://github.com/ultralytics/yolov5/blob/master/export.py In Prepare the model part it was also mentioned to use the following command if there is any issue with the model Seems that reference is not acctual anymore and maybe there is a new number ? |
@HripsimeS follow the readme.md on the page: https://github.com/pytorch/android-demo-app/tree/master/ObjectDetection As I noted before, on my tests, so far, the torchscript.ptl Model seems to be exported properly (and working on the iOS demo). But the android code is faulty somewhere, I suspect on the linked pytorch_android_lite library itself. But that is just a guess.. If there is consistency (cross platformed) in the numbering of the versions, then iOS uses version 1.13 while android got only upto 1.12.2. In addition in the android-demo-app repo the description is that the demo written for PyTorch 1.10 -- since I didn't find any access to the archived pytoch 1.10 -- then I can not train my model example using it, so it'll be best fit as it was written back then. as for the latter part of your question -- seems to me like a git issue.. not sure where are you getting that from, and what did you run to raise these git branch errors. |
@nighthawk2032 thanks for your reply! git reset --hard was recommened in https://github.com/pytorch/android-demo-app/tree/master/ObjectDetection and they say if there's any issue with running the script or using the model, try git reset --hard cd35a009ba964331abccd30f6fa0614224105d39. That's the reason I tried to reset my yolov5 project on git bash here |
Hello thank you for the nice work you provided.
I am currently working on a project that uses yolo on android device...
I was so happy to find out these examples but somehow, it doesn't work on my environment.
Since I am new to android, even though I have experiences in PyTorch, it is hard to fix the code..
I am keep getting the error starts with
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: Lite Interpreter verson number does not match. The model version must be between 3 and 5But the model version is 7 () Exception raised from parseMethods at ../torch/csrc/jit/mobile/import.cpp:320 (most recent call first):
I can guess that this error is from LiteModuleLoader.. but have no idea how to fix it and the meaning of the interpreter version.
I would be glad if I get an answer thanks! :)
The text was updated successfully, but these errors were encountered: