-
-
Notifications
You must be signed in to change notification settings - Fork 16.1k
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
What to do with output tensor (OpenVINO Inference) #7817
Comments
👋 Hello @GabrielDornelles, thank you for your interest in YOLOv5 🚀! Please visit our ⭐️ Tutorials to get started, where you can find quickstart guides for simple tasks like Custom Data Training all the way to advanced concepts like Hyperparameter Evolution. If this is a 🐛 Bug Report, please provide screenshots and minimum viable code to reproduce your issue, otherwise we can not help you. If this is a custom training ❓ Question, please provide as much information as possible, including dataset images, training logs, screenshots, and a public link to online W&B logging if available. For business inquiries or professional support requests please visit https://ultralytics.com or email support@ultralytics.com. RequirementsPython>=3.7.0 with all requirements.txt installed including PyTorch>=1.7. To get started: git clone https://github.com/ultralytics/yolov5 # clone
cd yolov5
pip install -r requirements.txt # install EnvironmentsYOLOv5 may be run in any of the following up-to-date verified environments (with all dependencies including CUDA/CUDNN, Python and PyTorch preinstalled):
StatusIf this badge is green, all YOLOv5 GitHub Actions Continuous Integration (CI) tests are currently passing. CI tests verify correct operation of YOLOv5 training (train.py), validation (val.py), inference (detect.py) and export (export.py) on macOS, Windows, and Ubuntu every 24 hours and on every commit. |
@GabrielDornelles 👋 Hello! Thanks for asking about handling inference results. YOLOv5 🚀 PyTorch Hub models allow for simple OpenVINO model loading and inference in a pure python environment of any YOLOv5 exported model: model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s.engine') # TensorRT
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s.onnx') # ONNX
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s_openvino_model/') # OpenVINO
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s.torchscript') # TorchScript
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s.mlmodel') # CoreML
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s.tflite') # TFLite Simple Inference ExampleThis example loads a pretrained YOLOv5s model from PyTorch Hub as import torch
# Model
model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # or yolov5m, yolov5l, yolov5x, etc.
# model = torch.hub.load('ultralytics/yolov5', 'custom', 'path/to/best.pt') # custom trained model
# Images
im = 'https://ultralytics.com/images/zidane.jpg' # or file, Path, URL, PIL, OpenCV, numpy, list
# Inference
results = model(im)
# Results
results.print() # or .show(), .save(), .crop(), .pandas(), etc.
results.xyxy[0] # im predictions (tensor)
results.pandas().xyxy[0] # im predictions (pandas)
# xmin ymin xmax ymax confidence class name
# 0 749.50 43.50 1148.0 704.5 0.874023 0 person
# 2 114.75 195.75 1095.0 708.0 0.624512 0 person
# 3 986.00 304.00 1028.0 420.0 0.286865 27 tie See YOLOv5 PyTorch Hub Tutorial for details. Good luck 🍀 and let us know if you have any other questions! |
Hi @glenn-jocher! Thanks for the answer, although I would like to understand what that shape was, I tried the implementation of yours to run the OpenVINO model, so if it worked I could just read the code and understand it. When loading the openvino model like you said model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s_openvino_model/') It searchs for a checkpoint
So I just looked over the code in frame = cv2.imread("/home/gabriel/Downloads/maxresdefault.jpg")
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
model = torch.hub.load('ultralytics/yolov5', 'custom', path='yolov5s_openvino_model/yolov5s.xml')
result = model(frame)
result.save() I think I can manage to get the code I want now that it works with the openvino files, but a quick correction would be that in order to run OpenVINO you need to pass .xml openvino file instead of openvino model directory. |
@GabrielDornelles good news 😃! Your original issue may now be fixed ✅ in PR #7826. To receive this update:
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 🚀! |
Working perfectly now! |
Resolves bug report ultralytics#7817
Resolves bug report ultralytics#7817
Great to hear that, @GabrielDornelles! 🎉 If you encounter any other questions or issues with YOLOv5 or need further assistance, feel free to reach out. Best of luck with your project, and happy coding! 🚀 |
Hi@glenn-jocher , Exception: [Errno 13] Permission denied: 'D:\update_infer\yolov5\best_openvino_model_16\openvino_model'. Cache may be out of date, try force_reload=True or see https://docs.ultralytics.com/yolov5/tutorials/pytorch_hub_model_loading for help. note: openvino_model folder contains all meta data information same as best_oprnvino_model folder |
@pinnintipraneethkumar hi there! It sounds like you're facing a file permission issue after renaming your model folder. This can happen due to various reasons such as the way the folder was renamed or the permissions set on the folder. Here's a quick thing you can try:
model = torch.hub.load('ultralytics/yolov5', 'custom', path='path/to/openvino_model.xml', force_reload=True) Make sure the Hopefully, this helps! If the issue persists, double-check the folder permissions and try running your script with administrative privileges or in a different directory. Happy coding! 😊 |
Search before asking
Question
I borrowed the inference code for openvino:
I don't understand what that output tensor (np.array in this case) is.
Additional
No response
The text was updated successfully, but these errors were encountered: