ultralytics / yolov5

YOLOv5 ๐Ÿš€ in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
51.18k stars 16.43k forks source link

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

Open Throws100 opened 3 days ago

Throws100 commented 3 days ago

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

UltralyticsAssistant commented 3 days ago

๐Ÿ‘‹ 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 commented 2 days ago

@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!