From 7d62d19bcdd841541090a7ad1e265d9dc46800e3 Mon Sep 17 00:00:00 2001 From: F0XZz <958828188@qq.com> Date: Wed, 27 Apr 2022 11:06:06 +0800 Subject: [PATCH 1/2] add the yolov5 gpu preprocess --- .clang-format | 0 .gitattributes | 0 .github/CODE_OF_CONDUCT.md | 0 .github/CONTRIBUTING.md | 0 .github/ISSUE_TEMPLATE/bug-report.yml | 0 .github/ISSUE_TEMPLATE/config.yml | 0 .github/ISSUE_TEMPLATE/documentation.yml | 0 .github/ISSUE_TEMPLATE/feature-request.yml | 0 .github/dependabot.yml | 0 .github/workflows/ci-test.yml | 0 .github/workflows/code-format.yml | 0 .github/workflows/codeql-analysis.yml | 0 .github/workflows/gh-pages.yml | 0 .github/workflows/pypi-release.yml | 0 .gitignore | 0 .pre-commit-config.yaml | 0 LICENSE | 0 README.md | 0 deployment/libtorch/CMakeLists.txt | 0 deployment/libtorch/README.md | 0 deployment/libtorch/cmdline.h | 0 deployment/libtorch/main.cpp | 0 deployment/ncnn/CMakeLists.txt | 0 deployment/ncnn/README.md | 0 deployment/ncnn/main.cpp | 0 deployment/ncnn/yolort-opt.param | 0 deployment/onnxruntime/CMakeLists.txt | 0 deployment/onnxruntime/README.md | 0 deployment/onnxruntime/cmdline.h | 0 deployment/onnxruntime/main.cpp | 0 deployment/tensorrt/CMakeLists.txt | 8 +- deployment/tensorrt/README.md | 22 +- deployment/tensorrt/cmdline.h | 0 deployment/tensorrt/main.cpp | 370 +++++++++++++++++- deployment/tensorrt/preprocess/CMakeLists.txt | 5 + deployment/tensorrt/preprocess/preprocess.cu | 116 ++++++ deployment/tensorrt/preprocess/preprocess.h | 16 + docs/Makefile | 0 docs/requirements.txt | 0 docs/source/_static/favicon.svg | 0 .../_static/mathjax/a11y/assistive-mml.js | 0 .../source/_static/mathjax/a11y/complexity.js | 0 docs/source/_static/mathjax/a11y/explorer.js | 0 .../_static/mathjax/a11y/semantic-enrich.js | 0 .../_static/mathjax/adaptors/liteDOM.js | 0 docs/source/_static/mathjax/core.js | 0 .../source/_static/mathjax/input/asciimath.js | 0 docs/source/_static/mathjax/input/mml.js | 0 .../_static/mathjax/input/mml/entities.js | 0 docs/source/_static/mathjax/input/tex-base.js | 0 docs/source/_static/mathjax/input/tex-full.js | 0 docs/source/_static/mathjax/input/tex.js | 0 .../mathjax/input/tex/extensions/action.js | 0 .../input/tex/extensions/all-packages.js | 0 .../mathjax/input/tex/extensions/ams.js | 0 .../mathjax/input/tex/extensions/amscd.js | 0 .../mathjax/input/tex/extensions/autoload.js | 0 .../mathjax/input/tex/extensions/bbox.js | 0 .../input/tex/extensions/boldsymbol.js | 0 .../mathjax/input/tex/extensions/braket.js | 0 .../input/tex/extensions/bussproofs.js | 0 .../mathjax/input/tex/extensions/cancel.js | 0 .../mathjax/input/tex/extensions/color.js | 0 .../mathjax/input/tex/extensions/colorv2.js | 0 .../input/tex/extensions/configmacros.js | 0 .../mathjax/input/tex/extensions/enclose.js | 0 .../mathjax/input/tex/extensions/extpfeil.js | 0 .../mathjax/input/tex/extensions/html.js | 0 .../mathjax/input/tex/extensions/mhchem.js | 0 .../input/tex/extensions/newcommand.js | 0 .../mathjax/input/tex/extensions/noerrors.js | 0 .../input/tex/extensions/noundefined.js | 0 .../mathjax/input/tex/extensions/physics.js | 0 .../mathjax/input/tex/extensions/require.js | 0 .../mathjax/input/tex/extensions/tagformat.js | 0 .../input/tex/extensions/textmacros.js | 0 .../mathjax/input/tex/extensions/unicode.js | 0 .../mathjax/input/tex/extensions/verb.js | 0 docs/source/_static/mathjax/latest.js | 0 docs/source/_static/mathjax/loader.js | 0 docs/source/_static/mathjax/mml-chtml.js | 0 docs/source/_static/mathjax/mml-svg.js | 0 docs/source/_static/mathjax/node-main.js | 0 docs/source/_static/mathjax/output/chtml.js | 0 .../_static/mathjax/output/chtml/fonts/tex.js | 0 .../fonts/woff-v2/MathJax_AMS-Regular.woff | Bin .../woff-v2/MathJax_Calligraphic-Bold.woff | Bin .../woff-v2/MathJax_Calligraphic-Regular.woff | Bin .../fonts/woff-v2/MathJax_Fraktur-Bold.woff | Bin .../woff-v2/MathJax_Fraktur-Regular.woff | Bin .../fonts/woff-v2/MathJax_Main-Bold.woff | Bin .../fonts/woff-v2/MathJax_Main-Italic.woff | Bin .../fonts/woff-v2/MathJax_Main-Regular.woff | Bin .../woff-v2/MathJax_Math-BoldItalic.woff | Bin .../fonts/woff-v2/MathJax_Math-Italic.woff | Bin .../fonts/woff-v2/MathJax_Math-Regular.woff | Bin .../fonts/woff-v2/MathJax_SansSerif-Bold.woff | Bin .../woff-v2/MathJax_SansSerif-Italic.woff | Bin .../woff-v2/MathJax_SansSerif-Regular.woff | Bin .../fonts/woff-v2/MathJax_Script-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size1-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size2-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size3-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size4-Regular.woff | Bin .../woff-v2/MathJax_Typewriter-Regular.woff | Bin .../fonts/woff-v2/MathJax_Vector-Bold.woff | Bin .../fonts/woff-v2/MathJax_Vector-Regular.woff | Bin .../chtml/fonts/woff-v2/MathJax_Zero.woff | Bin docs/source/_static/mathjax/output/svg.js | 0 .../_static/mathjax/output/svg/fonts/tex.js | 0 .../source/_static/mathjax/sre/mathmaps/de.js | 0 .../source/_static/mathjax/sre/mathmaps/en.js | 0 .../source/_static/mathjax/sre/mathmaps/es.js | 0 .../source/_static/mathjax/sre/mathmaps/fr.js | 0 .../mathjax/sre/mathmaps/mathmaps_ie.js | 0 .../_static/mathjax/sre/mathmaps/nemeth.js | 0 docs/source/_static/mathjax/sre/sre-node.js | 0 .../source/_static/mathjax/sre/sre_browser.js | 0 docs/source/_static/mathjax/startup.js | 0 docs/source/_static/mathjax/tex-chtml-full.js | 0 docs/source/_static/mathjax/tex-chtml.js | 0 docs/source/_static/mathjax/tex-mml-chtml.js | 0 docs/source/_static/mathjax/tex-mml-svg.js | 0 docs/source/_static/mathjax/tex-svg-full.js | 0 docs/source/_static/mathjax/tex-svg.js | 0 docs/source/_static/mathjax/ui/menu.js | 0 docs/source/_static/mathjax/ui/safe.js | 0 docs/source/_static/yolort_logo.png | Bin docs/source/_static/yolort_logo_icon.png | Bin docs/source/_templates/searchbox.html | 0 docs/source/conf.py | 0 docs/source/index.rst | 0 docs/source/installation.rst | 0 docs/source/models.rst | 0 docs/source/notebooks/.gitignore | 0 docs/source/what_is_yolort.rst | 0 docs/source/yolov5.rst | 0 hubconf.py | 0 notebooks/.gitignore | 0 ...nchor-label-assignment-visualization.ipynb | 0 notebooks/assets/coco.names | 0 notebooks/assets/yolov5_graph_visualize.png | Bin notebooks/assets/yolov5_graph_visualize.svg | 0 notebooks/assets/zidane.jpg | Bin .../comparison-between-yolort-vs-yolov5.ipynb | 0 .../export-onnx-inference-onnxruntime.ipynb | 0 notebooks/export-relay-inference-tvm.ipynb | 0 ...how-to-align-with-ultralytics-yolov5.ipynb | 0 .../inference-pytorch-export-libtorch.ipynb | 0 notebooks/model-graph-visualization.ipynb | 0 ...onnx-graphsurgeon-inference-tensorrt.ipynb | 0 pyproject.toml | 0 requirements.txt | 0 setup.cfg | 0 setup.py | 0 test/__init__.py | 0 test/assets/bus.jpg | Bin test/assets/zidane.jpg | Bin test/test_data_pipeline.py | 0 test/test_models.py | 0 test/test_models_anchor_utils.py | 0 test/test_models_common.py | 0 test/test_models_transform.py | 0 test/test_models_yolov5.py | 0 test/test_relay.py | 0 test/test_runtime_ort.py | 0 test/test_trainer.py | 0 test/test_utils.py | 0 test/test_v5.py | 0 test/tracing/CMakeLists.txt | 0 test/tracing/test_tracing.cpp | 0 test/tracing/trace_model.py | 0 tools/convert_yolov5_to_yolort.py | 0 tools/eval_metric.py | 0 tools/export_model.py | 0 tools/run_clang_format.py | 0 yolort/__init__.py | 0 yolort/data/__init__.py | 0 yolort/data/_helper.py | 0 yolort/data/builtin_meta.py | 0 yolort/data/coco.py | 0 yolort/data/coco_eval.py | 0 yolort/data/data_module.py | 0 yolort/data/distributed.py | 0 yolort/data/transforms.py | 0 yolort/data/voc.py | 0 yolort/models/__init__.py | 0 yolort/models/_checkpoint.py | 0 yolort/models/_utils.py | 0 yolort/models/anchor_utils.py | 0 yolort/models/backbone_utils.py | 0 yolort/models/box_head.py | 0 yolort/models/darknet.py | 0 yolort/models/darknetv4.py | 0 yolort/models/darknetv6.py | 0 yolort/models/path_aggregation_network.py | 0 yolort/models/transform.py | 0 yolort/models/transformer.py | 0 yolort/models/yolo.py | 0 yolort/models/yolo_lite.py | 0 yolort/models/yolov5.py | 0 yolort/relay/__init__.py | 0 yolort/relay/ir_visualizer.py | 0 yolort/relay/logits_decoder.py | 0 yolort/relay/trace_wrapper.py | 0 yolort/relay/trt_graphsurgeon.py | 0 yolort/relay/trt_inference.py | 0 yolort/runtime/__init__.py | 0 yolort/runtime/ort_helper.py | 0 yolort/runtime/trt_helper.py | 0 yolort/runtime/y_onnxruntime.py | 0 yolort/runtime/y_tensorrt.py | 0 yolort/trainer/__init__.py | 0 yolort/trainer/lightning_task.py | 0 yolort/utils/__init__.py | 0 yolort/utils/dependency.py | 0 yolort/utils/hooks.py | 0 yolort/utils/image_utils.py | 0 yolort/utils/logger.py | 0 yolort/utils/visualizer.py | 0 yolort/utils/yolo2coco.py | 0 yolort/v5/__init__.py | 0 yolort/v5/data/coco128.yaml | 0 yolort/v5/data/hyps/hyp.scratch.yaml | 0 yolort/v5/helper.py | 0 yolort/v5/models/__init__.py | 0 yolort/v5/models/common.py | 0 yolort/v5/models/experimental.py | 0 yolort/v5/models/hub/yolov5l6.yaml | 0 yolort/v5/models/hub/yolov5m6.yaml | 0 yolort/v5/models/hub/yolov5n6.yaml | 0 yolort/v5/models/hub/yolov5s6.yaml | 0 yolort/v5/models/yolo.py | 0 yolort/v5/models/yolov5l.yaml | 0 yolort/v5/models/yolov5m.yaml | 0 yolort/v5/models/yolov5n.yaml | 0 yolort/v5/models/yolov5s.yaml | 0 yolort/v5/utils/__init__.py | 0 yolort/v5/utils/activations.py | 0 yolort/v5/utils/augmentations.py | 0 yolort/v5/utils/autoanchor.py | 0 yolort/v5/utils/callbacks.py | 0 yolort/v5/utils/datasets.py | 0 yolort/v5/utils/downloads.py | 0 yolort/v5/utils/general.py | 0 yolort/v5/utils/loss.py | 0 yolort/v5/utils/metrics.py | 0 yolort/v5/utils/plots.py | 0 yolort/v5/utils/torch_utils.py | 0 249 files changed, 521 insertions(+), 16 deletions(-) mode change 100644 => 100755 .clang-format mode change 100644 => 100755 .gitattributes mode change 100644 => 100755 .github/CODE_OF_CONDUCT.md mode change 100644 => 100755 .github/CONTRIBUTING.md mode change 100644 => 100755 .github/ISSUE_TEMPLATE/bug-report.yml mode change 100644 => 100755 .github/ISSUE_TEMPLATE/config.yml mode change 100644 => 100755 .github/ISSUE_TEMPLATE/documentation.yml mode change 100644 => 100755 .github/ISSUE_TEMPLATE/feature-request.yml mode change 100644 => 100755 .github/dependabot.yml mode change 100644 => 100755 .github/workflows/ci-test.yml mode change 100644 => 100755 .github/workflows/code-format.yml mode change 100644 => 100755 .github/workflows/codeql-analysis.yml mode change 100644 => 100755 .github/workflows/gh-pages.yml mode change 100644 => 100755 .github/workflows/pypi-release.yml mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .pre-commit-config.yaml mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 deployment/libtorch/CMakeLists.txt mode change 100644 => 100755 deployment/libtorch/README.md mode change 100644 => 100755 deployment/libtorch/cmdline.h mode change 100644 => 100755 deployment/libtorch/main.cpp mode change 100644 => 100755 deployment/ncnn/CMakeLists.txt mode change 100644 => 100755 deployment/ncnn/README.md mode change 100644 => 100755 deployment/ncnn/main.cpp mode change 100644 => 100755 deployment/ncnn/yolort-opt.param mode change 100644 => 100755 deployment/onnxruntime/CMakeLists.txt mode change 100644 => 100755 deployment/onnxruntime/README.md mode change 100644 => 100755 deployment/onnxruntime/cmdline.h mode change 100644 => 100755 deployment/onnxruntime/main.cpp mode change 100644 => 100755 deployment/tensorrt/CMakeLists.txt mode change 100644 => 100755 deployment/tensorrt/README.md mode change 100644 => 100755 deployment/tensorrt/cmdline.h mode change 100644 => 100755 deployment/tensorrt/main.cpp create mode 100755 deployment/tensorrt/preprocess/CMakeLists.txt create mode 100755 deployment/tensorrt/preprocess/preprocess.cu create mode 100755 deployment/tensorrt/preprocess/preprocess.h mode change 100644 => 100755 docs/Makefile mode change 100644 => 100755 docs/requirements.txt mode change 100644 => 100755 docs/source/_static/favicon.svg mode change 100644 => 100755 docs/source/_static/mathjax/a11y/assistive-mml.js mode change 100644 => 100755 docs/source/_static/mathjax/a11y/complexity.js mode change 100644 => 100755 docs/source/_static/mathjax/a11y/explorer.js mode change 100644 => 100755 docs/source/_static/mathjax/a11y/semantic-enrich.js mode change 100644 => 100755 docs/source/_static/mathjax/adaptors/liteDOM.js mode change 100644 => 100755 docs/source/_static/mathjax/core.js mode change 100644 => 100755 docs/source/_static/mathjax/input/asciimath.js mode change 100644 => 100755 docs/source/_static/mathjax/input/mml.js mode change 100644 => 100755 docs/source/_static/mathjax/input/mml/entities.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex-base.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex-full.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/action.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/all-packages.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/ams.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/amscd.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/autoload.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/bbox.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/boldsymbol.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/braket.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/bussproofs.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/cancel.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/color.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/colorv2.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/configmacros.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/enclose.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/extpfeil.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/html.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/mhchem.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/newcommand.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/noerrors.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/noundefined.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/physics.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/require.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/tagformat.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/textmacros.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/unicode.js mode change 100644 => 100755 docs/source/_static/mathjax/input/tex/extensions/verb.js mode change 100644 => 100755 docs/source/_static/mathjax/latest.js mode change 100644 => 100755 docs/source/_static/mathjax/loader.js mode change 100644 => 100755 docs/source/_static/mathjax/mml-chtml.js mode change 100644 => 100755 docs/source/_static/mathjax/mml-svg.js mode change 100644 => 100755 docs/source/_static/mathjax/node-main.js mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml.js mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/tex.js mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff mode change 100644 => 100755 docs/source/_static/mathjax/output/svg.js mode change 100644 => 100755 docs/source/_static/mathjax/output/svg/fonts/tex.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/de.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/en.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/es.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/fr.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/mathmaps_ie.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/mathmaps/nemeth.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/sre-node.js mode change 100644 => 100755 docs/source/_static/mathjax/sre/sre_browser.js mode change 100644 => 100755 docs/source/_static/mathjax/startup.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-chtml-full.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-chtml.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-mml-chtml.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-mml-svg.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-svg-full.js mode change 100644 => 100755 docs/source/_static/mathjax/tex-svg.js mode change 100644 => 100755 docs/source/_static/mathjax/ui/menu.js mode change 100644 => 100755 docs/source/_static/mathjax/ui/safe.js mode change 100644 => 100755 docs/source/_static/yolort_logo.png mode change 100644 => 100755 docs/source/_static/yolort_logo_icon.png mode change 100644 => 100755 docs/source/_templates/searchbox.html mode change 100644 => 100755 docs/source/conf.py mode change 100644 => 100755 docs/source/index.rst mode change 100644 => 100755 docs/source/installation.rst mode change 100644 => 100755 docs/source/models.rst mode change 100644 => 100755 docs/source/notebooks/.gitignore mode change 100644 => 100755 docs/source/what_is_yolort.rst mode change 100644 => 100755 docs/source/yolov5.rst mode change 100644 => 100755 hubconf.py mode change 100644 => 100755 notebooks/.gitignore mode change 100644 => 100755 notebooks/anchor-label-assignment-visualization.ipynb mode change 100644 => 100755 notebooks/assets/coco.names mode change 100644 => 100755 notebooks/assets/yolov5_graph_visualize.png mode change 100644 => 100755 notebooks/assets/yolov5_graph_visualize.svg mode change 100644 => 100755 notebooks/assets/zidane.jpg mode change 100644 => 100755 notebooks/comparison-between-yolort-vs-yolov5.ipynb mode change 100644 => 100755 notebooks/export-onnx-inference-onnxruntime.ipynb mode change 100644 => 100755 notebooks/export-relay-inference-tvm.ipynb mode change 100644 => 100755 notebooks/how-to-align-with-ultralytics-yolov5.ipynb mode change 100644 => 100755 notebooks/inference-pytorch-export-libtorch.ipynb mode change 100644 => 100755 notebooks/model-graph-visualization.ipynb mode change 100644 => 100755 notebooks/onnx-graphsurgeon-inference-tensorrt.ipynb mode change 100644 => 100755 pyproject.toml mode change 100644 => 100755 requirements.txt mode change 100644 => 100755 setup.cfg mode change 100644 => 100755 setup.py mode change 100644 => 100755 test/__init__.py mode change 100644 => 100755 test/assets/bus.jpg mode change 100644 => 100755 test/assets/zidane.jpg mode change 100644 => 100755 test/test_data_pipeline.py mode change 100644 => 100755 test/test_models.py mode change 100644 => 100755 test/test_models_anchor_utils.py mode change 100644 => 100755 test/test_models_common.py mode change 100644 => 100755 test/test_models_transform.py mode change 100644 => 100755 test/test_models_yolov5.py mode change 100644 => 100755 test/test_relay.py mode change 100644 => 100755 test/test_runtime_ort.py mode change 100644 => 100755 test/test_trainer.py mode change 100644 => 100755 test/test_utils.py mode change 100644 => 100755 test/test_v5.py mode change 100644 => 100755 test/tracing/CMakeLists.txt mode change 100644 => 100755 test/tracing/test_tracing.cpp mode change 100644 => 100755 test/tracing/trace_model.py mode change 100644 => 100755 tools/convert_yolov5_to_yolort.py mode change 100644 => 100755 tools/eval_metric.py mode change 100644 => 100755 tools/export_model.py mode change 100644 => 100755 tools/run_clang_format.py mode change 100644 => 100755 yolort/__init__.py mode change 100644 => 100755 yolort/data/__init__.py mode change 100644 => 100755 yolort/data/_helper.py mode change 100644 => 100755 yolort/data/builtin_meta.py mode change 100644 => 100755 yolort/data/coco.py mode change 100644 => 100755 yolort/data/coco_eval.py mode change 100644 => 100755 yolort/data/data_module.py mode change 100644 => 100755 yolort/data/distributed.py mode change 100644 => 100755 yolort/data/transforms.py mode change 100644 => 100755 yolort/data/voc.py mode change 100644 => 100755 yolort/models/__init__.py mode change 100644 => 100755 yolort/models/_checkpoint.py mode change 100644 => 100755 yolort/models/_utils.py mode change 100644 => 100755 yolort/models/anchor_utils.py mode change 100644 => 100755 yolort/models/backbone_utils.py mode change 100644 => 100755 yolort/models/box_head.py mode change 100644 => 100755 yolort/models/darknet.py mode change 100644 => 100755 yolort/models/darknetv4.py mode change 100644 => 100755 yolort/models/darknetv6.py mode change 100644 => 100755 yolort/models/path_aggregation_network.py mode change 100644 => 100755 yolort/models/transform.py mode change 100644 => 100755 yolort/models/transformer.py mode change 100644 => 100755 yolort/models/yolo.py mode change 100644 => 100755 yolort/models/yolo_lite.py mode change 100644 => 100755 yolort/models/yolov5.py mode change 100644 => 100755 yolort/relay/__init__.py mode change 100644 => 100755 yolort/relay/ir_visualizer.py mode change 100644 => 100755 yolort/relay/logits_decoder.py mode change 100644 => 100755 yolort/relay/trace_wrapper.py mode change 100644 => 100755 yolort/relay/trt_graphsurgeon.py mode change 100644 => 100755 yolort/relay/trt_inference.py mode change 100644 => 100755 yolort/runtime/__init__.py mode change 100644 => 100755 yolort/runtime/ort_helper.py mode change 100644 => 100755 yolort/runtime/trt_helper.py mode change 100644 => 100755 yolort/runtime/y_onnxruntime.py mode change 100644 => 100755 yolort/runtime/y_tensorrt.py mode change 100644 => 100755 yolort/trainer/__init__.py mode change 100644 => 100755 yolort/trainer/lightning_task.py mode change 100644 => 100755 yolort/utils/__init__.py mode change 100644 => 100755 yolort/utils/dependency.py mode change 100644 => 100755 yolort/utils/hooks.py mode change 100644 => 100755 yolort/utils/image_utils.py mode change 100644 => 100755 yolort/utils/logger.py mode change 100644 => 100755 yolort/utils/visualizer.py mode change 100644 => 100755 yolort/utils/yolo2coco.py mode change 100644 => 100755 yolort/v5/__init__.py mode change 100644 => 100755 yolort/v5/data/coco128.yaml mode change 100644 => 100755 yolort/v5/data/hyps/hyp.scratch.yaml mode change 100644 => 100755 yolort/v5/helper.py mode change 100644 => 100755 yolort/v5/models/__init__.py mode change 100644 => 100755 yolort/v5/models/common.py mode change 100644 => 100755 yolort/v5/models/experimental.py mode change 100644 => 100755 yolort/v5/models/hub/yolov5l6.yaml mode change 100644 => 100755 yolort/v5/models/hub/yolov5m6.yaml mode change 100644 => 100755 yolort/v5/models/hub/yolov5n6.yaml mode change 100644 => 100755 yolort/v5/models/hub/yolov5s6.yaml mode change 100644 => 100755 yolort/v5/models/yolo.py mode change 100644 => 100755 yolort/v5/models/yolov5l.yaml mode change 100644 => 100755 yolort/v5/models/yolov5m.yaml mode change 100644 => 100755 yolort/v5/models/yolov5n.yaml mode change 100644 => 100755 yolort/v5/models/yolov5s.yaml mode change 100644 => 100755 yolort/v5/utils/__init__.py mode change 100644 => 100755 yolort/v5/utils/activations.py mode change 100644 => 100755 yolort/v5/utils/augmentations.py mode change 100644 => 100755 yolort/v5/utils/autoanchor.py mode change 100644 => 100755 yolort/v5/utils/callbacks.py mode change 100644 => 100755 yolort/v5/utils/datasets.py mode change 100644 => 100755 yolort/v5/utils/downloads.py mode change 100644 => 100755 yolort/v5/utils/general.py mode change 100644 => 100755 yolort/v5/utils/loss.py mode change 100644 => 100755 yolort/v5/utils/metrics.py mode change 100644 => 100755 yolort/v5/utils/plots.py mode change 100644 => 100755 yolort/v5/utils/torch_utils.py diff --git a/.clang-format b/.clang-format old mode 100644 new mode 100755 diff --git a/.gitattributes b/.gitattributes old mode 100644 new mode 100755 diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md old mode 100644 new mode 100755 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml old mode 100644 new mode 100755 diff --git a/.github/dependabot.yml b/.github/dependabot.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/code-format.yml b/.github/workflows/code-format.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/deployment/libtorch/CMakeLists.txt b/deployment/libtorch/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/deployment/libtorch/README.md b/deployment/libtorch/README.md old mode 100644 new mode 100755 diff --git a/deployment/libtorch/cmdline.h b/deployment/libtorch/cmdline.h old mode 100644 new mode 100755 diff --git a/deployment/libtorch/main.cpp b/deployment/libtorch/main.cpp old mode 100644 new mode 100755 diff --git a/deployment/ncnn/CMakeLists.txt b/deployment/ncnn/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/deployment/ncnn/README.md b/deployment/ncnn/README.md old mode 100644 new mode 100755 diff --git a/deployment/ncnn/main.cpp b/deployment/ncnn/main.cpp old mode 100644 new mode 100755 diff --git a/deployment/ncnn/yolort-opt.param b/deployment/ncnn/yolort-opt.param old mode 100644 new mode 100755 diff --git a/deployment/onnxruntime/CMakeLists.txt b/deployment/onnxruntime/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/deployment/onnxruntime/README.md b/deployment/onnxruntime/README.md old mode 100644 new mode 100755 diff --git a/deployment/onnxruntime/cmdline.h b/deployment/onnxruntime/cmdline.h old mode 100644 new mode 100755 diff --git a/deployment/onnxruntime/main.cpp b/deployment/onnxruntime/main.cpp old mode 100644 new mode 100755 diff --git a/deployment/tensorrt/CMakeLists.txt b/deployment/tensorrt/CMakeLists.txt old mode 100644 new mode 100755 index 677ed614..d7e2bde9 --- a/deployment/tensorrt/CMakeLists.txt +++ b/deployment/tensorrt/CMakeLists.txt @@ -5,6 +5,12 @@ option(TENSORRT_DIR "Path to built TensorRT directory." STRING) message(STATUS "TENSORRT_DIR: ${TENSORRT_DIR}") find_package(OpenCV REQUIRED) +# build the library of GPU preprocess +add_subdirectory(preprocess) +include_directories(./preprocess) +# set the link library +message(${CMAKE_BINARY_DIR}/preprocess) +link_directories(${CMAKE_BINARY_DIR}/preprocess) if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") add_compile_options(-Wall) @@ -39,4 +45,4 @@ include_directories(${TENSORRT_DIR}/include) link_directories(${TENSORRT_DIR}/lib) add_executable(${PROJECT_NAME} main.cpp) -target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} nvinfer cudart nvonnxparser nvinfer_plugin) +target_link_libraries(${PROJECT_NAME} preprocess ${OpenCV_LIBS} nvinfer cudart nvonnxparser nvinfer_plugin) diff --git a/deployment/tensorrt/README.md b/deployment/tensorrt/README.md old mode 100644 new mode 100755 index 6e7cb07a..1a265726 --- a/deployment/tensorrt/README.md +++ b/deployment/tensorrt/README.md @@ -13,6 +13,8 @@ The TensorRT inference example of `yolort`. Here we will mainly discuss how to use the C++ interface, we recommend that you check out our [tutorial](https://zhiqwang.com/yolov5-rt-stack/notebooks/onnx-graphsurgeon-inference-tensorrt.html) first. +Gpu preprocess reference code :[tensorrtx](https://github.com/wang-xinyu/tensorrtx/tree/master/yolov5) + 1. Export your custom model to TensorRT format We provide a CLI tool to export the custom model checkpoint trained from yolov5 to TensorRT serialized engine. @@ -21,6 +23,12 @@ Here we will mainly discuss how to use the C++ interface, we recommend that you python tools/export_model.py --checkpoint_path {path/to/your/best.pt} --include engine ``` + if you wanna inference in the mulitple batch just like 8 use this command + + ```bash + python tools/export_model.py --checkpoint_path {path/to/your/best.pt} --include engine --batch_size 8 + ``` + Note: This CLI will output a pair of ONNX model and TensorRT serialized engine if you have the full TensorRT's Python environment, otherwise it will only output an ONNX models with suffixes ".trt.onnx". And then you can also use the [`trtexct`](https://docs.nvidia.com/deeplearning/tensorrt/developer-guide/index.html#trtexec) provided by TensorRT to export the serialized engine as below: ```bash @@ -62,6 +70,7 @@ Here we will mainly discuss how to use the C++ interface, we recommend that you - cudnn_cnn_infer64_8.dll, cudnn_ops_infer64_8.dll, cudnn64_8.dll, nvinfer.dll, nvinfer_plugin.dll, nvonnxparser.dll, zlibwapi.dll (On which CUDA and cudnn depend) - opencv_corexxx.dll opencv_imgcodecsxxx.dll opencv_imgprocxxx.dll (Subsequent dependencies by OpenCV or you can also use Static OpenCV Library) + - Caculate time use the **sys/time.h** you should don;t use in the windows ,otherwise you will complie failed . 1. Now, you can infer your own images. @@ -69,6 +78,17 @@ Here we will mainly discuss how to use the C++ interface, we recommend that you ./yolort_trt --image {path/to/your/image} --model_path {path/to/your/serialized/tensorrt/engine} --class_names {path/to/your/class/names} + --batch 1 ``` - + + if you wanna inference in 8 batch,you should use images_folder + + ```bash + ./yolort_trt --images_folder {path/to/your/imagefolder} + --model_path {path/to/your/serialized/tensorrt/engine} + --class_names {path/to/your/class/names} + --batch 8 + ``` + The above `yolort_trt` will determine if it needs to build the serialized engine file from ONNX based on the file suffix, and only do serialization when the argument `--model_path` given are with `.onnx` suffixes, all other suffixes are treated as the TensorRT serialized engine. + diff --git a/deployment/tensorrt/cmdline.h b/deployment/tensorrt/cmdline.h old mode 100644 new mode 100755 diff --git a/deployment/tensorrt/main.cpp b/deployment/tensorrt/main.cpp old mode 100644 new mode 100755 index bd12892c..835d6959 --- a/deployment/tensorrt/main.cpp +++ b/deployment/tensorrt/main.cpp @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include #include @@ -8,10 +10,38 @@ #include "NvInferPlugin.h" #include "NvOnnxParser.h" #include "cmdline.h" +#include "preprocess.h" + +#define MAX_IMAGE_INPUT_SIZE_THRESH 3000 * 3000 +#define BATCH_SIZE 8 using namespace nvonnxparser; using namespace nvinfer1; +double cpuSecond() { + struct timeval tp; + gettimeofday(&tp, NULL); + return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6); +} +static inline int read_files_in_dir(const char* p_dir_name, std::vector& file_names) { + DIR* p_dir = opendir(p_dir_name); + if (p_dir == nullptr) { + return -1; + } + + struct dirent* p_file = nullptr; + while ((p_file = readdir(p_dir)) != nullptr) { + if (strcmp(p_file->d_name, ".") != 0 && strcmp(p_file->d_name, "..") != 0) { + // std::string cur_file_name(p_dir_name); + // cur_file_name += "/"; + // cur_file_name += p_file->d_name; + std::string cur_file_name(p_file->d_name); + file_names.push_back(cur_file_name); + } + } + closedir(p_dir); + return 0; +} #define CHECK(status) \ do { \ auto ret = (status); \ @@ -284,6 +314,8 @@ class YOLOv5Detector { std::vector detect(cv::Mat& image); std::vector> detect(std::vector& images); + std::vector detect_preprocessgpu(cv::Mat& images); + std::vector> batch_inference_gpu(std::vector& imagess); private: MyLogger logger; @@ -308,6 +340,272 @@ YOLOv5Detector::~YOLOv5Detector() { CHECK(cudaStreamDestroy(stream)); } } +std::vector YOLOv5Detector::detect_preprocessgpu(cv::Mat& image) { + std::vector result; + // void* 用于指向int* float* + std::vector buffers(engine->getNbBindings()); + std::size_t batch_size = 1; + int num_detections_index = engine->getBindingIndex("num_detections"); + int detection_boxes_index = engine->getBindingIndex("detection_boxes"); + int detection_scores_index = engine->getBindingIndex("detection_scores"); + int detection_labels_index = engine->getBindingIndex("detection_classes"); + + int32_t num_detections = 0; + std::vector detection_boxes; + std::vector detection_scores; + std::vector detection_labels; + + Dims dim = engine->getBindingDimensions(0); + dim.d[0] = batch_size; + context->setBindingDimensions(0, dim); + + cv::Size shape = image.size(); + + /* prepare the host mem alloc */ + for (int32_t i = 0; i < engine->getNbBindings(); i++) { + { + std::cout << " Bind[" << i << "] {" + << "Name:" << engine->getBindingName(i) + << ", Datatype:" << static_cast(engine->getBindingDataType(i)) << ",Shape:("; + for (int j = 0; j < engine->getBindingDimensions(i).nbDims; j++) { + std::cout << engine->getBindingDimensions(i).d[j] << ","; + } + std::cout << ")" + << "}" << std::endl; + } + size_t buffer_size = 1; + for (int j = 0; j < engine->getBindingDimensions(i).nbDims; j++) { + buffer_size *= engine->getBindingDimensions(i).d[j]; + } + // void* buffers[i] op&--> void** + CHECK(cudaMalloc(&buffers[i], buffer_size * getElementSize(engine->getBindingDataType(i)))); + if (i == detection_boxes_index) { + detection_boxes.resize(buffer_size); + } else if (i == detection_scores_index) { + detection_scores.resize(buffer_size); + } else if (i == detection_labels_index) { + detection_labels.resize(buffer_size); + } + } + uint8_t* img_host = nullptr; + uint8_t* img_device = nullptr; + // yolov5 malloc the device but this yolort has malloc in the upper loop + + // CUDA_CHECK(cudaMalloc((void**)&buffers[0], 3 * net_img_height * net_img_width * + // sizeof(float))); CUDA_CHECK(cudaMalloc((void**)&buffers[1], OUTPUT_SIZE * sizeof(float))); this + // malloc the mem to shuffle the device and host + CHECK(cudaMallocHost((void**)&img_host, MAX_IMAGE_INPUT_SIZE_THRESH * 3)); + CHECK(cudaMalloc((void**)&img_device, MAX_IMAGE_INPUT_SIZE_THRESH * 3)); + size_t size_image = image.cols * image.rows * 3; + memcpy(img_host, image.data, size_image); + // binding indices inputshape (1,3,640,640) + int32_t input_h = engine->getBindingDimensions(0).d[2]; + int32_t input_w = engine->getBindingDimensions(0).d[3]; + // float *buffer_idx = (float*)buffers[0]; + // buffer_idx point float* buffers() + float scale = + 1 / (std::min((float)input_h / (float)shape.height, (float)input_w / (float)shape.width)); + CHECK(cudaMemcpyAsync(img_device, img_host, size_image, cudaMemcpyHostToDevice, stream)); + + preprocess_kernel_img( + img_device, image.cols, image.rows, (float*)buffers[0], input_h, input_w, stream); + context->enqueueV2(buffers.data(), stream, nullptr); + for (int32_t i = 1; i < engine->getNbBindings(); i++) { + if (i == detection_boxes_index) { + CHECK(cudaMemcpy( + detection_boxes.data(), + buffers[detection_boxes_index], + detection_boxes.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == detection_scores_index) { + CHECK(cudaMemcpy( + detection_scores.data(), + buffers[detection_scores_index], + detection_scores.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == detection_labels_index) { + CHECK(cudaMemcpy( + detection_labels.data(), + buffers[detection_labels_index], + detection_labels.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == num_detections_index) { + CHECK(cudaMemcpy( + &num_detections, + buffers[num_detections_index], + getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } + } + + for (int i = 0; i < engine->getNbBindings(); ++i) { + CHECK(cudaFree(buffers[i])); + } + /* Convert box fromat from LTRB to LTWH */ + int x_offset = (input_w * scale - image.cols) / 2; + int y_offset = (input_h * scale - image.rows) / 2; + for (int32_t i = 0; i < num_detections; i++) { + result.emplace_back(); + // reference address + Detection& detection = result.back(); + detection.box.x = detection_boxes[4 * i] * scale - x_offset; + detection.box.y = detection_boxes[4 * i + 1] * scale - y_offset; + detection.box.width = detection_boxes[4 * i + 2] * scale - x_offset - detection.box.x; + detection.box.height = detection_boxes[4 * i + 3] * scale - y_offset - detection.box.y; + detection.classId = detection_labels[i]; + detection.conf = detection_scores[i]; + } + + return result; +} +std::vector> YOLOv5Detector::batch_inference_gpu( + std::vector& images) { + int images_len = images.size(); + + // use for temp + cv::Mat image; + // the mem allocate + std::vector num_detections; + std::vector detection_boxes; + std::vector detection_scores; + std::vector detection_labels; + + std::vector> result(images_len); + std::vector ratio_list(images_len); + + std::vector buffers(engine->getNbBindings()); + std::size_t batch_size = BATCH_SIZE; + // getBindingDimensions [BCHW] get the input H W + int32_t input_h = engine->getBindingDimensions(0).d[2]; + int32_t input_w = engine->getBindingDimensions(0).d[3]; + // get the different scale + for (int i = 0; i < images_len; ++i) { + cv::Size shape = images[i].size(); + ratio_list[i] = + 1 / (std::min((float)input_h / (float)shape.height, (float)input_w / (float)shape.width)); + } + int inputIndex = engine->getBindingIndex("images"); + int num_detections_index = engine->getBindingIndex("num_detections"); + int detection_boxes_index = engine->getBindingIndex("detection_boxes"); + int detection_scores_index = engine->getBindingIndex("detection_scores"); + int detection_labels_index = engine->getBindingIndex("detection_classes"); + + for (int32_t i = 0; i < engine->getNbBindings(); i++) { + { + std::cout << " Bind[" << i << "] {" + << "Name:" << engine->getBindingName(i) + << ", Datatype:" << static_cast(engine->getBindingDataType(i)) << ",Shape:("; + for (int j = 0; j < engine->getBindingDimensions(i).nbDims; j++) { + std::cout << engine->getBindingDimensions(i).d[j] << ","; + } + std::cout << ")" + << "}" << std::endl; + } + int buffer_size = 1; + for (int j = 0; j < engine->getBindingDimensions(i).nbDims; j++) { + buffer_size *= engine->getBindingDimensions(i).d[j]; + } + // malloc all the data + CHECK(cudaMalloc(&buffers[i], buffer_size * getElementSize(engine->getBindingDataType(i)))); + if (i == detection_boxes_index) { + detection_boxes.resize(buffer_size); + } else if (i == detection_scores_index) { + detection_scores.resize(buffer_size); + } else if (i == detection_labels_index) { + detection_labels.resize(buffer_size); + } else if (i == num_detections_index) { + num_detections.resize(buffer_size); + } + } + + uint8_t* img_host = nullptr; + uint8_t* img_device = nullptr; + // init the store space except out of the mem boudary + CHECK(cudaMallocHost((void**)&img_host, MAX_IMAGE_INPUT_SIZE_THRESH * 3)); + CHECK(cudaMalloc((void**)&img_device, MAX_IMAGE_INPUT_SIZE_THRESH * 3)); + // std::cout<enqueueV2(buffers.data(), stream, nullptr); + // inference in batch + context->enqueue(8, (void**)buffers.data(), stream, nullptr); + + // buffers contain 8batch result can copy by the cudaMemcpy (DevicetoHost) + for (int32_t i = 1; i < engine->getNbBindings(); i++) { + if (i == detection_boxes_index) { + CHECK(cudaMemcpy( + detection_boxes.data(), + buffers[detection_boxes_index], + detection_boxes.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == detection_scores_index) { + CHECK(cudaMemcpy( + detection_scores.data(), + buffers[detection_scores_index], + detection_scores.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == detection_labels_index) { + CHECK(cudaMemcpy( + detection_labels.data(), + buffers[detection_labels_index], + detection_labels.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } else if (i == num_detections_index) { + CHECK(cudaMemcpy( + num_detections.data(), + buffers[num_detections_index], + num_detections.size() * getElementSize(engine->getBindingDataType(i)), + cudaMemcpyDeviceToHost)); + } + } + + // free the buffers + for (int i = 0; i < engine->getNbBindings(); ++i) { + CHECK(cudaFree(buffers[i])); + } + + // number j pic + for (int j = 0; j < images_len; ++j) { + image = images[j]; + int x_offset = (input_w * ratio_list[j] - image.cols) / 2; + int y_offset = (input_h * ratio_list[j] - image.rows) / 2; + + for (int32_t i = 0; i < num_detections[j]; ++i) { + result[j].emplace_back(); + Detection& detection = result[j].back(); + detection.box.x = detection_boxes[j * 100 * 4 + 4 * i] * ratio_list[j] - x_offset; + detection.box.y = detection_boxes[j * 100 * 4 + 4 * i + 1] * ratio_list[j] - y_offset; + detection.box.width = + detection_boxes[j * 100 * 4 + 4 * i + 2] * ratio_list[j] - x_offset - detection.box.x; + detection.box.height = + detection_boxes[j * 100 * 4 + 4 * i + 3] * ratio_list[j] - y_offset - detection.box.y; + detection.classId = detection_labels[j * 100 + i]; + detection.conf = detection_scores[j * 100 + i]; + } + } + + std::cout << result.size() << std::endl; + return result; +} std::vector YOLOv5Detector::detect(cv::Mat& image) { std::vector result; @@ -430,31 +728,75 @@ std::vector YOLOv5Detector::detect(cv::Mat& image) { int main(int argc, char* argv[]) { cmdline::parser cmd; + double iStart, iElaps; cmd.add("int8", '\0', "Enable INT8 inference."); cmd.add("fp16", '\0', "Enable FP16 inference."); cmd.add("model_path", 'm', "Path to onnx model.", true, "yolov5.onnx"); - cmd.add("image", 'i', "Image source to be detected.", true, "bus.jpg"); + cmd.add("image", 'i', "Image source to be detected.", false, "bus.jpg"); cmd.add("class_names", 'c', "Path of dataset labels.", true, "coco.names"); + cmd.add("images_folder", 'f', "Image file store folder", false, "images"); + cmd.add("batch", 'b', "batch or not", true, 1); cmd.parse_check(argc, argv); std::string imagePath = cmd.get("image"); std::string modelPath = cmd.get("model_path"); std::string classNamesPath = cmd.get("class_names"); std::vector classNames = loadNames(classNamesPath); + std::string images_folder = cmd.get("images_folder"); + int batch_infer = cmd.get("batch"); + if (batch_infer == 1) { + cv::Mat image = cv::imread(imagePath); + if (image.empty()) { + std::cerr << "Read image file fail: " << imagePath << std::endl; + return -1; + } + YOLOv5Detector yolo_detector(modelPath.c_str(), cmd.exist("int8"), cmd.exist("fp16")); + iStart = cpuSecond(); + std::vector result = yolo_detector.detect(image); + iElaps = cpuSecond() - iStart; + printf("Time elapsed cpu %f sec\n", iElaps); + std::cout << "Detected " << result.size() << " objects." << std::endl; - cv::Mat image = cv::imread(imagePath); - if (image.empty()) { - std::cerr << "Read image file fail: " << imagePath << std::endl; - return -1; - } - YOLOv5Detector yolo_detector(modelPath.c_str(), cmd.exist("int8"), cmd.exist("fp16")); - std::vector result = yolo_detector.detect(image); - - std::cout << "Detected " << result.size() << " objects." << std::endl; - - visualizeDetection(image, result, classNames); + visualizeDetection(image, result, classNames); - cv::imwrite("result.jpg", image); + cv::imwrite("result.jpg", image); - return 0; + return 0; + } else { + YOLOv5Detector yolo_detector_batch(modelPath.c_str(), cmd.exist("int8"), cmd.exist("fp16")); + std::vector imgs_buffer(BATCH_SIZE); + std::vector file_names; + if (read_files_in_dir(images_folder.c_str(), file_names) < 0) { + std::cerr << "read_files_in_dir failed." << std::endl; + return -1; + } + printf("read success"); + int fcount = 0; + if ((int)file_names.size() < BATCH_SIZE) { + for (int i = 0; i < BATCH_SIZE - (int)file_names.size(); ++i) { + file_names.push_back(file_names[0]); + } + } + for (int f = 0; f < BATCH_SIZE; f++) { + cv::Mat img = cv::imread(images_folder + "/" + file_names[f]); + if (img.empty()) { + printf("there was some error in read picture"); + std::cout << images_folder + "/" + file_names[f] << std::endl; + continue; + } + imgs_buffer[f] = img; + } + std::cout << imgs_buffer.size() << std::endl; + std::vector> batch_result; + + iStart = cpuSecond(); + batch_result = yolo_detector_batch.batch_inference_gpu(imgs_buffer); + iElaps = cpuSecond() - iStart; + printf("Time elapsed batch %d gpu %f sec\n", BATCH_SIZE,iElaps); + for (int i = 0; i < BATCH_SIZE; i++) { + visualizeDetection(imgs_buffer[i], batch_result[i], classNames); + std::string Name = "result" + std::to_string(i) + ".jpg"; + cv::imwrite(Name, imgs_buffer[i]); + } + } } diff --git a/deployment/tensorrt/preprocess/CMakeLists.txt b/deployment/tensorrt/preprocess/CMakeLists.txt new file mode 100755 index 00000000..2c6a479a --- /dev/null +++ b/deployment/tensorrt/preprocess/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.18.0) +find_package(CUDA) +find_package(OpenCV REQUIRED) +cuda_add_library(preprocess SHARED preprocess.cu) +target_link_libraries(preprocess cudart ${OpenCV_LIBS}) diff --git a/deployment/tensorrt/preprocess/preprocess.cu b/deployment/tensorrt/preprocess/preprocess.cu new file mode 100755 index 00000000..51359cc2 --- /dev/null +++ b/deployment/tensorrt/preprocess/preprocess.cu @@ -0,0 +1,116 @@ +#include "preprocess.h" +#include + +__global__ void warpaffine_kernel( + uint8_t* src, int src_line_size, int src_width, + int src_height, float* dst, int dst_width, + int dst_height, uint8_t const_value_st, + AffineMatrix d2s, int edge) { + int position = blockDim.x * blockIdx.x + threadIdx.x; + if (position >= edge) return; + + float m_x1 = d2s.value[0]; + float m_y1 = d2s.value[1]; + float m_z1 = d2s.value[2]; + float m_x2 = d2s.value[3]; + float m_y2 = d2s.value[4]; + float m_z2 = d2s.value[5]; + + int dx = position % dst_width; + int dy = position / dst_width; + float src_x = m_x1 * dx + m_y1 * dy + m_z1 + 0.5f; + float src_y = m_x2 * dx + m_y2 * dy + m_z2 + 0.5f; + float c0, c1, c2; + + if (src_x <= -1 || src_x >= src_width || src_y <= -1 || src_y >= src_height) { + // out of range + c0 = const_value_st; + c1 = const_value_st; + c2 = const_value_st; + } else { + int y_low = floorf(src_y); + int x_low = floorf(src_x); + int y_high = y_low + 1; + int x_high = x_low + 1; + + uint8_t const_value[] = {const_value_st, const_value_st, const_value_st}; + float ly = src_y - y_low; + float lx = src_x - x_low; + float hy = 1 - ly; + float hx = 1 - lx; + float w1 = hy * hx, w2 = hy * lx, w3 = ly * hx, w4 = ly * lx; + uint8_t* v1 = const_value; + uint8_t* v2 = const_value; + uint8_t* v3 = const_value; + uint8_t* v4 = const_value; + + if (y_low >= 0) { + if (x_low >= 0) + v1 = src + y_low * src_line_size + x_low * 3; + + if (x_high < src_width) + v2 = src + y_low * src_line_size + x_high * 3; + } + + if (y_high < src_height) { + if (x_low >= 0) + v3 = src + y_high * src_line_size + x_low * 3; + + if (x_high < src_width) + v4 = src + y_high * src_line_size + x_high * 3; + } + + c0 = w1 * v1[0] + w2 * v2[0] + w3 * v3[0] + w4 * v4[0]; + c1 = w1 * v1[1] + w2 * v2[1] + w3 * v3[1] + w4 * v4[1]; + c2 = w1 * v1[2] + w2 * v2[2] + w3 * v3[2] + w4 * v4[2]; + } + + //bgr to rgb + float t = c2; + c2 = c0; + c0 = t; + + //normalization + c0 = c0 / 255.0f; + c1 = c1 / 255.0f; + c2 = c2 / 255.0f; + + //rgbrgbrgb to rrrgggbbb + int area = dst_width * dst_height; + float* pdst_c0 = dst + dy * dst_width + dx; + float* pdst_c1 = pdst_c0 + area; + float* pdst_c2 = pdst_c1 + area; + *pdst_c0 = c0; + *pdst_c1 = c1; + *pdst_c2 = c2; +} + +void preprocess_kernel_img( + uint8_t* src, int src_width, int src_height, + float* dst, int dst_width, int dst_height, + cudaStream_t stream) { + AffineMatrix s2d,d2s; + float scale = std::min(dst_height / (float)src_height, dst_width / (float)src_width); + + s2d.value[0] = scale; + s2d.value[1] = 0; + s2d.value[2] = -scale * src_width * 0.5 + dst_width * 0.5; + s2d.value[3] = 0; + s2d.value[4] = scale; + s2d.value[5] = -scale * src_height * 0.5 + dst_height * 0.5; + + cv::Mat m2x3_s2d(2, 3, CV_32F, s2d.value); + cv::Mat m2x3_d2s(2, 3, CV_32F, d2s.value); + cv::invertAffineTransform(m2x3_s2d, m2x3_d2s); + + memcpy(d2s.value, m2x3_d2s.ptr(0), sizeof(d2s.value)); + + int jobs = dst_height * dst_width; + int threads = 256; + int blocks = ceil(jobs / (float)threads); + warpaffine_kernel<<>>( + src, src_width*3, src_width, + src_height, dst, dst_width, + dst_height, 128, d2s, jobs); + +} diff --git a/deployment/tensorrt/preprocess/preprocess.h b/deployment/tensorrt/preprocess/preprocess.h new file mode 100755 index 00000000..236d5f33 --- /dev/null +++ b/deployment/tensorrt/preprocess/preprocess.h @@ -0,0 +1,16 @@ +#ifndef __PREPROCESS_H +#define __PREPROCESS_H + +#include +#include + + +struct AffineMatrix{ + float value[6]; +}; + + +void preprocess_kernel_img(uint8_t* src, int src_width, int src_height, + float* dst, int dst_width, int dst_height, + cudaStream_t stream); +#endif // __PREPROCESS_H diff --git a/docs/Makefile b/docs/Makefile old mode 100644 new mode 100755 diff --git a/docs/requirements.txt b/docs/requirements.txt old mode 100644 new mode 100755 diff --git a/docs/source/_static/favicon.svg b/docs/source/_static/favicon.svg old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/a11y/assistive-mml.js b/docs/source/_static/mathjax/a11y/assistive-mml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/a11y/complexity.js b/docs/source/_static/mathjax/a11y/complexity.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/a11y/explorer.js b/docs/source/_static/mathjax/a11y/explorer.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/a11y/semantic-enrich.js b/docs/source/_static/mathjax/a11y/semantic-enrich.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/adaptors/liteDOM.js b/docs/source/_static/mathjax/adaptors/liteDOM.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/core.js b/docs/source/_static/mathjax/core.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/asciimath.js b/docs/source/_static/mathjax/input/asciimath.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/mml.js b/docs/source/_static/mathjax/input/mml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/mml/entities.js b/docs/source/_static/mathjax/input/mml/entities.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex-base.js b/docs/source/_static/mathjax/input/tex-base.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex-full.js b/docs/source/_static/mathjax/input/tex-full.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex.js b/docs/source/_static/mathjax/input/tex.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/action.js b/docs/source/_static/mathjax/input/tex/extensions/action.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/all-packages.js b/docs/source/_static/mathjax/input/tex/extensions/all-packages.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/ams.js b/docs/source/_static/mathjax/input/tex/extensions/ams.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/amscd.js b/docs/source/_static/mathjax/input/tex/extensions/amscd.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/autoload.js b/docs/source/_static/mathjax/input/tex/extensions/autoload.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/bbox.js b/docs/source/_static/mathjax/input/tex/extensions/bbox.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/boldsymbol.js b/docs/source/_static/mathjax/input/tex/extensions/boldsymbol.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/braket.js b/docs/source/_static/mathjax/input/tex/extensions/braket.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/bussproofs.js b/docs/source/_static/mathjax/input/tex/extensions/bussproofs.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/cancel.js b/docs/source/_static/mathjax/input/tex/extensions/cancel.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/color.js b/docs/source/_static/mathjax/input/tex/extensions/color.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/colorv2.js b/docs/source/_static/mathjax/input/tex/extensions/colorv2.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/configmacros.js b/docs/source/_static/mathjax/input/tex/extensions/configmacros.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/enclose.js b/docs/source/_static/mathjax/input/tex/extensions/enclose.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/extpfeil.js b/docs/source/_static/mathjax/input/tex/extensions/extpfeil.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/html.js b/docs/source/_static/mathjax/input/tex/extensions/html.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/mhchem.js b/docs/source/_static/mathjax/input/tex/extensions/mhchem.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/newcommand.js b/docs/source/_static/mathjax/input/tex/extensions/newcommand.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/noerrors.js b/docs/source/_static/mathjax/input/tex/extensions/noerrors.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/noundefined.js b/docs/source/_static/mathjax/input/tex/extensions/noundefined.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/physics.js b/docs/source/_static/mathjax/input/tex/extensions/physics.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/require.js b/docs/source/_static/mathjax/input/tex/extensions/require.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/tagformat.js b/docs/source/_static/mathjax/input/tex/extensions/tagformat.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/textmacros.js b/docs/source/_static/mathjax/input/tex/extensions/textmacros.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/unicode.js b/docs/source/_static/mathjax/input/tex/extensions/unicode.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/input/tex/extensions/verb.js b/docs/source/_static/mathjax/input/tex/extensions/verb.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/latest.js b/docs/source/_static/mathjax/latest.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/loader.js b/docs/source/_static/mathjax/loader.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/mml-chtml.js b/docs/source/_static/mathjax/mml-chtml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/mml-svg.js b/docs/source/_static/mathjax/mml-svg.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/node-main.js b/docs/source/_static/mathjax/node-main.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml.js b/docs/source/_static/mathjax/output/chtml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/tex.js b/docs/source/_static/mathjax/output/chtml/fonts/tex.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff b/docs/source/_static/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/svg.js b/docs/source/_static/mathjax/output/svg.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/output/svg/fonts/tex.js b/docs/source/_static/mathjax/output/svg/fonts/tex.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/de.js b/docs/source/_static/mathjax/sre/mathmaps/de.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/en.js b/docs/source/_static/mathjax/sre/mathmaps/en.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/es.js b/docs/source/_static/mathjax/sre/mathmaps/es.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/fr.js b/docs/source/_static/mathjax/sre/mathmaps/fr.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/mathmaps_ie.js b/docs/source/_static/mathjax/sre/mathmaps/mathmaps_ie.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/mathmaps/nemeth.js b/docs/source/_static/mathjax/sre/mathmaps/nemeth.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/sre-node.js b/docs/source/_static/mathjax/sre/sre-node.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/sre/sre_browser.js b/docs/source/_static/mathjax/sre/sre_browser.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/startup.js b/docs/source/_static/mathjax/startup.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-chtml-full.js b/docs/source/_static/mathjax/tex-chtml-full.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-chtml.js b/docs/source/_static/mathjax/tex-chtml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-mml-chtml.js b/docs/source/_static/mathjax/tex-mml-chtml.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-mml-svg.js b/docs/source/_static/mathjax/tex-mml-svg.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-svg-full.js b/docs/source/_static/mathjax/tex-svg-full.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/tex-svg.js b/docs/source/_static/mathjax/tex-svg.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/ui/menu.js b/docs/source/_static/mathjax/ui/menu.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/mathjax/ui/safe.js b/docs/source/_static/mathjax/ui/safe.js old mode 100644 new mode 100755 diff --git a/docs/source/_static/yolort_logo.png b/docs/source/_static/yolort_logo.png old mode 100644 new mode 100755 diff --git a/docs/source/_static/yolort_logo_icon.png b/docs/source/_static/yolort_logo_icon.png old mode 100644 new mode 100755 diff --git a/docs/source/_templates/searchbox.html b/docs/source/_templates/searchbox.html old mode 100644 new mode 100755 diff --git a/docs/source/conf.py b/docs/source/conf.py old mode 100644 new mode 100755 diff --git a/docs/source/index.rst b/docs/source/index.rst old mode 100644 new mode 100755 diff --git a/docs/source/installation.rst b/docs/source/installation.rst old mode 100644 new mode 100755 diff --git a/docs/source/models.rst b/docs/source/models.rst old mode 100644 new mode 100755 diff --git a/docs/source/notebooks/.gitignore b/docs/source/notebooks/.gitignore old mode 100644 new mode 100755 diff --git a/docs/source/what_is_yolort.rst b/docs/source/what_is_yolort.rst old mode 100644 new mode 100755 diff --git a/docs/source/yolov5.rst b/docs/source/yolov5.rst old mode 100644 new mode 100755 diff --git a/hubconf.py b/hubconf.py old mode 100644 new mode 100755 diff --git a/notebooks/.gitignore b/notebooks/.gitignore old mode 100644 new mode 100755 diff --git a/notebooks/anchor-label-assignment-visualization.ipynb b/notebooks/anchor-label-assignment-visualization.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/assets/coco.names b/notebooks/assets/coco.names old mode 100644 new mode 100755 diff --git a/notebooks/assets/yolov5_graph_visualize.png b/notebooks/assets/yolov5_graph_visualize.png old mode 100644 new mode 100755 diff --git a/notebooks/assets/yolov5_graph_visualize.svg b/notebooks/assets/yolov5_graph_visualize.svg old mode 100644 new mode 100755 diff --git a/notebooks/assets/zidane.jpg b/notebooks/assets/zidane.jpg old mode 100644 new mode 100755 diff --git a/notebooks/comparison-between-yolort-vs-yolov5.ipynb b/notebooks/comparison-between-yolort-vs-yolov5.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/export-onnx-inference-onnxruntime.ipynb b/notebooks/export-onnx-inference-onnxruntime.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/export-relay-inference-tvm.ipynb b/notebooks/export-relay-inference-tvm.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/how-to-align-with-ultralytics-yolov5.ipynb b/notebooks/how-to-align-with-ultralytics-yolov5.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/inference-pytorch-export-libtorch.ipynb b/notebooks/inference-pytorch-export-libtorch.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/model-graph-visualization.ipynb b/notebooks/model-graph-visualization.ipynb old mode 100644 new mode 100755 diff --git a/notebooks/onnx-graphsurgeon-inference-tensorrt.ipynb b/notebooks/onnx-graphsurgeon-inference-tensorrt.ipynb old mode 100644 new mode 100755 diff --git a/pyproject.toml b/pyproject.toml old mode 100644 new mode 100755 diff --git a/requirements.txt b/requirements.txt old mode 100644 new mode 100755 diff --git a/setup.cfg b/setup.cfg old mode 100644 new mode 100755 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 diff --git a/test/__init__.py b/test/__init__.py old mode 100644 new mode 100755 diff --git a/test/assets/bus.jpg b/test/assets/bus.jpg old mode 100644 new mode 100755 diff --git a/test/assets/zidane.jpg b/test/assets/zidane.jpg old mode 100644 new mode 100755 diff --git a/test/test_data_pipeline.py b/test/test_data_pipeline.py old mode 100644 new mode 100755 diff --git a/test/test_models.py b/test/test_models.py old mode 100644 new mode 100755 diff --git a/test/test_models_anchor_utils.py b/test/test_models_anchor_utils.py old mode 100644 new mode 100755 diff --git a/test/test_models_common.py b/test/test_models_common.py old mode 100644 new mode 100755 diff --git a/test/test_models_transform.py b/test/test_models_transform.py old mode 100644 new mode 100755 diff --git a/test/test_models_yolov5.py b/test/test_models_yolov5.py old mode 100644 new mode 100755 diff --git a/test/test_relay.py b/test/test_relay.py old mode 100644 new mode 100755 diff --git a/test/test_runtime_ort.py b/test/test_runtime_ort.py old mode 100644 new mode 100755 diff --git a/test/test_trainer.py b/test/test_trainer.py old mode 100644 new mode 100755 diff --git a/test/test_utils.py b/test/test_utils.py old mode 100644 new mode 100755 diff --git a/test/test_v5.py b/test/test_v5.py old mode 100644 new mode 100755 diff --git a/test/tracing/CMakeLists.txt b/test/tracing/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/test/tracing/test_tracing.cpp b/test/tracing/test_tracing.cpp old mode 100644 new mode 100755 diff --git a/test/tracing/trace_model.py b/test/tracing/trace_model.py old mode 100644 new mode 100755 diff --git a/tools/convert_yolov5_to_yolort.py b/tools/convert_yolov5_to_yolort.py old mode 100644 new mode 100755 diff --git a/tools/eval_metric.py b/tools/eval_metric.py old mode 100644 new mode 100755 diff --git a/tools/export_model.py b/tools/export_model.py old mode 100644 new mode 100755 diff --git a/tools/run_clang_format.py b/tools/run_clang_format.py old mode 100644 new mode 100755 diff --git a/yolort/__init__.py b/yolort/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/data/__init__.py b/yolort/data/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/data/_helper.py b/yolort/data/_helper.py old mode 100644 new mode 100755 diff --git a/yolort/data/builtin_meta.py b/yolort/data/builtin_meta.py old mode 100644 new mode 100755 diff --git a/yolort/data/coco.py b/yolort/data/coco.py old mode 100644 new mode 100755 diff --git a/yolort/data/coco_eval.py b/yolort/data/coco_eval.py old mode 100644 new mode 100755 diff --git a/yolort/data/data_module.py b/yolort/data/data_module.py old mode 100644 new mode 100755 diff --git a/yolort/data/distributed.py b/yolort/data/distributed.py old mode 100644 new mode 100755 diff --git a/yolort/data/transforms.py b/yolort/data/transforms.py old mode 100644 new mode 100755 diff --git a/yolort/data/voc.py b/yolort/data/voc.py old mode 100644 new mode 100755 diff --git a/yolort/models/__init__.py b/yolort/models/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/models/_checkpoint.py b/yolort/models/_checkpoint.py old mode 100644 new mode 100755 diff --git a/yolort/models/_utils.py b/yolort/models/_utils.py old mode 100644 new mode 100755 diff --git a/yolort/models/anchor_utils.py b/yolort/models/anchor_utils.py old mode 100644 new mode 100755 diff --git a/yolort/models/backbone_utils.py b/yolort/models/backbone_utils.py old mode 100644 new mode 100755 diff --git a/yolort/models/box_head.py b/yolort/models/box_head.py old mode 100644 new mode 100755 diff --git a/yolort/models/darknet.py b/yolort/models/darknet.py old mode 100644 new mode 100755 diff --git a/yolort/models/darknetv4.py b/yolort/models/darknetv4.py old mode 100644 new mode 100755 diff --git a/yolort/models/darknetv6.py b/yolort/models/darknetv6.py old mode 100644 new mode 100755 diff --git a/yolort/models/path_aggregation_network.py b/yolort/models/path_aggregation_network.py old mode 100644 new mode 100755 diff --git a/yolort/models/transform.py b/yolort/models/transform.py old mode 100644 new mode 100755 diff --git a/yolort/models/transformer.py b/yolort/models/transformer.py old mode 100644 new mode 100755 diff --git a/yolort/models/yolo.py b/yolort/models/yolo.py old mode 100644 new mode 100755 diff --git a/yolort/models/yolo_lite.py b/yolort/models/yolo_lite.py old mode 100644 new mode 100755 diff --git a/yolort/models/yolov5.py b/yolort/models/yolov5.py old mode 100644 new mode 100755 diff --git a/yolort/relay/__init__.py b/yolort/relay/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/relay/ir_visualizer.py b/yolort/relay/ir_visualizer.py old mode 100644 new mode 100755 diff --git a/yolort/relay/logits_decoder.py b/yolort/relay/logits_decoder.py old mode 100644 new mode 100755 diff --git a/yolort/relay/trace_wrapper.py b/yolort/relay/trace_wrapper.py old mode 100644 new mode 100755 diff --git a/yolort/relay/trt_graphsurgeon.py b/yolort/relay/trt_graphsurgeon.py old mode 100644 new mode 100755 diff --git a/yolort/relay/trt_inference.py b/yolort/relay/trt_inference.py old mode 100644 new mode 100755 diff --git a/yolort/runtime/__init__.py b/yolort/runtime/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/runtime/ort_helper.py b/yolort/runtime/ort_helper.py old mode 100644 new mode 100755 diff --git a/yolort/runtime/trt_helper.py b/yolort/runtime/trt_helper.py old mode 100644 new mode 100755 diff --git a/yolort/runtime/y_onnxruntime.py b/yolort/runtime/y_onnxruntime.py old mode 100644 new mode 100755 diff --git a/yolort/runtime/y_tensorrt.py b/yolort/runtime/y_tensorrt.py old mode 100644 new mode 100755 diff --git a/yolort/trainer/__init__.py b/yolort/trainer/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/trainer/lightning_task.py b/yolort/trainer/lightning_task.py old mode 100644 new mode 100755 diff --git a/yolort/utils/__init__.py b/yolort/utils/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/utils/dependency.py b/yolort/utils/dependency.py old mode 100644 new mode 100755 diff --git a/yolort/utils/hooks.py b/yolort/utils/hooks.py old mode 100644 new mode 100755 diff --git a/yolort/utils/image_utils.py b/yolort/utils/image_utils.py old mode 100644 new mode 100755 diff --git a/yolort/utils/logger.py b/yolort/utils/logger.py old mode 100644 new mode 100755 diff --git a/yolort/utils/visualizer.py b/yolort/utils/visualizer.py old mode 100644 new mode 100755 diff --git a/yolort/utils/yolo2coco.py b/yolort/utils/yolo2coco.py old mode 100644 new mode 100755 diff --git a/yolort/v5/__init__.py b/yolort/v5/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/v5/data/coco128.yaml b/yolort/v5/data/coco128.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/data/hyps/hyp.scratch.yaml b/yolort/v5/data/hyps/hyp.scratch.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/helper.py b/yolort/v5/helper.py old mode 100644 new mode 100755 diff --git a/yolort/v5/models/__init__.py b/yolort/v5/models/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/v5/models/common.py b/yolort/v5/models/common.py old mode 100644 new mode 100755 diff --git a/yolort/v5/models/experimental.py b/yolort/v5/models/experimental.py old mode 100644 new mode 100755 diff --git a/yolort/v5/models/hub/yolov5l6.yaml b/yolort/v5/models/hub/yolov5l6.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/hub/yolov5m6.yaml b/yolort/v5/models/hub/yolov5m6.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/hub/yolov5n6.yaml b/yolort/v5/models/hub/yolov5n6.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/hub/yolov5s6.yaml b/yolort/v5/models/hub/yolov5s6.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/yolo.py b/yolort/v5/models/yolo.py old mode 100644 new mode 100755 diff --git a/yolort/v5/models/yolov5l.yaml b/yolort/v5/models/yolov5l.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/yolov5m.yaml b/yolort/v5/models/yolov5m.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/yolov5n.yaml b/yolort/v5/models/yolov5n.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/models/yolov5s.yaml b/yolort/v5/models/yolov5s.yaml old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/__init__.py b/yolort/v5/utils/__init__.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/activations.py b/yolort/v5/utils/activations.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/augmentations.py b/yolort/v5/utils/augmentations.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/autoanchor.py b/yolort/v5/utils/autoanchor.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/callbacks.py b/yolort/v5/utils/callbacks.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/datasets.py b/yolort/v5/utils/datasets.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/downloads.py b/yolort/v5/utils/downloads.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/general.py b/yolort/v5/utils/general.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/loss.py b/yolort/v5/utils/loss.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/metrics.py b/yolort/v5/utils/metrics.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/plots.py b/yolort/v5/utils/plots.py old mode 100644 new mode 100755 diff --git a/yolort/v5/utils/torch_utils.py b/yolort/v5/utils/torch_utils.py old mode 100644 new mode 100755 From c0ec7fdd73198ca4dda7549250eb30c43c705377 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 27 Apr 2022 03:09:36 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/CODE_OF_CONDUCT.md | 0 .github/CONTRIBUTING.md | 0 README.md | 0 deployment/libtorch/README.md | 0 deployment/ncnn/README.md | 0 deployment/onnxruntime/README.md | 0 deployment/tensorrt/README.md | 7 +++---- 7 files changed, 3 insertions(+), 4 deletions(-) mode change 100755 => 100644 .github/CODE_OF_CONDUCT.md mode change 100755 => 100644 .github/CONTRIBUTING.md mode change 100755 => 100644 README.md mode change 100755 => 100644 deployment/libtorch/README.md mode change 100755 => 100644 deployment/ncnn/README.md mode change 100755 => 100644 deployment/onnxruntime/README.md mode change 100755 => 100644 deployment/tensorrt/README.md diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md old mode 100755 new mode 100644 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 diff --git a/deployment/libtorch/README.md b/deployment/libtorch/README.md old mode 100755 new mode 100644 diff --git a/deployment/ncnn/README.md b/deployment/ncnn/README.md old mode 100755 new mode 100644 diff --git a/deployment/onnxruntime/README.md b/deployment/onnxruntime/README.md old mode 100755 new mode 100644 diff --git a/deployment/tensorrt/README.md b/deployment/tensorrt/README.md old mode 100755 new mode 100644 index 1a265726..8334bb9c --- a/deployment/tensorrt/README.md +++ b/deployment/tensorrt/README.md @@ -80,15 +80,14 @@ Gpu preprocess reference code :[tensorrtx](https://github.com/wang-xinyu/tensorr --class_names {path/to/your/class/names} --batch 1 ``` - + if you wanna inference in 8 batch,you should use images_folder - + ```bash ./yolort_trt --images_folder {path/to/your/imagefolder} --model_path {path/to/your/serialized/tensorrt/engine} --class_names {path/to/your/class/names} --batch 8 ``` - - The above `yolort_trt` will determine if it needs to build the serialized engine file from ONNX based on the file suffix, and only do serialization when the argument `--model_path` given are with `.onnx` suffixes, all other suffixes are treated as the TensorRT serialized engine. + The above `yolort_trt` will determine if it needs to build the serialized engine file from ONNX based on the file suffix, and only do serialization when the argument `--model_path` given are with `.onnx` suffixes, all other suffixes are treated as the TensorRT serialized engine.