Skip to content

New way for register nms in onnx for tensorrt onnxruntime openvino#8101

Closed
triple-mu wants to merge 326 commits intoultralytics:masterfrom
triple-mu:onnxNMS
Closed

New way for register nms in onnx for tensorrt onnxruntime openvino#8101
triple-mu wants to merge 326 commits intoultralytics:masterfrom
triple-mu:onnxNMS

Conversation

@triple-mu
Copy link
Copy Markdown
Contributor

@triple-mu triple-mu commented Jun 4, 2022

The last pr provides a basic solution for exporting onnx and modifying it.
This pr improves the last pr so that registered nms is completely dependent on pytorch. Simple yet effective!

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

WARNING ⚠️ this PR is very large, summary may not cover all changes.

🌟 Summary

Detect and classify objects in images, videos, directories, and streams with YOLOv5.

📊 Key Changes

  • Added segmentation and classification capabilities.
  • Enhanced sources handling for detection (screen capture, list of images/streams).
  • Improved download scripts for ease of use and added new datasets.
  • Streamlined image and video inference with new options and better resizing.
  • Provided various model format support for both detection and classification.

🎯 Purpose & Impact

  • Provides users with flexible, high-accuracy object detection and classification across diverse media sources.
  • These upgrades expand the use cases of YOLOv5 and enable more complex computer vision tasks.
  • Improved download scripts and additional models formats lower barriers for adoption and deployment.

@glenn-jocher
Copy link
Copy Markdown
Member

@triple-mu thanks for the PR! The easiest argument structure is to simply use an --nms arg that would be handled accordingly for formats that are nms capable.

@visualcortex-team
Copy link
Copy Markdown

This looks good @triple-mu and the process looks correct (agree with @glenn-jocher comment above).

We have found that the EfficientNMS plugin does not always work very predictably as FP16 support was only merged in recently and so does not work correctly in things like the NVIDIA DeepStream Docker images (on older TensorRT versions). It would be better to use the TensorRT BatchedNMS plugin which has been around longer and is more stable. Given you are already converting cx,cy,w,h to tlbr format it should be easy to update 👍

@zhiqwang
Copy link
Copy Markdown
Contributor

zhiqwang commented Jun 15, 2022

FP16 support was only merged in recently

Hi @visualcortex-team , TensorRT supports EfficientNMS fp16 mode from 8.2.4+.

It would be better to use the TensorRT BatchedNMS plugin which has been around longer and is more stable.

But EfficientNMS plugin is much faster than BatchedNMS. BTW, TensorRT release 8.4 GA today.

@visualcortex-team
Copy link
Copy Markdown

Thanks @zhiqwang . I guess people will either:

  • need to know that the minimum supported version of TensorRT to use EfficientNMS is 8.2.4+ (as it will not throw errors it will just produce no results) - this could be added as a warning when exporting?

or

  • A flag is provided to choose which NMS to export with (BatchedNMS vs EfficientNMS)

@zhiqwang
Copy link
Copy Markdown
Contributor

Hi @visualcortex-team

need to know that the minimum supported version of TensorRT to use EfficientNMS is 8.2.4+ (as it will not throw errors it will just produce no results) - this could be added as a warning when exporting?

Agreed!

A flag is provided to choose which NMS to export with (BatchedNMS vs EfficientNMS)

Of course there is no problem supporting BatchedNMS plugin from a technical point of view. Seems that TensorRT made this BatchedNMS plugin according to the TensorFlow's interface, it is very slow, there is no need to support it for me.

@visualcortex-team
Copy link
Copy Markdown

For future readers:

  • the TensorRT release @zhiqwang spoke about updated the apt packages to version: tensorrt-dev/unknown 8.4.1.5-1+cuda11.6 amd64 which will work correctly with the EfficientNMS plugin.

  • to decode the bounding boxes if used with Nvidia Deepstream you will need a custom decoder implementation in nvdsinfer_custombboxparser.cpp using these mappings (unfortunately none of the others work):

object.left=p_bboxes[4*i];
object.top=p_bboxes[4*i+1];
object.width=(p_bboxes[4*i+2] - object.left);
object.height= (p_bboxes[4*i+3] - object.top);

@triple-mu
Copy link
Copy Markdown
Contributor Author

triple-mu commented Jul 22, 2022

Why I can not pass CI test?
@glenn-jocher

@triple-mu
Copy link
Copy Markdown
Contributor Author

triple-mu commented Jul 28, 2022

@glenn-jocher
I am very happy that yolov5 will support dynamic batch at #8526.
At the same time, I also applied dynamic batch to the registered NMS!
--nms default set tensorrt nms into onnx or tf.js nms into model
--nms 0 or any int set onnx nms into onnx nms values is the same as max-wh in nms
--dynamic default dynamic all axes into onnx or tf.js model not support onnx for tensorrt
--dynamic 0 dynamic batch into onnx also support onnx for tensorrt

glenn-jocher and others added 18 commits August 29, 2022 15:12
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
The low package version is causing conflicts among other dependencies, commenting it causes no ill effects in CI so this should be fine.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
If < 1 or > 1024 set output to default batch size 16.

May partially address ultralytics#9156

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Delete rebase.yml

No longer required with new built-in GitHub PR merge master feature

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update CONTRIBUTING.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update greetings.yml

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update CONTRIBUTING.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* cleanup

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Solution by @Laughing-q  to resolve duplicate segment verification bug in ultralytics#9052 (comment)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
…tralytics#9213)

* New LetterBox transform

YOLOv5 LetterBox class for image preprocessing, i.e. T.Compose([T.ToTensor(), LetterBox(size)])

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update augmentations.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update augmentations.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update augmentations.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup

* cleanup

* cleanup

* cleanup

* cleanup

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* Add ClassificationModel TF export assert

Export to TF not yet supported, warning alerts users.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
remove usage of pathlib.Path.unlink(missing_ok=...)

Co-authored-by: Yannick Merkli <ymerkli@latticeflow.ai>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Add `url_getsize()` function

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update downloads.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update

* update

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Optional manual rotation code per iPhone rotation issue in ultralytics#8493

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Move cudnn.benchmarks(True) to LoadStreams

* Update dataloaders.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Move cudnn.benchmarks(True) to LoadStreams

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
thepycoder and others added 27 commits December 5, 2022 12:12
)

* Added basic flag to enable reusing last task clearml

* Added option to provide task ID to override

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Use exist_ok argument instead

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Add catch for misspelled task

Signed-off-by: Leander van Eekelen <47320151+leandervaneekelen@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update val.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update val.py

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Leander van Eekelen <47320151+leandervaneekelen@users.noreply.github.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* [pre-commit.ci] pre-commit suggestions

updates:
- [github.com/pre-commit/pre-commit-hooks: v4.3.0 → v4.4.0](pre-commit/pre-commit-hooks@v4.3.0...v4.4.0)
- [github.com/asottile/pyupgrade: v3.2.0 → v3.3.0](asottile/pyupgrade@v3.2.0...v3.3.0)
- [github.com/PyCQA/flake8: 5.0.4 → 6.0.0](PyCQA/flake8@5.0.4...6.0.0)

* Fix flake8 ignore syntax

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* spacing

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
…ltralytics#10426)

* Update README.md

Info for Ep 2 of Ultralytics Live Sessions

Signed-off-by: Talia Bender <85292283+taliabender@users.noreply.github.com>

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update image link

Make sure we update the href field in the image so when users click the image they go directly to the YouTube live page.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Talia Bender <85292283+taliabender@users.noreply.github.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Add README App section

@AyushExel @pderrenger this should increase our app visibility per ultralytics#10431

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Create translate-readme.yml

@AyushExel @pderrenger @Laughing-q adding README translation action since we are unable to manually maintain our Chinese-translated README

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Double hyperlinks

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Delete README_cn.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Create README.zh-CN.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update .pre-commit-config.yaml

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Modify comment for OpenCV File I/O Functions

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
…#10460)

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Beautify Chinese Documents

* Beautify Chinese Documents

* Beautify Chinese Documents

* Beautify Chinese Documents

* add blank

* Update translate-readme.yml

Disable auto-translation by changing on-push branch to 'translate_readme'. This prevents overwriting of manual fixes.

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update translate-readme.yml

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* fix live doc

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update README.zh-CN.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Update README.md

Signed-off-by: nerdyespresso <106761627+nerdyespresso@users.noreply.github.com>

* Update README.md

Signed-off-by: nerdyespresso <106761627+nerdyespresso@users.noreply.github.com>

* Update README.md

Signed-off-by: nerdyespresso <106761627+nerdyespresso@users.noreply.github.com>

* Update README.md

Signed-off-by: nerdyespresso <106761627+nerdyespresso@users.noreply.github.com>

* Update tutorial.ipynb

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update tutorial.ipynb

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update tutorial.ipynb

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

* Update README.md

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: nerdyespresso <106761627+nerdyespresso@users.noreply.github.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* Checks conf_thres and iou_thres at beign

Why checks conf_thres after operation with it?

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update general.py

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
…ation (ultralytics#10516)

* support extensive shape for functions related to bounding box localization

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* merge exp branch updates

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Setting `master_port` to 1 may cause `Permission denied` due to failure to bind the port. So it is better to set it to a port greater than 1024.

Signed-off-by: Wang Xin <xinwang614@gmail.com>

Signed-off-by: Wang Xin <xinwang614@gmail.com>
Co-authored-by: Ayush Chaurasia <ayush.chaurarsia@gmail.com>
* limit detections without explicit if condition

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* cleanup indexing code for limit detections

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
…ing several models with different seeds (ultralytics#10486)

* set seed with parameter

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* make seed to be a large number

* set seed with a parameter

* set a seed of dataloader with opt for more randomness

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
…lytics#10517)

* sort by confidence and remove excess boxes without explicit if

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>

* cleanup indexing boxes for remove excess boxes

it is related to ultralytics#10502.

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* add albumentation hyps

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Rename hyp.noAugmentation.yaml to hyp.no-augmentation.yaml

* Update hyp.no-augmentation.yaml

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
* fix bug "resize to 0"

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Use math.ceil() for resize to enforce min floor of 1 pixel

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@Laughing-q @AyushExel setting to 1 due to recent issues

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
New PR for "ultralytics#7736"

Remove not use

Format onnxruntime and tensorrt onnx outputs

fix

unified outputs
@triple-mu triple-mu reopened this Dec 27, 2022
@triple-mu triple-mu closed this Dec 27, 2022
@glenn-jocher
Copy link
Copy Markdown
Member

@triple-mu thanks for the input! We'll make sure to consider the dynamic batching and NMS options in our future development. Your feedback is greatly appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.