Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yolov5 Torchscript Lite Version #5809

Closed
1 task done
aseprohman opened this issue Nov 27, 2021 · 6 comments · Fixed by #6183
Closed
1 task done

Yolov5 Torchscript Lite Version #5809

aseprohman opened this issue Nov 27, 2021 · 6 comments · Fixed by #6183
Labels
question Further information is requested

Comments

@aseprohman
Copy link

Search before asking

Question

Hello @glenn-jocher et all,

when I run android demo project for yolov5 on android I see error message below. I have follow any insctruction for save model with _save_for_lite_interpreter() method but it has no change. How to fixed it ? thanks

Additional

java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: PytorchStreamReader failed locating file bytecode.pkl: file not found ()

@aseprohman aseprohman added the question Further information is requested label Nov 27, 2021
@glenn-jocher
Copy link
Member

glenn-jocher commented Nov 27, 2021

@aseprohman 👋 hi, thanks for letting us know about this possible problem with YOLOv5 🚀. We've created a few short guidelines below to help users provide what we need in order to get started investigating a possible problem.

How to create a Minimal, Reproducible Example

When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:

  • Minimal – Use as little code as possible to produce the problem
  • Complete – Provide all parts someone else needs to reproduce the problem
  • Reproducible – Test the code you're about to provide to make sure it reproduces the problem

For Ultralytics to provide assistance your code should also be:

  • Current – Verify that your code is up-to-date with GitHub master, and if necessary git pull or git clone a new copy to ensure your problem has not already been solved in master.
  • Unmodified – Your problem must be reproducible using official YOLOv5 code without changes. Ultralytics does not provide support for custom code ⚠️.

If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.

Thank you! 😃

@yinrong
Copy link
Contributor

yinrong commented Dec 27, 2021

basic tutorial not working:
android-demo-app/ObjectDetection
replace xxx.pt with yolov5 exported model.

@yinrong
Copy link
Contributor

yinrong commented Dec 27, 2021

@aseprohman have you solved this ?

@zhiqwang
Copy link
Contributor

zhiqwang commented Dec 27, 2021

FYI, The official torchscript exported by yolov5 only contains the general model inferencing part, one must implement the pre-preprocess (letterbox) and post-proprocess (nms) if they want to deploy this torchscript.

We did some experiments on yolort to embed the pre-processing and post-processing into the torchscript graph, so yolort can maintain a similar input and output interface with detr example in torchlive, here is a notebook for intuition of yolort. I think this can be used as the base of the experiment.

(In order to improve the user-friendliness of the interface, we use the pytorch-lightning module, torch.mobile does not seem to like this kind of wrapper, here may need to be slightly modified.)

@yinrong
Copy link
Contributor

yinrong commented Jan 4, 2022

@adrianholovaty you may try again. I run yolov5 demo with my own model successfully on android now. It do need to modify export.py in yolov5 as my merge request below.

image

@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 4, 2022

@aseprohman @yinrong good news 😃! Your original issue may now be fixed ✅ in PR #6183. To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants