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

Guidance/Libary Needed for ONNX Model Post-Processing #13436

Open
1 task done
Throws100 opened this issue Nov 27, 2024 · 4 comments
Open
1 task done

Guidance/Libary Needed for ONNX Model Post-Processing #13436

Throws100 opened this issue Nov 27, 2024 · 4 comments
Labels
exports Model exports (ONNX, TensorRT, TFLite, etc.) question Further information is requested

Comments

@Throws100
Copy link

Search before asking

Question

I've trained a custom YOLOv5 model that performs well, and I've exported it as an ONNX file. However, the output from the ONNX model differs from my expectations. After researching, I understand that ONNX outputs require additional post-processing to match the results seen with the PyTorch model.

Unfortunately, I'm struggling to implement this post-processing manually. Since deploying models in other languages is a common task, I was wondering if anyone could point me to an existing component or library that handles YOLOv5 ONNX post-processing.

Any guidance or resources would be greatly appreciated!
Thank you, Seb

Additional

No response

@Throws100 Throws100 added the question Further information is requested label Nov 27, 2024
@UltralyticsAssistant UltralyticsAssistant added the exports Model exports (ONNX, TensorRT, TFLite, etc.) label Nov 27, 2024
@UltralyticsAssistant
Copy link
Member

👋 Hello @Throws100, thank you for your interest in YOLOv5 🚀! Your question about ONNX model post-processing is noted. This is an automated response, but an Ultralytics engineer will assist you further as soon as possible 😊.

For now, if this is a 🐛 Bug Report, please provide a minimum reproducible example to help us debug it. This should include any relevant code snippets and a description of inputs and outputs.

If this is a custom training ❓ Question, please provide as much detail as possible, including examples of outputs and specific steps you've followed.

Requirements

YOLOv5 requires Python>=3.8.0 with all dependencies correctly installed. To ensure your environment is up to date, you can start by cloning the YOLOv5 repository, navigating to it, and installing required packages as follows:

git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install

Environments

YOLOv5 models can be executed in various verified environments, including free GPU notebooks, cloud platforms, and Docker containers. These environments include all necessary prerequisites like Python, CUDA, CUDNN, and PyTorch preinstalled.

Status

Our continuous integration (CI) tests verify the correct operation of core YOLOv5 components such as training, validation, inference, export, and benchmarking on multiple platforms daily. If an issue is related to one of these workflows, rest assured our engineers will investigate thoroughly.

Thank you for your patience while we review your query further! 🚀

@pderrenger
Copy link
Member

@Throws100 thank you for your query, Seb. For YOLOv5 ONNX post-processing, you’ll need to handle the post-processing manually, as ONNX outputs raw model predictions. This typically includes applying non-maximum suppression (NMS), decoding bounding box coordinates, and reshaping logits. Libraries like ONNX Runtime or OpenCV’s DNN module might help.

Refer to the following for a detailed example:
YOLOv5 ONNX Export Documentation.

If you’re still encountering issues, you might want to explore discussions or examples from community repositories like Hexmagic/ONNX-yolov5. Let us know if further clarification is needed!

@Throws100
Copy link
Author

Thanks I managed to get my custom onnx model to work I have used this: https://github.com/robinZhao/object-detect-java
Thanks for your help:)

@pderrenger
Copy link
Member

@Throws100 you're welcome! Glad to hear you got your ONNX model working. The credit goes to the YOLO community and resources like the one you mentioned for providing such valuable tools. Happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exports Model exports (ONNX, TensorRT, TFLite, etc.) question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants