From 4a24152b3b2d28aa8fbd5e1fe90efe246b4ec963 Mon Sep 17 00:00:00 2001 From: Camille Huang Date: Thu, 17 Oct 2024 10:17:34 -0700 Subject: [PATCH] Update to 1.2.0 Release This release is compatible with DeepStream SDK 7.1 Ubuntu 22.04 Python 3.10 DeepStream SDK 7.1 Features: - New build system using PyPA to support pip 24.2 - Pybind11 version update to v2.13.0 - New bindings: Object encoder API: NvDsObjEncOutParams, NvDsObjEncUsrArgs, nvds_obj_enc_create_context(), nvds_obj_enc_process(), nvds_obj_enc_finish(), nvds_obj_enc_destroy_context(). See integration tests, utils.cpp, and bindfunctions.cpp for reference. - New bindings: NvDsObjReid API. See integration tests and bindtrackermeta.cpp for reference. - New bindings: NvDsAnalyticsObjInfo.objStatus. See bindanalyticsmeta.cpp for reference. Notes: - Numpy 2.x is not currently supported - Segmentation apps are not currently supported in DeepStream 7.1. --- .gitmodules | 10 +- 3rdparty/gstreamer | 1 - 3rdparty/pybind11 | 1 - FAQ.md | 2 +- HOWTO.md | 2 +- README.md | 19 ++- apps/README | 8 +- apps/deepstream-custom-binding-test/README | 4 +- .../README | 2 +- .../ds_demux_pgie_config.txt | 19 +-- .../README | 4 +- .../dstest_imagedata_cupy_config.txt | 19 +-- .../README | 4 +- apps/deepstream-imagedata-multistream/README | 4 +- .../dstest_imagedata_config.txt | 19 +-- apps/deepstream-nvdsanalytics/README | 2 +- .../dsnvanalytics_pgie_config.txt | 18 +-- apps/deepstream-opticalflow/README | 4 +- apps/deepstream-preprocess-test/README | 2 +- .../config_preprocess.txt | 2 +- .../deepstream_preprocess_test.py | 2 +- .../dstest1_pgie_config.txt | 27 ++-- apps/deepstream-rtsp-in-rtsp-out/README | 2 +- .../dstest1_pgie_config.txt | 18 +-- apps/deepstream-segmask/README | 6 +- apps/deepstream-segmentation/README | 4 +- apps/deepstream-ssd-parser/README | 2 +- apps/deepstream-test1-rtsp-out/README | 2 +- .../dstest1_pgie_config.txt | 18 +-- apps/deepstream-test1-usbcam/README | 2 +- .../dstest1_pgie_config.txt | 18 +-- apps/deepstream-test1/README | 2 +- apps/deepstream-test1/dstest1_pgie_config.txt | 19 +-- apps/deepstream-test2/README | 2 +- apps/deepstream-test2/dstest2_pgie_config.txt | 16 +- .../deepstream-test2/dstest2_sgie1_config.txt | 11 +- .../deepstream-test2/dstest2_sgie2_config.txt | 13 +- apps/deepstream-test3/README | 2 +- apps/deepstream-test3/deepstream_test_3.py | 4 + apps/deepstream-test3/dstest3_pgie_config.txt | 20 +-- apps/deepstream-test4/README | 2 +- apps/deepstream-test4/dstest4_pgie_config.txt | 18 +-- apps/runtime_source_add_delete/README | 2 +- .../deepstream_rt_src_add_del.py | 10 +- .../dstest_pgie_config.txt | 16 +- .../dstest_sgie1_config.txt | 11 +- .../dstest_sgie2_config.txt | 13 +- bindings/BINDINGSGUIDE.md | 18 ++- bindings/CMakeLists.txt | 25 +-- bindings/{packaging/setup.py => MANIFEST.in} | 19 +-- bindings/README.md | 105 ++++++------ bindings/docstrings/analyticsmetadoc.h | 2 + bindings/docstrings/functionsdoc.h | 60 +++++-- bindings/docstrings/nvdsmetadoc.h | 2 + bindings/docstrings/trackermetadoc.h | 16 +- bindings/docstrings/utilsdoc.h | 61 +++++++ bindings/include/bind/bindtrackermeta.hpp | 1 + bindings/include/utils.hpp | 3 + bindings/pyproject.toml | 35 ++++ .../ubuntu-cross-aarch64.Dockerfile | 3 +- bindings/setup.py | 85 ++++++++++ bindings/src/bindanalyticsmeta.cpp | 1 + bindings/src/bindfunctions.cpp | 63 +++++++- bindings/src/bindnvdsmeta.cpp | 6 + bindings/src/bindtrackermeta.cpp | 21 ++- bindings/src/pyds.cpp | 5 +- bindings/src/utils.cpp | 56 +++++++ docs/PYTHON_API/Methods/methodsdoc.rst | 32 +++- docs/README.md | 4 +- docs/bindings_file_list.txt | 1 + docs/conf.py | 2 +- docs/index.rst | 1 + notebooks/configs/dslaunchpad_pgie_config.txt | 18 +-- .../configs/dslaunchpad_sgie1_config.txt | 11 +- .../configs/dslaunchpad_sgie2_config.txt | 13 +- notebooks/deepstream_launchpad.ipynb | 12 +- notebooks/deepstream_test_1.ipynb | 4 +- notebooks/deepstream_test_4.ipynb | 4 +- tests/integration/README.md | 24 +-- tests/integration/deepstream_demo.py | 4 +- tests/integration/ds_base_config.txt | 18 +-- tests/integration/ds_pgie_config.txt | 18 +-- tests/integration/ds_sgie1_config.txt | 11 +- tests/integration/ds_sgie2_config.txt | 13 +- tests/integration/test.py | 127 ++++++++++++++- tests/integration/tracker_config.yml | 151 ++++++++++++------ tests/testcommon/frame_iterator.py | 28 ++-- tests/testcommon/pipeline_fakesink.py | 11 ++ 88 files changed, 987 insertions(+), 515 deletions(-) delete mode 160000 3rdparty/gstreamer delete mode 160000 3rdparty/pybind11 rename bindings/{packaging/setup.py => MANIFEST.in} (63%) create mode 100644 bindings/docstrings/utilsdoc.h create mode 100644 bindings/pyproject.toml create mode 100644 bindings/setup.py diff --git a/.gitmodules b/.gitmodules index b9ce656..244cd0f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,10 @@ [submodule "3rdparty/pybind11"] - path = 3rdparty/pybind11 + path = bindings/3rdparty/pybind11 url = https://github.com/pybind/pybind11.git -[submodule "gstreamer"] - path = 3rdparty/gstreamer +[submodule "3rdparty/git-partial-submodule"] + path = bindings/3rdparty/git-partial-submodule + url = https://github.com/Reedbeta/git-partial-submodule.git +[submodule "3rdparty/gstreamer"] + path = bindings/3rdparty/gstreamer url = https://github.com/GStreamer/gstreamer.git + sparse-checkout = subprojects/gst-python/ diff --git a/3rdparty/gstreamer b/3rdparty/gstreamer deleted file mode 160000 index ccf22e3..0000000 --- a/3rdparty/gstreamer +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ccf22e315cedf81e0075ab179ffb1b733da5206e diff --git a/3rdparty/pybind11 b/3rdparty/pybind11 deleted file mode 160000 index 3b1dbeb..0000000 --- a/3rdparty/pybind11 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3b1dbebabc801c9cf6f0953a4c20b904d444f879 diff --git a/FAQ.md b/FAQ.md index 70e295b..e1d5900 100644 --- a/FAQ.md +++ b/FAQ.md @@ -165,5 +165,5 @@ The pyds wheel installs the pyds.so library where all the pip packages are store Command to install the pyds wheel is: ```bash - $ pip3 install ./pyds-1.1.11-py3-none*.whl + $ pip3 install ./pyds-1.2.0*.whl ``` \ No newline at end of file diff --git a/HOWTO.md b/HOWTO.md index fac9902..3a15e67 100644 --- a/HOWTO.md +++ b/HOWTO.md @@ -16,7 +16,7 @@ This guide provides resources for DeepStream application development in Python. ## Prerequisites * Ubuntu 22.04 -* [DeepStream SDK 7.0](https://developer.nvidia.com/deepstream-download) or later +* [DeepStream SDK 7.1](https://developer.nvidia.com/deepstream-download) or later * Python 3.10 * [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.20.3 diff --git a/README.md b/README.md index 01bf331..4896b7d 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,23 @@ This repository contains Python bindings and sample applications for the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk). -SDK version supported: 7.0 +SDK version supported: 7.1 -This release only supports Ubuntu 22.04 for DeepStreamSDK 7.0 with Python 3.10 and [gst-python](3rdparty/gst-python/) 1.20.3! Ubuntu 20.04 for DeepStreamSDK 6.3 with Python 3.8 support is NOW DEPRECATED +This release only supports Ubuntu 22.04 for DeepStreamSDK 7.1 with Python 3.10 and [gst-python](3rdparty/gst-python/) 1.20.3! Ubuntu 20.04 for DeepStreamSDK 6.3 with Python 3.8 support is NOW DEPRECATED -The bindings sources along with build instructions are available under [bindings](bindings)! We include one [guide](bindings/BINDINGSGUIDE.md) for contributing to bindings and another [guide](bindings/CUSTOMUSERMETAGUIDE.md) for advanced use-cases such as writing bindings for custom data structures. +The bindings sources along with build instructions are available under [bindings](bindings)! PyDS 1.2.0 for DeepStream 7.1 uses an updated build system for PyPA to support pip 24.2, which deprecated setup.py command line. We include one [guide](bindings/BINDINGSGUIDE.md) for contributing to bindings and another [guide](bindings/CUSTOMUSERMETAGUIDE.md) for advanced use-cases such as writing bindings for custom data structures. Please report any issues or bugs on the [DeepStream SDK Forums](https://devtalk.nvidia.com/default/board/209). This enables the DeepStream community to find help at a central location. +NOTE: numpy 2.x is not supported. If you have numpy 2.x installed, please downgrade by running +``` +pip3 install --force-reinstall numpy==1.26.0 +``` + +NOTE: deepstream-segmask and deepstream-segmentation applications are not currently supported by DeepStream 7.1, due to removal of segmentation models. + +NOTE for DeepStream dockers: If you installed PyDS by running the user_deepstream_python_apps_install.sh script, be sure you also run the user_additional_install.sh script. + - [DeepStream Python Apps](#deepstream-python-apps) - [Setup](#setup) - [Python Bindings](#python-bindings) @@ -59,7 +68,7 @@ We currently provide the following sample applications: * [deepstream-test1-usbcam](apps/deepstream-test1-usbcam) -- deepstream-test1 pipeline with USB camera input * [deepstream-test1-rtsp-out](apps/deepstream-test1-rtsp-out) -- deepstream-test1 pipeline with RTSP output, demonstrates adding software encoder option to support Jetson Orin Nano * [deepstream-opticalflow](apps/deepstream-opticalflow) -- optical flow and visualization pipeline with flow vectors returned in NumPy array -* [deepstream-segmentation](apps/deepstream-segmentation) -- segmentation and visualization pipeline with segmentation mask returned in NumPy array +* [deepstream-segmentation](apps/deepstream-segmentation) -- **NOT CURRENTLY SUPPORTED IN DS 7.1** segmentation and visualization pipeline with segmentation mask returned in NumPy array * [deepstream-nvdsanalytics](apps/deepstream-nvdsanalytics) -- multistream pipeline with analytics plugin * [runtime_source_add_delete](apps/runtime_source_add_delete) -- add/delete source streams at runtime * [deepstream-imagedata-multistream-redaction](apps/deepstream-imagedata-multistream-redaction) -- multi-stream pipeline with face detection and redaction @@ -67,7 +76,7 @@ We currently provide the following sample applications: * [deepstream-preprocess-test](apps/deepstream-preprocess-test) -- multi-stream pipeline using nvdspreprocess plugin with custom ROIs * [deepstream-demux-multi-in-multi-out](apps/deepstream-demux-multi-in-multi-out) -- multi-stream pipeline using nvstreamdemux plugin to generated separate buffer outputs * [deepstream-imagedata-multistream-cupy](apps/deepstream-imagedata-multistream-cupy) -- access imagedata buffer from GPU in a multistream source as CuPy array - x86 only -* [deepstream-segmask](apps/deepstream-segmask) -- access and interpret segmentation mask information from NvOSD_MaskParams +* [deepstream-segmask](apps/deepstream-segmask) -- **NOT CURRENTLY SUPPORTED IN DS 7.1** access and interpret segmentation mask information from NvOSD_MaskParams * [deepstream-custom-binding-test](apps/deepstream-custom-binding-test) -- demonstrate usage of NvDsUserMeta for attaching custom data structure - see also the [Custom User Meta Guide](bindings/CUSTOMUSERMETAGUIDE.md) diff --git a/apps/README b/apps/README index 4d53e15..e214393 100644 --- a/apps/README +++ b/apps/README @@ -20,7 +20,7 @@ DeepStream SDK Python Bindings ================================================================================ Setup pre-requisites: - Ubuntu 22.04 -- NVIDIA DeepStream SDK 7.0 +- NVIDIA DeepStream SDK 7.1 - Python 3.10 - Gst-python @@ -36,7 +36,7 @@ Package Contents Installing Pre-requisites: -------------------------------------------------------------------------------- -DeepStream SDK 7.0 +DeepStream SDK 7.1 -------------------- Download and install from https://developer.nvidia.com/deepstream-download @@ -51,14 +51,14 @@ If missing, install with the following steps: $ sudo apt update $ sudo apt install python3-gi python3-dev python3-gst-1.0 -y -cuda-python +**NEW** cuda-python ----------- $ pip3 install cuda-python -------------------------------------------------------------------------------- Running the samples -------------------------------------------------------------------------------- -The apps are configured to work from inside the DeepStream SDK 7.0 installation. +The apps are configured to work from inside the DeepStream SDK 7.1 installation. Clone the deepstream_python_apps repo under /sources: $ git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps diff --git a/apps/deepstream-custom-binding-test/README b/apps/deepstream-custom-binding-test/README index 127903d..ea01650 100644 --- a/apps/deepstream-custom-binding-test/README +++ b/apps/deepstream-custom-binding-test/README @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-demux-multi-in-multi-out/README b/apps/deepstream-demux-multi-in-multi-out/README index 0574fca..601f10f 100644 --- a/apps/deepstream-demux-multi-in-multi-out/README +++ b/apps/deepstream-demux-multi-in-multi-out/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt b/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt index 9f5352e..a95a01f 100644 --- a/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt +++ b/apps/deepstream-demux-multi-in-multi-out/ds_demux_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,12 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 + +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +68,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-imagedata-multistream-cupy/README b/apps/deepstream-imagedata-multistream-cupy/README index 6902a96..d55d7be 100644 --- a/apps/deepstream-imagedata-multistream-cupy/README +++ b/apps/deepstream-imagedata-multistream-cupy/README @@ -16,10 +16,10 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python -- NumPy package +- NumPy package <2.0, >=1.22 (2.0 and above not supported) - OpenCV package - CuPy for Cuda 12.1 or later diff --git a/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt b/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt index 9f5352e..a95a01f 100644 --- a/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt +++ b/apps/deepstream-imagedata-multistream-cupy/dstest_imagedata_cupy_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,12 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 + +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +68,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-imagedata-multistream-redaction/README b/apps/deepstream-imagedata-multistream-redaction/README index 6d00dbf..b95ecbc 100755 --- a/apps/deepstream-imagedata-multistream-redaction/README +++ b/apps/deepstream-imagedata-multistream-redaction/README @@ -16,10 +16,10 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python -- NumPy package +- NumPy package <2.0, >=1.22 (2.0 and above not supported) - OpenCV package - GstRtspServer diff --git a/apps/deepstream-imagedata-multistream/README b/apps/deepstream-imagedata-multistream/README index 174e549..3db0989 100755 --- a/apps/deepstream-imagedata-multistream/README +++ b/apps/deepstream-imagedata-multistream/README @@ -16,10 +16,10 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python -- NumPy package +- NumPy package <2.0, >=1.22 (2.0 and above not supported) - OpenCV package To install required packages: diff --git a/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt b/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt index 9f5352e..a95a01f 100755 --- a/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt +++ b/apps/deepstream-imagedata-multistream/dstest_imagedata_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,12 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 + +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +68,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-nvdsanalytics/README b/apps/deepstream-nvdsanalytics/README index 1a53857..541d42c 100755 --- a/apps/deepstream-nvdsanalytics/README +++ b/apps/deepstream-nvdsanalytics/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt b/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt index 9f5352e..0dfc3c2 100644 --- a/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt +++ b/apps/deepstream-nvdsanalytics/dsnvanalytics_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-opticalflow/README b/apps/deepstream-opticalflow/README index 3877998..f38f401 100755 --- a/apps/deepstream-opticalflow/README +++ b/apps/deepstream-opticalflow/README @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2020-2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2020-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python - NumPy package diff --git a/apps/deepstream-preprocess-test/README b/apps/deepstream-preprocess-test/README index ace3d1b..cd66eec 100644 --- a/apps/deepstream-preprocess-test/README +++ b/apps/deepstream-preprocess-test/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python - GstRtspServer diff --git a/apps/deepstream-preprocess-test/config_preprocess.txt b/apps/deepstream-preprocess-test/config_preprocess.txt index 127f5ed..f0ec0cf 100644 --- a/apps/deepstream-preprocess-test/config_preprocess.txt +++ b/apps/deepstream-preprocess-test/config_preprocess.txt @@ -40,7 +40,7 @@ network-input-shape=8;3;544;960 network-color-format=0 # 0=FP32, 1=UINT8, 2=INT8, 3=UINT32, 4=INT32, 5=FP16 tensor-data-type=0 -tensor-name=input_1 +tensor-name=input_1:0 # 0=NVBUF_MEM_DEFAULT 1=NVBUF_MEM_CUDA_PINNED 2=NVBUF_MEM_CUDA_DEVICE 3=NVBUF_MEM_CUDA_UNIFIED scaling-pool-memory-type=0 # 0=NvBufSurfTransformCompute_Default 1=NvBufSurfTransformCompute_GPU 2=NvBufSurfTransformCompute_VIC diff --git a/apps/deepstream-preprocess-test/deepstream_preprocess_test.py b/apps/deepstream-preprocess-test/deepstream_preprocess_test.py index 6badd7d..e3c2be4 100644 --- a/apps/deepstream-preprocess-test/deepstream_preprocess_test.py +++ b/apps/deepstream-preprocess-test/deepstream_preprocess_test.py @@ -329,7 +329,7 @@ def main(args): streammux.set_property("width", 1920) streammux.set_property("height", 1080) - streammux.set_property("batch-size", 1) + streammux.set_property("batch-size", number_sources) streammux.set_property("batched-push-timeout", MUXER_BATCH_TIMEOUT_USEC) preprocess.set_property("config-file", "config_preprocess.txt") pgie.set_property("config-file-path", "dstest1_pgie_config.txt") diff --git a/apps/deepstream-preprocess-test/dstest1_pgie_config.txt b/apps/deepstream-preprocess-test/dstest1_pgie_config.txt index a0d18bd..fb0ab2a 100644 --- a/apps/deepstream-preprocess-test/dstest1_pgie_config.txt +++ b/apps/deepstream-preprocess-test/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, +# custom-lib-path # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -51,33 +51,28 @@ # # The values in the config file are overridden by values set through GObject # properties. +# +# NOTE : Below config parameters will not get used when preprocessing plugin is used +# to form tensor : +# net-scale-factor, model-color-format, mean-file, offsets [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=1 +batch-size=4 process-mode=1 model-color-format=0 -## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd -#scaling-filter=0 -#scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-rtsp-in-rtsp-out/README b/apps/deepstream-rtsp-in-rtsp-out/README index 8dfed98..f65572f 100755 --- a/apps/deepstream-rtsp-in-rtsp-out/README +++ b/apps/deepstream-rtsp-in-rtsp-out/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python - GstRtspServer diff --git a/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt b/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt index 9f5352e..0dfc3c2 100755 --- a/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt +++ b/apps/deepstream-rtsp-in-rtsp-out/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-segmask/README b/apps/deepstream-segmask/README index eca364b..40b023d 100644 --- a/apps/deepstream-segmask/README +++ b/apps/deepstream-segmask/README @@ -16,16 +16,18 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.0 **NOT CURRENTLY SUPPORTED BY 7.1** - Python 3.10 - Gst-python -- NumPy package +- NumPy package <2.0, >=1.22 (2.0 and above not supported) - OpenCV package To install required packages: $ sudo apt update $ sudo apt install python3-numpy python3-opencv -y +**NOTE**: this application is not currently supported by DeepStream 7.1, due to removal of segmentation models. + Download PeopleSegNet model: Please follow instructions from the README.md located at : /opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/README.md to download latest supported PeopleSegNet model diff --git a/apps/deepstream-segmentation/README b/apps/deepstream-segmentation/README index e2b68bc..dd4666a 100644 --- a/apps/deepstream-segmentation/README +++ b/apps/deepstream-segmentation/README @@ -16,10 +16,10 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.0 **NOT SUPPORTED BY 7.1** - Python 3.10 - Gst-python -- NumPy package +- NumPy package <2.0, >=1.22 (2.0 and above not supported) - OpenCV package To install required packages: diff --git a/apps/deepstream-ssd-parser/README b/apps/deepstream-ssd-parser/README index c26e4c4..27cc099 100644 --- a/apps/deepstream-ssd-parser/README +++ b/apps/deepstream-ssd-parser/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - NVIDIA Triton Inference Server - Python 3.10 - Gst-python diff --git a/apps/deepstream-test1-rtsp-out/README b/apps/deepstream-test1-rtsp-out/README index be2ef29..04cb82d 100644 --- a/apps/deepstream-test1-rtsp-out/README +++ b/apps/deepstream-test1-rtsp-out/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python - GstRtspServer diff --git a/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt b/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt index 9f5352e..0dfc3c2 100644 --- a/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt +++ b/apps/deepstream-test1-rtsp-out/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-test1-usbcam/README b/apps/deepstream-test1-usbcam/README index d708582..cbb8b87 100644 --- a/apps/deepstream-test1-usbcam/README +++ b/apps/deepstream-test1-usbcam/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt b/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt index 9f5352e..0dfc3c2 100755 --- a/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt +++ b/apps/deepstream-test1-usbcam/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-test1/README b/apps/deepstream-test1/README index 10c5a35..582fd85 100644 --- a/apps/deepstream-test1/README +++ b/apps/deepstream-test1/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-test1/dstest1_pgie_config.txt b/apps/deepstream-test1/dstest1_pgie_config.txt index a1d9f03..7ccbca6 100644 --- a/apps/deepstream-test1/dstest1_pgie_config.txt +++ b/apps/deepstream-test1/dstest1_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,29 +55,20 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 batch-size=1 -process-mode=1 -model-color-format=0 -## 0=FP32, 1=INT8, 2=FP16 mode network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-test2/README b/apps/deepstream-test2/README index abea0ad..610916b 100644 --- a/apps/deepstream-test2/README +++ b/apps/deepstream-test2/README @@ -16,7 +16,7 @@ ################################################################################ Prequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-test2/dstest2_pgie_config.txt b/apps/deepstream-test2/dstest2_pgie_config.txt index a1d9f03..0dfc3c2 100644 --- a/apps/deepstream-test2/dstest2_pgie_config.txt +++ b/apps/deepstream-test2/dstest2_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b1_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 batch-size=1 process-mode=1 model-color-format=0 @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-test2/dstest2_sgie1_config.txt b/apps/deepstream-test2/dstest2_sgie1_config.txt index 5ab0cd6..e8d722a 100644 --- a/apps/deepstream-test2/dstest2_sgie1_config.txt +++ b/apps/deepstream-test2/dstest2_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 -infer-dims=3;244;244 diff --git a/apps/deepstream-test2/dstest2_sgie2_config.txt b/apps/deepstream-test2/dstest2_sgie2_config.txt index 8b0313b..f29bc5d 100644 --- a/apps/deepstream-test2/dstest2_sgie2_config.txt +++ b/apps/deepstream-test2/dstest2_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 -#scaling-compute-hw=0 -infer-dims=3;244;244 +#scaling-compute-hw=0 \ No newline at end of file diff --git a/apps/deepstream-test3/README b/apps/deepstream-test3/README index 1dcc988..b982a59 100755 --- a/apps/deepstream-test3/README +++ b/apps/deepstream-test3/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - NVIDIA Triton Inference Server (optional) - Python 3.10 - Gst-python diff --git a/apps/deepstream-test3/deepstream_test_3.py b/apps/deepstream-test3/deepstream_test_3.py index 6625881..1d04ebc 100755 --- a/apps/deepstream-test3/deepstream_test_3.py +++ b/apps/deepstream-test3/deepstream_test_3.py @@ -356,6 +356,10 @@ def main(args, requested_pgie=None, config=None, disable_probe=False): tiler.set_property("columns",tiler_columns) tiler.set_property("width", TILED_OUTPUT_WIDTH) tiler.set_property("height", TILED_OUTPUT_HEIGHT) + if platform_info.is_integrated_gpu(): + tiler.set_property("compute-hw", 2) + else: + tiler.set_property("compute-hw", 1) sink.set_property("qos",0) print("Adding elements to Pipeline \n") diff --git a/apps/deepstream-test3/dstest3_pgie_config.txt b/apps/deepstream-test3/dstest3_pgie_config.txt index 9f5352e..98d8ed6 100755 --- a/apps/deepstream-test3/dstest3_pgie_config.txt +++ b/apps/deepstream-test3/dstest3_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +26,7 @@ # # Optional properties for detectors: # cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0) -# custom-lib-path, +# custom-lib-path # parse-bbox-func-name # # Mandatory properties for classifiers: @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 batch-size=30 process-mode=1 model-color-format=0 @@ -69,15 +67,9 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd -#scaling-filter=0 -#scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/deepstream-test4/README b/apps/deepstream-test4/README index 0c7fcaf..2782c3a 100755 --- a/apps/deepstream-test4/README +++ b/apps/deepstream-test4/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/deepstream-test4/dstest4_pgie_config.txt b/apps/deepstream-test4/dstest4_pgie_config.txt index a0d18bd..87fb2ae 100755 --- a/apps/deepstream-test4/dstest4_pgie_config.txt +++ b/apps/deepstream-test4/dstest4_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 batch-size=1 process-mode=1 model-color-format=0 @@ -68,16 +66,14 @@ model-color-format=0 network-mode=1 num-detected-classes=4 interval=0 +process-mode=1 +model-color-format=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/apps/runtime_source_add_delete/README b/apps/runtime_source_add_delete/README index 8e8fadc..282f1f4 100644 --- a/apps/runtime_source_add_delete/README +++ b/apps/runtime_source_add_delete/README @@ -16,7 +16,7 @@ ################################################################################ Prerequisites: -- DeepStreamSDK 7.0 +- DeepStreamSDK 7.1 - Python 3.10 - Gst-python diff --git a/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py b/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py index 5ef0441..cde259d 100644 --- a/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py +++ b/apps/runtime_source_add_delete/deepstream_rt_src_add_del.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -526,7 +526,13 @@ def main(args): # start play back and listed to events pipeline.set_state(Gst.State.PLAYING) - GLib.timeout_add_seconds(10, add_sources, g_source_bin_list) + print("Waiting for state change\n") + status, state, pending = pipeline.get_state(Gst.CLOCK_TIME_NONE) + print(f"Current state {state}, pending state {pending}, status {status}\n") + if (state == Gst.State.PLAYING) and (pending == Gst.State.VOID_PENDING): + GLib.timeout_add_seconds(10, add_sources, g_source_bin_list) + else: + print("Pipeline is not in playing state to add sources\n") try: loop.run() diff --git a/apps/runtime_source_add_delete/dstest_pgie_config.txt b/apps/runtime_source_add_delete/dstest_pgie_config.txt index a3c84ea..d022dd6 100644 --- a/apps/runtime_source_add_delete/dstest_pgie_config.txt +++ b/apps/runtime_source_add_delete/dstest_pgie_config.txt @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,17 +67,9 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd -#parse-bbox-func-name=NvDsInferParseCustomResnet -#custom-lib-path=/path/to/libnvdsparsebbox.so -#enable-dbscan=1 [class-attrs-all] pre-cluster-threshold=0.2 diff --git a/apps/runtime_source_add_delete/dstest_sgie1_config.txt b/apps/runtime_source_add_delete/dstest_sgie1_config.txt index 2a0acf6..0273408 100644 --- a/apps/runtime_source_add_delete/dstest_sgie1_config.txt +++ b/apps/runtime_source_add_delete/dstest_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 -infer-dims=3;244;244 diff --git a/apps/runtime_source_add_delete/dstest_sgie2_config.txt b/apps/runtime_source_add_delete/dstest_sgie2_config.txt index 57aa4b2..7551c1c 100644 --- a/apps/runtime_source_add_delete/dstest_sgie2_config.txt +++ b/apps/runtime_source_add_delete/dstest_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 -#scaling-compute-hw=0 -infer-dims=3;244;244 +#scaling-compute-hw=0 \ No newline at end of file diff --git a/bindings/BINDINGSGUIDE.md b/bindings/BINDINGSGUIDE.md index 253cb44..cd8abaa 100644 --- a/bindings/BINDINGSGUIDE.md +++ b/bindings/BINDINGSGUIDE.md @@ -725,4 +725,20 @@ m.def("gst_element_send_nvevent_new_stream_reset", ``` -So now, we can return the status of whether the event was handled properly, which is provided by ```gst_element_send_event()``` back to Python app as a boolean. \ No newline at end of file +So now, we can return the status of whether the event was handled properly, which is provided by ```gst_element_send_event()``` back to Python app as a boolean. + +Some additional notes: if you call a potentially blocking send event function in a sub-thread, you may need to manually release the [GIL](https://docs.python.org/3/c-api/init.html#thread-state-and-the-global-interpreter-lock). Here is an example: + +```cpp +m.def("gst_element_send_nvevent_interval_update", + [](size_t gst_element, char* stream_id, int interval) { + bool ret = false; + auto *element = reinterpret_cast(gst_element); + auto *event = gst_nvevent_infer_interval_update(stream_id, interval); + Py_BEGIN_ALLOW_THREADS; + ret = gst_element_send_event(element, event); + Py_END_ALLOW_THREADS; + return ret; + }, + pydsdoc::methodsDoc::gst_element_send_nvevent_interval_update); +``` \ No newline at end of file diff --git a/bindings/CMakeLists.txt b/bindings/CMakeLists.txt index 7b01fb2..0901ef8 100644 --- a/bindings/CMakeLists.txt +++ b/bindings/CMakeLists.txt @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,7 @@ endfunction() check_variable_set(PYTHON_MAJOR_VERSION 3) check_variable_set(PYTHON_MINOR_VERSION 10) -check_variable_set(PIP_PLATFORM linux_x86_64) + check_variable_set(DS_PATH "/opt/nvidia/deepstream/deepstream") if (DEFINED IS_SBSA) message("IS_SBSA is set. Enabling definitions for ARM_SBSA") @@ -41,8 +41,6 @@ set(PYTHON_MAJVERS_ALLOWED 3) check_variable_allowed(PYTHON_MAJOR_VERSION PYTHON_MAJVERS_ALLOWED) set(PYTHON_MINVERS_ALLOWED 10) check_variable_allowed(PYTHON_MINOR_VERSION PYTHON_MINVERS_ALLOWED) -set(PIP_PLATFORM_ALLOWED linux_x86_64 linux_aarch64) -check_variable_allowed(PIP_PLATFORM PIP_PLATFORM_ALLOWED) # Setting C++ values set(CMAKE_CXX_STANDARD 17) @@ -63,8 +61,8 @@ include_directories( ${DS_PATH}/sources/includes/ include/bind include/nvds - ../3rdparty/pybind11/include/pybind11/ - ../3rdparty/pybind11/include/ + 3rdparty/pybind11/include/pybind11/ + 3rdparty/pybind11/include/ /usr/include/python${PYTHON_VERSION} /usr/include/gstreamer-1.0 /usr/include/glib-2.0 @@ -98,17 +96,6 @@ function(add_ds_lib libname) target_link_libraries(pyds ${libname}) endfunction() -foreach(nvds_lib nvds_osd nvds_meta nvds_infer nvdsgst_meta nvbufsurface nvbufsurftransform nvdsgst_helper) +foreach(nvds_lib nvds_osd nvds_meta nvds_infer nvdsgst_meta nvbufsurface nvbufsurftransform nvdsgst_helper nvdsgst_customhelper nvds_batch_jpegenc) add_ds_lib(${nvds_lib}) -endforeach() - -# Pip wheel build -add_custom_command( - OUTPUT ${PIP_WHEEL} - DEPENDS pyds - COMMAND python${PYTHON_VERSION} ${CMAKE_SOURCE_DIR}/packaging/setup.py bdist_wheel --plat-name ${PIP_PLATFORM} - COMMAND mv -f dist/${PIP_WHEEL} ${PIP_WHEEL} - COMMAND rmdir dist -) - -add_custom_target(pip_wheel ALL DEPENDS ${PIP_WHEEL}) +endforeach() \ No newline at end of file diff --git a/bindings/packaging/setup.py b/bindings/MANIFEST.in similarity index 63% rename from bindings/packaging/setup.py rename to bindings/MANIFEST.in index d71f1e8..bde57d6 100644 --- a/bindings/packaging/setup.py +++ b/bindings/MANIFEST.in @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -13,15 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import setuptools - -setuptools.setup( - name="pyds", - version="1.1.11", - author="NVIDIA", - description="Install precompiled DeepStream Python bindings extension", - url="nvidia.com", - packages=[''], - package_data={'': ['pyds.so']}, - install_requires=["pgi", "PyGObject"] -) +graft 3rdparty/pybind11/include/pybind11 +graft src +graft include +graft docstrings +global-include CMakeLists.txt \ No newline at end of file diff --git a/bindings/README.md b/bindings/README.md index 9f60e00..af7c8bb 100644 --- a/bindings/README.md +++ b/bindings/README.md @@ -1,6 +1,6 @@ # DeepStream python bindings -SDK version supported: 7.0 +SDK version supported: 7.1 The latest prebuilt release package complete with python bindings and sample applications can be downloaded from the [release section](../../../releases) for x86, Jetson and SBSA platforms. @@ -15,16 +15,16 @@ The readme is divided into three main parts: - [1.3 Initialization of submodules](#13-initialization-of-submodules) - [1.4 Installing Gst-python](#14-installing-gst-python) - [2 Compiling the bindings](#2-compiling-the-bindings) - - [2.1 Quick build 1 (x86-ubuntu-22.04 | python 3.10 | Deepstream 7.0)](#21-quick-build-1-x86-ubuntu-2204--python-310--deepstream-70) - - [2.2 Quick build 2 (Jetson-ubuntu-22.04 | python 3.10 | Deepstream 7.0)](#22-quick-build-2-jetson-ubuntu-2204--python-310--deepstream-70) - - [2.3 Quick build 3 (SBSA-ubuntu-22.04 | python 3.10 | Deepstream 7.0)](#23-quick-build-3-sbsa-ubuntu-2204--python-310--deepstream-70) + - [2.1 Quick build 1 (x86-ubuntu-22.04 | python 3.10 | Deepstream 7.1)](#21-quick-build-1-x86-ubuntu-2204--python-310--deepstream-71) + - [2.2 Quick build 2 (Jetson-ubuntu-22.04 | python 3.10 | Deepstream 7.1)](#22-quick-build-2-jetson-ubuntu-2204--python-310--deepstream-71) + - [2.3 Quick build 3 (SBSA-ubuntu-22.04 | python 3.10 | Deepstream 7.1)](#23-quick-build-3-sbsa-ubuntu-2204--python-310--deepstream-71) - [2.4 Advanced build](#24-advanced-build) - [2.4.1 Using Cmake options](#241-using-cmake-options) - [2.4.2 Available cmake options](#242-available-cmake-options) - [2.4.3 Example](#243-example) - [2.5 Cross-Compilation for aarch64 on x86](#25-cross-compilation-for-aarch64-on-x86) - [2.5.1 Build Pre-requisites](#251-build-pre-requisites) - - [2.5.2 Download the JetPack SDK 6.0 GA](#252-download-the-jetpack-sdk-60-ga) + - [2.5.2 Download the JetPack SDK 6.1](#252-download-the-jetpack-sdk-61) - [2.5.3 Generate the cross-compile build container](#253-generate-the-cross-compile-build-container) - [2.5.4 Launch the cross-compile build container](#254-launch-the-cross-compile-build-container) - [2.5.5 Build DeepStreamSDK python bindings](#255-build-deepstreamsdk-python-bindings) @@ -50,10 +50,14 @@ apt install python3-gi python3-dev python3-gst-1.0 python-gi-dev git meson \ python3 python3-pip python3.10-dev cmake g++ build-essential libglib2.0-dev \ libglib2.0-dev-bin libgstreamer1.0-dev libtool m4 autoconf automake libgirepository1.0-dev libcairo2-dev ``` +**NEW** Additionally, install PyPA : +``` +pip3 install build +``` ### 1.3 Initialization of submodules -Make sure you clone the deepstream_python_apps repo under /sources: +Make sure you clone the deepstream_python_apps repo under \/sources: git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps This will create the following directory: @@ -66,19 +70,14 @@ To initializes them, run the following command: ```bash cd /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/ git submodule update --init +python3 bindings/3rdparty/git-partial-submodule/git-partial-submodule.py restore-sparse ``` ### 1.4 Installing Gst-python -Following commands ensure we add the new certificates that gst-python git server now uses: -```bash -sudo apt-get install -y apt-transport-https ca-certificates -y -sudo update-ca-certificates -``` - Build and install gst-python: ```bash -cd 3rdparty/gstreamer/subprojects/gst-python/ +cd bindings/3rdparty/gstreamer/subprojects/gst-python/ meson setup build cd build ninja @@ -87,41 +86,34 @@ ninja install ## 2 Compiling the bindings -Python bindings are compiled using CMake. -Following commands provide quick cmake configurations for common compilation options: +Python bindings are compiled using PyPA with a CMake extension. The compiled bindings wheel will be found inside directory `dist/`. +Following commands provide instructions for common compilation options: -### 2.1 Quick build 1 (x86-ubuntu-22.04 | python 3.10 | Deepstream 7.0) +### 2.1 Quick build 1 (x86-ubuntu-22.04 | python 3.10 | Deepstream 7.1) ```bash cd deepstream_python_apps/bindings -mkdir build -cd build -cmake .. -make -j$(nproc) +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +python3 -m build ``` -### 2.2 Quick build 2 (Jetson-ubuntu-22.04 | python 3.10 | Deepstream 7.0) +### 2.2 Quick build 2 (Jetson-ubuntu-22.04 | python 3.10 | Deepstream 7.1) The following commands will work for a native build on Jetson platform. ```bash cd deepstream_python_apps/bindings -mkdir build -cd build -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 \ - -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream/ -make -j$(nproc) +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +python3 -m build ``` -### 2.3 Quick build 3 (SBSA-ubuntu-22.04 | python 3.10 | Deepstream 7.0) +### 2.3 Quick build 3 (SBSA-ubuntu-22.04 | python 3.10 | Deepstream 7.1) The following commands will work for a native build on SBSA platform. ```bash cd deepstream_python_apps/bindings -mkdir build -cd build -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 -DIS_SBSA=1 \ - -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream/ -make -j$(nproc) +export CMAKE_ARGS="-DIS_SBSA=on" +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +python3 -m build ``` @@ -131,16 +123,15 @@ make -j$(nproc) Multiple options can be used with cmake as follows: ```bash -cmake .. [-D= [-D= [-D= ... ]]] +export CMAKE_ARGS="-D= -D= -D= ..." ``` #### 2.4.2 Available cmake options | Var | Default value | Purpose | Available values |-----|:-------------:|---------|:----------------: -| DS_VERSION | 7.0 | Used to determine default deepstream library path | should match to the deepstream version installed on your computer +| DS_VERSION | 7.1 | Used to determine default deepstream library path | should match to the deepstream version installed on your computer | PYTHON_MAJOR_VERSION | 3 | Used to set the python version used for the bindings | 3 | PYTHON_MINOR_VERSION | 10 | Used to set the python version used for the bindings | 10 -| PIP_PLATFORM | linux_x86_64 | Used to select the target architecture to compile the bindings | linux_x86_64, linux_aarch64 | DS_PATH | /opt/nvidia/deepstream/deepstream-${DS_VERSION} | Path where deepstream libraries are available | Should match the existing deepstream library folder | IS_SBSA | (Optional) | Indicate whether the build is for SBSA platform | 1 @@ -150,22 +141,18 @@ Following commands can be used to compile the bindings natively on Jetson device ```bash cd deepstream_python_apps/bindings -mkdir build -cd build -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 \ - -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream/ -make +export CMAKE_ARGS="-DDS_PATH=/opt/nvidia/deepstream/deepstream/" +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +python3 -m build ``` Following commands can be used to compile the bindings natively on SBSA platform. ```bash cd deepstream_python_apps/bindings -mkdir build -cd build -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 -DIS_SBSA=1\ - -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream/ -make +export CMAKE_ARGS="-DIS_SBSA=on" +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) +python3 -m build ``` @@ -187,17 +174,17 @@ sudo apt-get install qemu binfmt-support qemu-user-static docker run --rm --privileged dockerhub.nvidia.com/multiarch/qemu-user-static --reset -p yes # Verify qemu installation -docker run --platform linux/aarch64 --rm -t nvcr.io/nvidia/deepstream:7.0-samples-multiarch uname -m +docker run --platform linux/aarch64 --rm -t nvcr.io/nvidia/deepstream:7.1-samples-multiarch uname -m #aarch64 ``` -#### 2.5.2 Download the JetPack SDK 6.0 GA +#### 2.5.2 Download the JetPack SDK 6.1 Cross-compilation for Jetson on x86 host requires some low level libraries which can be downloaded using SDK Manager. Follow these steps to obtain these libraries, which are utilized by the docker build later. 1. Download and install the [NVIDIA SDK manager](https://developer.nvidia.com/nvidia-sdk-manager) 2. Launch the SDK Manager and login with your NVIDIA developer account. -3. Select the platform and target OS (example: Jetson AGX Xavier, `Linux Jetpack 6.0 GA`) and click Continue. +3. Select the platform and target OS (example: Jetson AGX Xavier, `Linux Jetpack 6.1`) and click Continue. 4. Under `Download & Install Options` change the download folder and select `Download now, Install later`. Agree to the license terms and click Continue. 5. Go to the download folder, and run: @@ -218,7 +205,7 @@ Below command generates the build container cd deepstream_python_apps/bindings # Make sure you are in deepstream_python_apps/bindings directory # This command builds the cross-compile docker and adds the mentioned tag -docker build --platform linux/aarch64 --tag=deepstream-7.0-ubuntu22.04-python-l4t -f qemu_docker/ubuntu-cross-aarch64.Dockerfile . +docker build --platform linux/aarch64 --tag=deepstream-7.1-ubuntu22.04-python-l4t -f qemu_docker/ubuntu-cross-aarch64.Dockerfile . ``` #### 2.5.4 Launch the cross-compile build container @@ -228,7 +215,7 @@ docker build --platform linux/aarch64 --tag=deepstream-7.0-ubuntu22.04-python-l4 mkdir export_pyds # Run the container. Make sure the tag matches the one from Generate step above -docker run --platform linux/aarch64 -it --entrypoint bash -v $PWD/export_pyds:/export_pyds deepstream-7.0-ubuntu22.04-python-l4t +docker run --platform linux/aarch64 -it --entrypoint bash -v $PWD/export_pyds:/export_pyds deepstream-7.1-ubuntu22.04-python-l4t ``` #### 2.5.5 Build DeepStreamSDK python bindings @@ -247,17 +234,14 @@ cd deepstream_python_apps/bindings/ # Initialize submodules git submodule update --init -# Create build dir and cd to it -mkdir build && cd build - -# Run cmake with following options -cmake .. -DPYTHON_MAJOR_VERSION=3 -DPYTHON_MINOR_VERSION=10 -DPIP_PLATFORM=linux_aarch64 -DDS_PATH=/opt/nvidia/deepstream/deepstream +# Set parallelization level +export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) -# Build pybind wheel and pyds.so -make -j$(nproc) +# Build pybind wheel +python3 -m build # Copy the pyds wheel package to the export dir -cp pyds-*.whl /export_pyds +cp dist/pyds-*.whl /export_pyds ``` Build output (pip wheel) is copied to the previously created export_pyds directory (deepstream_python_apps/bindings/export_pyds) on the host machine. @@ -269,7 +253,8 @@ Following commands can be used to install the generated pip wheel. ### 3.1 Installing the pip wheel ```bash -pip3 install ./pyds-1.1.11-py3-none*.whl +cd dist/ +pip3 install ./pyds-1.2.0-*.whl ``` #### 3.1.1 pip wheel troubleshooting @@ -283,4 +268,4 @@ python3 -m pip install --upgrade pip ```bash cd apps/deepstream-test1 python3 deepstream_test_1.py -``` +``` \ No newline at end of file diff --git a/bindings/docstrings/analyticsmetadoc.h b/bindings/docstrings/analyticsmetadoc.h index d3f0449..51e79df 100644 --- a/bindings/docstrings/analyticsmetadoc.h +++ b/bindings/docstrings/analyticsmetadoc.h @@ -30,6 +30,7 @@ namespace pydsdoc :ivar ocStatus: *list of str*, Holds the array of OverCrowding labels in which object is present. :ivar lcStatus: *list of str*, Holds the array of line crossing labels which object has crossed. :ivar dirStatus: *str*, Holds the direction string for the tracked object. + :ivar objStatus: *str*, Holds the status string for the tracked object. :ivar unique_id: *int*, Holds unique identifier for nvdsanalytics instance. Example usage: @@ -48,6 +49,7 @@ namespace pydsdoc if user_meta_data.lcStatus: print("Object {0} line crossing status: {1}".format(obj_meta.object_id, user_meta_data.lcStatus)) if user_meta_data.ocStatus: print("Object {0} overcrowding status: {1}".format(obj_meta.object_id, user_meta_data.ocStatus)) if user_meta_data.roiStatus: print("Object {0} roi status: {1}".format(obj_meta.object_id, user_meta_data.roiStatus)) + if user_meta_data.objStatus: print("Object {0} status: {1}".format(obj_meta.object_id, user_meta_data.objStatus)) except StopIteration: break diff --git a/bindings/docstrings/functionsdoc.h b/bindings/docstrings/functionsdoc.h index 2796605..48e4b45 100644 --- a/bindings/docstrings/functionsdoc.h +++ b/bindings/docstrings/functionsdoc.h @@ -593,7 +593,17 @@ namespace pydsdoc :arg gst_element: element for to which the generated event needs to be sent. :arg source_id: source id for which this event needs to be generated :returns: True for success.)pyds"; - + + constexpr const char* gst_element_send_nvevent_interval_update=R"pyds( + Sends a "nv-infer-interval-update" event to nvinfer. + + This function is used to update the value of the interval property of nvinfer + + :arg gst_element: nvinfer for to which the interval-update event needs to be sent. + :arg source_id: Stream ID of the stream for which infer-interval-update is to be sent + :arg interval: The infer interval obtained corresponding to stream ID for the event. + :returns: True for success.)pyds"; + constexpr const char* alloc_custom_struct=R"pyds( Allocate an :class:`CustomDataStruct`. @@ -611,21 +621,51 @@ namespace pydsdoc :arg src_elem: GStreamer source element to be configured.)pyds"; constexpr const char* nvds_measure_buffer_latency=R"pyds( - Measures the latency of all frames present in the current batch. + Measures the latency of all frames present in the current batch. :arg buffer: GstBuffer from which to retrieve the :class:`NvDsBatchMeta` - :returns: :sources number in batch. + :returns: sources number in batch. Example usage: :: - #enable pipeline latency measurement - export NVDS_ENABLE_LATENCY_MEASUREMENT=1 - #enable compoment latency measurement - export NVDS_ENABLE_COMPONENT_LATENCY_MEASUREMENT=1 + #enable pipeline latency measurement + export NVDS_ENABLE_LATENCY_MEASUREMENT=1 + #enable compoment latency measurement + export NVDS_ENABLE_COMPONENT_LATENCY_MEASUREMENT=1 + + #add this code in plugin probe function. + num_sources_in_batch = pyds.nvds_measure_buffer_latency(hash(gst_buffer));)pyds"; + + constexpr const char* nvds_obj_enc_create_context=R"pyds( + Create context and return a handle to NvObjEncCtx. + + :arg gpu_id: gpu id. + + :returns: handle to NvObjEncCtx.)pyds"; + + constexpr const char* nvds_obj_enc_process=R"pyds( + Enqueue an object crop for JPEG encode. + This is a non-blocking call and user should call `nvds_obj_enc_finish()` + to make sure all enqueued object crops have been processed. + + :arg context: handle to NvObjEncCtx. + :arg args: An object of type :class:`NvDsObjEncUsrArgs`. + :arg buffer: GstBuffer from which to retrieve the :class:`NvBufSurface` + :arg obj_meta: An object of type :class:`NvDsOjbectMeta`. + :arg frame_meta: An object of type :class:`NvDsFrameMeta`. + + :returns: 0 for success, -1 for failure.)pyds"; + + constexpr const char* nvds_obj_enc_finish=R"pyds( + Wait for all enqueued crops to be encoded. + + :arg context: handle to NvObjEncCtx.)pyds"; + + constexpr const char* nvds_obj_enc_destroy_context=R"pyds( + Destroy NvObjEncCtx context. - #add this code in plugin probe function. - num_sources_in_batch = pyds.nvds_measure_buffer_latency(hash(gst_buffer));)pyds"; - } + :arg context: handle to NvObjEncCtx.)pyds"; + } } \ No newline at end of file diff --git a/bindings/docstrings/nvdsmetadoc.h b/bindings/docstrings/nvdsmetadoc.h index bf222a2..fd8ca05 100644 --- a/bindings/docstrings/nvdsmetadoc.h +++ b/bindings/docstrings/nvdsmetadoc.h @@ -44,6 +44,8 @@ namespace pydsdoc constexpr const char* NVDSINFER_SEGMENTATION_META=R"pyds(metadata type of segmentation model output attached by gst-nvinfer. Refer :class:`NvDsInferSegmentationMeta` for details.)pyds"; constexpr const char* NVDS_CROP_IMAGE_META=R"pyds(Specifies metadata type for JPEG-encoded object crops.See the deepstream-image-meta-test app for details.)pyds"; constexpr const char* NVDS_TRACKER_PAST_FRAME_META=R"pyds(metadata type to be set for tracking previous frames)pyds"; + constexpr const char* NVDS_TRACKER_BATCH_REID_META=R"pyds(The ReID vectors for the whole batch generated by tracker. )pyds"; + constexpr const char* NVDS_TRACKER_OBJ_REID_META=R"pyds(The ReID information for a single object generated by tracker. )pyds"; constexpr const char* NVDS_AUDIO_BATCH_META=R"pyds(Specifies metadata type for formed audio batch.)pyds"; constexpr const char* NVDS_AUDIO_FRAME_META=R"pyds(Specifies metadata type for audio frame.)pyds"; constexpr const char* NVDS_RESERVED_META=R"pyds(Reserved field)pyds"; diff --git a/bindings/docstrings/trackermetadoc.h b/bindings/docstrings/trackermetadoc.h index 4a35840..f9b2e2c 100644 --- a/bindings/docstrings/trackermetadoc.h +++ b/bindings/docstrings/trackermetadoc.h @@ -109,7 +109,7 @@ namespace pydsdoc constexpr const char* list=R"pyds(Retrieve :class:`NvDsTargetMiscDataStream` object as list of :class:`NvDsTargetMiscDataObject`. Contains objects inside this stream.)pyds"; constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataStream`, call pyds.NvDsTargetMiscDataStream.cast(data))pyds"; } - + namespace NvDsTargetMiscDataBatchDoc { constexpr const char* descr = R"pyds( @@ -123,5 +123,19 @@ namespace pydsdoc constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsTargetMiscDataBatch`, call pyds.NvDsTargetMiscDataBatch.cast(data))pyds"; } + namespace NvDsObjReidDoc + { + constexpr const char* descr = R"pyds( + Holds Reid Vector information for an object. See :class:`NvDsObjReid` for example usage. + :ivar featureSize: *int*, ReID vector length. + )pyds"; + + constexpr const char* get_host_reid_vector =R"pyds( + This function converts the float* ptr_host to a NumPy array (py::array_t). + It constructs a NumPy array with the shape defined by featureSize and the data provided by ptr_host without copying the data. The array uses the float* directly from the C++ struct. + :returns: Returns Host ReID vector as NumPy array)pyds"; + + constexpr const char* cast=R"pyds(cast given object/data to :class:`NvDsObjReid`, call pyds.NvDsObjReid.cast(data))pyds"; + } } } \ No newline at end of file diff --git a/bindings/docstrings/utilsdoc.h b/bindings/docstrings/utilsdoc.h new file mode 100644 index 0000000..938c440 --- /dev/null +++ b/bindings/docstrings/utilsdoc.h @@ -0,0 +1,61 @@ +/* + * SPDX-FileCopyrightText: Copyright (c) 2021-2023 NVIDIA CORPORATION & + * AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +namespace pydsdoc { +namespace utilsdoc { + +namespace NvDsObjEncOutParamsDoc { +constexpr const char *descr = R"pyds( + output parameters of NVDS_CROP_IMAGE_META + + :ivar outBuffer: *np.array of char*, The output buffer JPEG Encoded Object.)pyds"; + +constexpr const char *cast = + R"pyds(cast given object/data to :class:`NvDsObjEncOutParams`, call pyds.NvDsObjEncOutParams.cast(data))pyds"; +} // namespace NvDsObjEncOutParamsDoc + +namespace NvDsObjEncUsrArgsDoc { +constexpr const char *descr = R"pyds( + user parameters for a nvds_obj_enc_process call + + :ivar saveImg: *bool*, Boolean variable to save image. + :ivar attachUsrMeta: *bool*, Variable to attach user metadata. + Metadata Type is "NVDS_CROP_IMAGE_META". + :ivar scaleImg: *bool*, Boolean variable to scale image. + :ivar scaledWidth: *int*, Width Parameter for scaling. + :ivar scaledHeight: *int*, Height Paramater for scaling. + :ivar fileNameImg: An array to store the string describing the path of the JPEG file. + If user specifies the filename then it'll be used otherwise the + following naming convention is used to create filename of the encoded + objects - + "frame-number_stream-number_object-number_object-type_widthxheight.jpg". + For example - 0_2_3_PERSON_126x148.jpg + :ivar objNum: *int*, Object number in the frame . + :ivar quality: *bool*, Image quality value. + :ivar isFrame: *bool*, Variable for frame/object encoding. + 1: Encodes the entire frame. + 0: Encodes object of specified resolution + :ivar calcEncodeTime: *bool*, Boolean variable to calculate time of encode.)pyds"; + +constexpr const char *cast = + R"pyds(cast given object/data to :class:`NvDsObjEncUsrArgs`, call pyds.NvDsObjEncUsrArgs.cast(data))pyds"; +} // namespace NvDsObjEncUsrArgsDoc + +} // namespace utilsdoc +} // namespace pydsdoc \ No newline at end of file diff --git a/bindings/include/bind/bindtrackermeta.hpp b/bindings/include/bind/bindtrackermeta.hpp index a57015b..f6c3e22 100644 --- a/bindings/include/bind/bindtrackermeta.hpp +++ b/bindings/include/bind/bindtrackermeta.hpp @@ -20,6 +20,7 @@ #include "../../docstrings/trackermetadoc.h" #include "pyds.hpp" +#include "pybind11/numpy.h" namespace py = pybind11; diff --git a/bindings/include/utils.hpp b/bindings/include/utils.hpp index f713b9b..223be0a 100644 --- a/bindings/include/utils.hpp +++ b/bindings/include/utils.hpp @@ -43,6 +43,9 @@ namespace pydeepstream { pybind11::arg operator ""_a(const char *str, size_t len); } +namespace pydeepstream { + void bindutils(py::module &m); +} namespace pydeepstream::utils { diff --git a/bindings/pyproject.toml b/bindings/pyproject.toml new file mode 100644 index 0000000..649dffc --- /dev/null +++ b/bindings/pyproject.toml @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +[build-system] +requires = [ + "setuptools>=42", + "wheel", + "ninja", + "cmake>=3.12", +] +build-backend = "setuptools.build_meta" + +[tool.mypy] +files = "setup.py" +python_version = "3.10" +strict = true +show_error_codes = true +enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] +warn_unreachable = true + +[[tool.mypy.overrides]] +module = ["ninja"] +ignore_missing_imports = true \ No newline at end of file diff --git a/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile b/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile index a954b9d..ffa1f6a 100644 --- a/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile +++ b/bindings/qemu_docker/ubuntu-cross-aarch64.Dockerfile @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM nvcr.io/nvidia/deepstream:7.0-triton-multiarch +FROM nvcr.io/nvidia/deepstream:7.1-triton-multiarch LABEL maintainer="NVIDIA CORPORATION" # Set timezone. @@ -69,6 +69,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ RUN pip3 install --upgrade pip RUN pip3 install setuptools>=41.0.0 +RUN pip3 install build COPY docker/jetpack_files/Jetson*Linux_R*aarch64.tbz2 /bsp_files/ diff --git a/bindings/setup.py b/bindings/setup.py new file mode 100644 index 0000000..5edbf7d --- /dev/null +++ b/bindings/setup.py @@ -0,0 +1,85 @@ +# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import subprocess +from pathlib import Path + +from setuptools import Extension, setup +from setuptools.command.build_ext import build_ext + +# A CMakeExtension needs a sourcedir instead of a file list. +# The name must be the _single_ output extension from the CMake build. +# If you need multiple extensions, see scikit-build. +class CMakeExtension(Extension): + def __init__(self, name: str, sourcedir: str = "") -> None: + super().__init__(name, sources=[]) + self.sourcedir = os.fspath(Path(sourcedir).resolve()) + + +class CMakeBuild(build_ext): + def build_extension(self, ext: CMakeExtension) -> None: + # Must be in this form due to bug in .resolve() only fixed in Python 3.10+ + ext_fullpath = Path.cwd() / self.get_ext_fullpath(ext.name) + extdir = ext_fullpath.parent.resolve() + + # CMake lets you override the generator - we need to check this. + # Can be set with Conda-Build, for example. + cmake_generator = os.environ.get("CMAKE_GENERATOR", "") + + cmake_args = [ + f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}" + ] + build_args = [] + # Adding CMake arguments set as environment variable + # (needed to build for SBSA) + if "CMAKE_ARGS" in os.environ: + cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" ") if item] + + # Set CMAKE_BUILD_PARALLEL_LEVEL to control the parallel build level + # across all generators. + if "CMAKE_BUILD_PARALLEL_LEVEL" not in os.environ: + # self.parallel is a Python 3 only way to set parallel jobs by hand + # using -j in the build_ext call, not supported by pip or PyPA-build. + if hasattr(self, "parallel") and self.parallel: + # CMake 3.12+ only. + build_args += [f"-j{self.parallel}"] + + build_temp = Path(self.build_temp) / ext.name + if not build_temp.exists(): + build_temp.mkdir(parents=True) + + subprocess.run( + ["cmake", ext.sourcedir, *cmake_args], cwd=build_temp, check=True + ) + subprocess.run( + ["cmake", "--build", ".", *build_args], cwd=build_temp, check=True + ) + + +# The information here can also be placed in setup.cfg - better separation of +# logic and declaration, and simpler if you include description/version in a file. +setup( + name="pyds", + version="1.2.0", + author="NVIDIA", + description="Install precompiled DeepStream Python bindings extension", + url="nvidia.com", + long_description="", + ext_modules=[CMakeExtension("pyds")], + cmdclass={"build_ext": CMakeBuild}, + zip_safe=False, + python_requires=">=3.10", +) \ No newline at end of file diff --git a/bindings/src/bindanalyticsmeta.cpp b/bindings/src/bindanalyticsmeta.cpp index 173b471..30b1197 100644 --- a/bindings/src/bindanalyticsmeta.cpp +++ b/bindings/src/bindanalyticsmeta.cpp @@ -34,6 +34,7 @@ namespace pydeepstream { .def_readwrite("ocStatus", &NvDsAnalyticsObjInfo::ocStatus) .def_readwrite("lcStatus", &NvDsAnalyticsObjInfo::lcStatus) .def_readwrite("dirStatus", &NvDsAnalyticsObjInfo::dirStatus) + .def_readwrite("objStatus", &NvDsAnalyticsObjInfo::objStatus) .def_readwrite("unique_id", &NvDsAnalyticsObjInfo::unique_id) .def_static("cast", diff --git a/bindings/src/bindfunctions.cpp b/bindings/src/bindfunctions.cpp index cc2c9cc..eade8d5 100644 --- a/bindings/src/bindfunctions.cpp +++ b/bindings/src/bindfunctions.cpp @@ -17,6 +17,8 @@ #include "bind_string_property_definitions.h" #include "bindfunctions.hpp" +#include "gst-nvdscustomevent.h" +#include "nvds_obj_encode.h" namespace py = pybind11; using namespace std; @@ -272,7 +274,9 @@ namespace pydeepstream { pydsdoc::methodsDoc::nvds_copy_obj_meta_list1); m.def("nvds_get_user_meta_type", - &nvds_get_user_meta_type, + [](const char* meta_descriptor) { + return g_quark_from_string((gchar*)meta_descriptor) + NVDS_START_USER_META; + }, "meta_descriptor"_a, pydsdoc::methodsDoc::nvds_get_user_meta_type1); @@ -797,6 +801,18 @@ namespace pydeepstream { }, pydsdoc::methodsDoc::gst_element_send_nvevent_new_stream_reset); + m.def("gst_element_send_nvevent_interval_update", + [](size_t gst_element, char* stream_id, int interval) { + bool ret = false; + auto *element = reinterpret_cast(gst_element); + auto *event = gst_nvevent_infer_interval_update(stream_id, interval); + Py_BEGIN_ALLOW_THREADS; + ret = gst_element_send_event(element, event); + Py_END_ALLOW_THREADS; + return ret; + }, + pydsdoc::methodsDoc::gst_element_send_nvevent_interval_update); + m.def("configure_source_for_ntp_sync", [](size_t src_elem) { auto *element = reinterpret_cast(src_elem); @@ -839,5 +855,48 @@ namespace pydeepstream { }, "gst_buffer"_a, py::return_value_policy::reference, pydsdoc::methodsDoc::nvds_measure_buffer_latency); - } + + m.def("nvds_obj_enc_create_context", + [](int gpu_id) -> size_t { + auto handle = nvds_obj_enc_create_context(gpu_id); + return reinterpret_cast(handle); + }, py::return_value_policy::reference, + pydsdoc::methodsDoc::nvds_obj_enc_create_context); + + m.def("nvds_obj_enc_process", + [](size_t ctx, NvDsObjEncUsrArgs *args, + size_t gst_buffer, NvDsObjectMeta *obj_meta, NvDsFrameMeta *frame_meta) -> bool { + auto *buffer = reinterpret_cast(gst_buffer); + auto *handle = reinterpret_cast(ctx); + if (buffer == nullptr || handle == nullptr) { + std::cout << "buffer: " << buffer << " handle: " << handle << std::endl; + return false; + } + + GstMapInfo inmap; + gst_buffer_map(buffer, &inmap, GST_MAP_READ); + auto *inputnvsurface = reinterpret_cast(inmap.data); + gst_buffer_unmap(buffer, &inmap); + + return nvds_obj_enc_process(handle, args, inputnvsurface, obj_meta, frame_meta); + }, "ctx"_a, "args"_a, "gst_buffer"_a, "obj_meta"_a, "frame_meta"_a, + py::return_value_policy::reference, + pydsdoc::methodsDoc::nvds_obj_enc_process); + + m.def("nvds_obj_enc_finish", + [](size_t ctx) { + auto *handle = reinterpret_cast(ctx); + if (handle != nullptr) { + nvds_obj_enc_finish(handle); + } + }, "ctx"_a, pydsdoc::methodsDoc::nvds_obj_enc_finish); + + m.def("nvds_obj_enc_destroy_context", + [](size_t ctx) { + auto *handle = reinterpret_cast(ctx); + if (handle != nullptr) { + nvds_obj_enc_destroy_context(handle); + } + }, "ctx"_a, pydsdoc::methodsDoc::nvds_obj_enc_destroy_context); + } } diff --git a/bindings/src/bindnvdsmeta.cpp b/bindings/src/bindnvdsmeta.cpp index 95b0585..a42a6c6 100644 --- a/bindings/src/bindnvdsmeta.cpp +++ b/bindings/src/bindnvdsmeta.cpp @@ -65,6 +65,12 @@ namespace pydeepstream { .value("NVDS_TRACKER_PAST_FRAME_META", NVDS_TRACKER_PAST_FRAME_META, pydsdoc::nvmeta::MetaTypeDoc::NVDS_TRACKER_PAST_FRAME_META) + .value("NVDS_TRACKER_BATCH_REID_META", + NVDS_TRACKER_BATCH_REID_META, + pydsdoc::nvmeta::MetaTypeDoc::NVDS_TRACKER_BATCH_REID_META) + .value("NVDS_TRACKER_OBJ_REID_META", + NVDS_TRACKER_OBJ_REID_META, + pydsdoc::nvmeta::MetaTypeDoc::NVDS_TRACKER_OBJ_REID_META) .value("NVDS_AUDIO_BATCH_META", NVDS_AUDIO_BATCH_META, pydsdoc::nvmeta::MetaTypeDoc::NVDS_AUDIO_BATCH_META) .value("NVDS_AUDIO_FRAME_META", NVDS_AUDIO_FRAME_META, diff --git a/bindings/src/bindtrackermeta.cpp b/bindings/src/bindtrackermeta.cpp index 672e7bb..f817aa0 100644 --- a/bindings/src/bindtrackermeta.cpp +++ b/bindings/src/bindtrackermeta.cpp @@ -23,7 +23,6 @@ namespace py = pybind11; namespace pydeepstream { - void bindtrackermeta(py::module &m) { /*Start of Bindings for nvds_tracker_meta.h*/ py::class_(m, "NvDsTargetMiscDataFrame", @@ -115,6 +114,26 @@ namespace pydeepstream { py::keep_alive<0, 1>(), py::return_value_policy::reference, pydsdoc::trackerdoc::NvDsTargetMiscDataBatchDoc::list); + + py::class_(m, "NvDsObjReid", + pydsdoc::trackerdoc::NvDsObjReidDoc::descr) + .def(py::init<>()) + .def_readwrite("featureSize", + &NvDsObjReid::featureSize) + // Expose a method to get the ReID vector as a NumPy array + .def("get_host_reid_vector", [](NvDsObjReid &self) { + return py::array_t( + {self.featureSize}, // Shape of the array + {sizeof(float)}, // Stride of the array + self.ptr_host // Data pointer (ptr_host from C++) + ); + }, "Returns Host ReID vector as NumPy array") + .def("cast", + [](void *data) { + return (NvDsObjReid *) data; + }, + py::return_value_policy::reference, + pydsdoc::trackerdoc::NvDsObjReidDoc::cast); } } diff --git a/bindings/src/pyds.cpp b/bindings/src/pyds.cpp index 30d02ff..56631e1 100644 --- a/bindings/src/pyds.cpp +++ b/bindings/src/pyds.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ #include */ -#define PYDS_VERSION "1.1.11" +#define PYDS_VERSION "1.2.0" using namespace std; namespace py = pybind11; @@ -63,6 +63,7 @@ namespace pydeepstream { bindnvbufsurface(m); bindnvdsinfer(m); bindopticalflowmeta(m); + bindutils(m); bindcustom(m); } // end PYBIND11_MODULE(pyds, m) diff --git a/bindings/src/utils.cpp b/bindings/src/utils.cpp index 356ff8a..9f97794 100644 --- a/bindings/src/utils.cpp +++ b/bindings/src/utils.cpp @@ -24,8 +24,13 @@ #include #include #include "gstnvdsmeta.h" +#include "pyds.hpp" #include "nvdsmeta_schema.h" #include "utils.hpp" +#include "nvds_obj_encode.h" +#include "bind_string_property_definitions.h" +#include "../../docstrings/utilsdoc.h" + /** * Specifies the type of function to copy meta data. * It is passed the pointer to meta data and user specific data. @@ -50,6 +55,57 @@ namespace pydeepstream { } } +// Utils +namespace pydeepstream { + void bindutils(py::module &m) { + py::class_(m, "NvDsObjEncOutParams", + pydsdoc::utilsdoc::NvDsObjEncOutParamsDoc::descr) + .def(py::init<>()) + .def("outBuffer", [](const NvDsObjEncOutParams &self) { + // Use this if the C++ buffer should NOT be deallocated + // once Python no longer has a reference to it + py::capsule buffer_handle([](){}); + return py::array(self.outLen, self.outBuffer, buffer_handle); + }) + .def("cast", [](size_t data) { + return (NvDsObjEncOutParams *) data; + }, + py::return_value_policy::reference, + pydsdoc::utilsdoc::NvDsObjEncOutParamsDoc::cast) + .def("cast", [](void *data) { + return (NvDsObjEncOutParams *) data; + }, + py::return_value_policy::reference, + pydsdoc::utilsdoc::NvDsObjEncOutParamsDoc::cast); + + py::class_(m, "NvDsObjEncUsrArgs", + pydsdoc::utilsdoc::NvDsObjEncUsrArgsDoc::descr) + .def(py::init<>()) + .def_readwrite("saveImg", &NvDsObjEncUsrArgs::saveImg) + .def_readwrite("attachUsrMeta", &NvDsObjEncUsrArgs::attachUsrMeta) + .def_readwrite("scaleImg", &NvDsObjEncUsrArgs::scaleImg) + .def_readwrite("scaledWidth", &NvDsObjEncUsrArgs::scaledWidth) + .def_readwrite("scaledHeight", &NvDsObjEncUsrArgs::scaledHeight) + .def_property("fileNameImg", STRING_CHAR_ARRAY(NvDsObjEncUsrArgs, fileNameImg)) + .def_readwrite("objNum", &NvDsObjEncUsrArgs::objNum) + .def_readwrite("quality", &NvDsObjEncUsrArgs::quality) + .def_readwrite("isFrame", &NvDsObjEncUsrArgs::isFrame) + .def_readwrite("calcEncodeTime", &NvDsObjEncUsrArgs::calcEncodeTime) + .def("cast", + [](size_t data) { + return (NvDsObjEncUsrArgs *) data; + }, + py::return_value_policy::reference, + pydsdoc::utilsdoc::NvDsObjEncUsrArgsDoc::cast) + .def("cast", + [](void *data) { + return (NvDsObjEncUsrArgs *) data; + }, + py::return_value_policy::reference, + pydsdoc::utilsdoc::NvDsObjEncUsrArgsDoc::cast); + } +} + namespace pydeepstream::utils { std::unordered_map> font_name_memory; diff --git a/docs/PYTHON_API/Methods/methodsdoc.rst b/docs/PYTHON_API/Methods/methodsdoc.rst index 10d9804..48b5214 100644 --- a/docs/PYTHON_API/Methods/methodsdoc.rst +++ b/docs/PYTHON_API/Methods/methodsdoc.rst @@ -16,6 +16,12 @@ gst_element_send_nvevent_new_stream_reset .. autofunction:: pyds.gst_element_send_nvevent_new_stream_reset +====================== +gst_element_send_nvevent_interval_update +====================== + +.. autofunction:: pyds.gst_element_send_nvevent_interval_update + ====================== get_segmentation_masks ====================== @@ -414,4 +420,28 @@ NvBufSurfaceMapEglImage nvds_measure_buffer_latency ============================= -.. autofunction:: pyds.nvds_measure_buffer_latency \ No newline at end of file +.. autofunction:: pyds.nvds_measure_buffer_latency + +============================= +nvds_obj_enc_create_context +============================= + +.. autofunction:: pyds.nvds_obj_enc_create_context + +============================= +nvds_obj_enc_process +============================= + +.. autofunction:: pyds.nvds_obj_enc_process + +============================= +nvds_obj_enc_finish +============================= + +.. autofunction:: pyds.nvds_obj_enc_finish + +============================= +nvds_obj_enc_destroy_context +============================= + +.. autofunction:: pyds.nvds_obj_enc_destroy_context diff --git a/docs/README.md b/docs/README.md index 0f254e0..2eed720 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2,7 +2,7 @@ Please follow the following steps to build html files requirements =================== -1. python 3.8 (The default `python --version` should be 3.8) +1. python 3.10 (The default `python --version` should be 3.10) 2. sphinx (>=4.2) 3. breathe extension 4. recommonmark @@ -18,7 +18,7 @@ pip3 install sphinx_rtd_theme ``` 1. Run parse_bindings.py to generate rst files for classes and enums -2. Copy the pyds.so from ds_python/bindings/build dir into this (docs) directory +2. Follow README in `../bindings` to compile and install bindings 3. Then run ```bash make html diff --git a/docs/bindings_file_list.txt b/docs/bindings_file_list.txt index a9571e3..2d9a3d8 100644 --- a/docs/bindings_file_list.txt +++ b/docs/bindings_file_list.txt @@ -8,4 +8,5 @@ bindnvosd.cpp bindopticalflow.cpp bindschema.cpp bindtrackermeta.cpp +utils.cpp custom_binding/bindcustom.cpp \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 3258826..4fc39b7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ project = 'Deepstream' copyright = '2019-2023, NVIDIA.' author = 'NVIDIA' -version = 'Deepstream Version: 7.0' +version = 'Deepstream Version: 7.1' release = version diff --git a/docs/index.rst b/docs/index.rst index c975452..eb6ab22 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,6 +17,7 @@ Deepstream Python API Reference PYTHON_API/NvDs360DMeta/NvDs360DMeta_toc PYTHON_API/NvDsOpticalFlow/NvDsOpticalFlow_toc PYTHON_API/GstNvDsMeta/GstNvDsMeta_toc + PYTHON_API/Utils/Utils_toc PYTHON_API/Methods/pymethods.rst PYTHON_API/CustomDataStruct/CustomDataStruct_toc diff --git a/notebooks/configs/dslaunchpad_pgie_config.txt b/notebooks/configs/dslaunchpad_pgie_config.txt index 8898e45..0dfc3c2 100644 --- a/notebooks/configs/dslaunchpad_pgie_config.txt +++ b/notebooks/configs/dslaunchpad_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/notebooks/configs/dslaunchpad_sgie1_config.txt b/notebooks/configs/dslaunchpad_sgie1_config.txt index 1b81b07..e8d722a 100644 --- a/notebooks/configs/dslaunchpad_sgie1_config.txt +++ b/notebooks/configs/dslaunchpad_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 -infer-dims=3;244;244 \ No newline at end of file diff --git a/notebooks/configs/dslaunchpad_sgie2_config.txt b/notebooks/configs/dslaunchpad_sgie2_config.txt index 3e3843d..f29bc5d 100644 --- a/notebooks/configs/dslaunchpad_sgie2_config.txt +++ b/notebooks/configs/dslaunchpad_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 -#scaling-compute-hw=0 -infer-dims=3;244;244 +#scaling-compute-hw=0 \ No newline at end of file diff --git a/notebooks/deepstream_launchpad.ipynb b/notebooks/deepstream_launchpad.ipynb index 7f46109..db3559e 100644 --- a/notebooks/deepstream_launchpad.ipynb +++ b/notebooks/deepstream_launchpad.ipynb @@ -576,26 +576,20 @@ "[property]\n", "gpu-id=0 # Device ID of GPU to use for inference\n", "net-scale-factor=0.00392156862745098 # Pixel scaling factor\n", - "tlt-model-key=tlt_encode # Key for the TAO toolkit encoded model.\n", - "tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt # Pathname of the TAO toolkit encoded model.\n", - "model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine # Path to serialized model engine file\n", + "onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx # Pathname of the TAO toolkit encoded model.\n", + "model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine # Path to serialized model engine file\n", "labelfile-path=../../../../samples/models/Primary_Detector/labels.txt # Path to text file containing labels\n", "int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin # Path to calibration file\n", - "force-implicit-batch-dim=1 # Force the implicit batch dimension mode\n", - "batch-size=30 # Number of frames/objects to be inferred together in a batch\n", + "batch-size=1 # Number of frames/objects to be inferred together in a batch\n", "process-mode=1 # Infer Processing Mode 1=Primary Mode 2=Secondary Mode\n", "model-color-format=0 # Color format required by the model (ignored if input-tensor-meta enabled)\n", "network-mode=1 # Data format to be used by inference 0=FP32, 1=INT8, 2=FP16 mode\n", "num-detected-classes=4 # Number of classes detected by the network\n", "interval=0 # Number of consecutive batches to be skipped for inference\n", "gie-unique-id=1 # Unique ID to assign to GIE\n", - "uff-input-order=0 # UFF input layer order\n", - "uff-input-blob-name=input_1 # Name of the input blob in the UFF file\n", - "output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd # Array of output layer names\n", "#scaling-filter=0\n", "#scaling-compute-hw=0\n", "cluster-mode=2 # Clustering algorithm to use.\n", - "infer-dims=3;544;960 # Binding dimensions to set on the image input layer\n", "\n", "[class-attrs-all]\n", "pre-cluster-threshold=0.2 # Detection threshold to be applied prior to clustering\n", diff --git a/notebooks/deepstream_test_1.ipynb b/notebooks/deepstream_test_1.ipynb index 0fcfdb6..9e5cb41 100644 --- a/notebooks/deepstream_test_1.ipynb +++ b/notebooks/deepstream_test_1.ipynb @@ -50,9 +50,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " * **DeepStream SDK 7.0**\n", + " * **DeepStream SDK 7.1**\n", "\n", - "To setup and install DeepStream 7.0, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", + "To setup and install DeepStream 7.1, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", " \n", " * **DeepStream Python Apps**\n", "\n", diff --git a/notebooks/deepstream_test_4.ipynb b/notebooks/deepstream_test_4.ipynb index 34405f2..afa4bcc 100644 --- a/notebooks/deepstream_test_4.ipynb +++ b/notebooks/deepstream_test_4.ipynb @@ -45,9 +45,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " * **DeepStream SDK 7.0**\n", + " * **DeepStream SDK 7.1**\n", "\n", - "To setup and install DeepStream 7.0, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", + "To setup and install DeepStream 7.1, please follow the steps at https://developer.nvidia.com/deepstream-getting-started\n", " \n", " * **DeepStream Python Apps**\n", "\n", diff --git a/tests/integration/README.md b/tests/integration/README.md index 2f6d2cf..e161faa 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -34,24 +34,30 @@ Installing: * python virtual env for the requested python version * dependencies listed in the `bindings` folder * pytest +* ReID model for tracker + ``` + cd /opt/nvidia/deepstream/deepstream/samples/models + mkdir Tracker && cd Tracker + wget --content-disposition 'https://api.ngc.nvidia.com/v2/models/org/nvidia/team/tao/reidentificationnet/deployable_v1.2/files?redirect=true&path=resnet50_market1501_aicity156.onnx' -O resnet50_market1501_aicity156.onnx + export PATH=$PATH:/usr/src/tensorrt/bin + trtexec --minShapes=input:1x3x256x128 --optShapes=input:8x3x256x128 --maxShapes=input:16x3x256x128 --fp16 --saveEngine=resnet50_market1501_aicity156.onnx_b16_gpu0_fp16.engine --onnx=resnet50_market1501_aicity156.onnx + ``` ### step1 -``` -mkdir -p bindings/build -cd bindings/build -``` + +Compile bindings as per [Python Binding instructions](../../bindings) + ### step2 #### Python 3.10 ``` -cmake .. -DPYTHON_MINOR_VERSION=10 -make +apt install python3.10-venv python3.10 -m venv env ``` ### step3 ``` . env/bin/activate -pip install pyds-1.1.11-py3-none-*.whl -pip install pytest -cd ../../tests/integration +pip install /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/dist/pyds-1.2.0*.whl +pip install pytest pygobject cuda-python numpy==1.26.0 +cd /opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/tests/integration pytest test.py ``` diff --git a/tests/integration/deepstream_demo.py b/tests/integration/deepstream_demo.py index 28e19e9..f0e9765 100755 --- a/tests/integration/deepstream_demo.py +++ b/tests/integration/deepstream_demo.py @@ -52,7 +52,7 @@ def make_text_display(display_meta, frame_number, num_rects, obj_counter): py_nvosd_text_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0) -def frame_function(batch_meta, frame_meta, dict_data): +def frame_function(batch_meta, frame_meta, dict_data, gst_buffer): obj_counter = dict_data["obj_counter"] pgie_class_id = dict_data["pgie_class_id"] frame_number = frame_meta.frame_num @@ -66,7 +66,7 @@ def frame_function(batch_meta, frame_meta, dict_data): pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta) -def box_function(batch_meta, frame_meta, obj_meta, dict_data): +def box_function(batch_meta, frame_meta, obj_meta, dict_data, gst_buffer): obj_counter = dict_data["obj_counter"] pgie_class_id = dict_data["pgie_class_id"] obj_counter[pgie_class_id[obj_meta.class_id]] += 1 diff --git a/tests/integration/ds_base_config.txt b/tests/integration/ds_base_config.txt index 9f5352e..0dfc3c2 100644 --- a/tests/integration/ds_base_config.txt +++ b/tests/integration/ds_base_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/tests/integration/ds_pgie_config.txt b/tests/integration/ds_pgie_config.txt index 9f5352e..0dfc3c2 100644 --- a/tests/integration/ds_pgie_config.txt +++ b/tests/integration/ds_pgie_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,13 +55,11 @@ [property] gpu-id=0 net-scale-factor=0.00392156862745098 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt -model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet.etlt_b30_gpu0_int8.engine +onnx-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx +model-engine-file=../../../../samples/models/Primary_Detector/resnet18_trafficcamnet_pruned.onnx_b1_gpu0_int8.engine labelfile-path=../../../../samples/models/Primary_Detector/labels.txt int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin -force-implicit-batch-dim=1 -batch-size=30 +batch-size=1 process-mode=1 model-color-format=0 ## 0=FP32, 1=INT8, 2=FP16 mode @@ -69,15 +67,11 @@ network-mode=1 num-detected-classes=4 interval=0 gie-unique-id=1 -uff-input-order=0 -uff-input-blob-name=input_1 -output-blob-names=output_cov/Sigmoid;output_bbox/BiasAdd #scaling-filter=0 #scaling-compute-hw=0 cluster-mode=2 -infer-dims=3;544;960 [class-attrs-all] pre-cluster-threshold=0.2 -eps=0.2 -group-threshold=1 +topk=20 +nms-iou-threshold=0.5 diff --git a/tests/integration/ds_sgie1_config.txt b/tests/integration/ds_sgie1_config.txt index d8f02d4..e8d722a 100644 --- a/tests/integration/ds_sgie1_config.txt +++ b/tests/integration/ds_sgie1_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleMake/resnet18_vehiclemakenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleMake/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleMake/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=2 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 #scaling-compute-hw=0 -infer-dims=3;244;244 \ No newline at end of file diff --git a/tests/integration/ds_sgie2_config.txt b/tests/integration/ds_sgie2_config.txt index 8b0313b..f29bc5d 100644 --- a/tests/integration/ds_sgie2_config.txt +++ b/tests/integration/ds_sgie2_config.txt @@ -1,5 +1,5 @@ ################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-FileCopyrightText: Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,12 +55,10 @@ [property] gpu-id=0 net-scale-factor=1 -tlt-model-key=tlt_encode -tlt-encoded-model=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt -model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet.etlt_b16_gpu0_int8.engine +onnx-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx +model-engine-file=../../../../samples/models/Secondary_VehicleTypes/resnet18_vehicletypenet_pruned.onnx_b16_gpu0_int8.engine labelfile-path=../../../../samples/models/Secondary_VehicleTypes/labels.txt int8-calib-file=../../../../samples/models/Secondary_VehicleTypes/cal_trt.bin -force-implicit-batch-dim=1 batch-size=16 # 0=FP32 and 1=INT8 mode network-mode=1 @@ -73,11 +71,8 @@ gie-unique-id=3 operate-on-gie-id=1 operate-on-class-ids=0 is-classifier=1 -uff-input-blob-name=input_1 -output-blob-names=predictions/Softmax classifier-async-mode=1 classifier-threshold=0.51 process-mode=2 #scaling-filter=0 -#scaling-compute-hw=0 -infer-dims=3;244;244 +#scaling-compute-hw=0 \ No newline at end of file diff --git a/tests/integration/test.py b/tests/integration/test.py index c73703c..9669dd0 100644 --- a/tests/integration/test.py +++ b/tests/integration/test.py @@ -71,11 +71,11 @@ def test_pipeline1(): ### INIT DATA # defining the function to be called at each frame - def frame_function(batch_meta, frame_meta, dict_data): + def frame_function(batch_meta, frame_meta, dict_data, gst_buffer): pass # defining the function to be called at each object - def box_function(batch_meta, frame_meta, obj_meta, dict_data): + def box_function(batch_meta, frame_meta, obj_meta, dict_data, gst_buffer): obj_counter = dict_data["obj_counter"] pgie_class_id = dict_data["pgie_class_id"] obj_counter[pgie_class_id[obj_meta.class_id]] += 1 @@ -112,7 +112,7 @@ def test_pipeline2(): ### INIT DATA # defining the function to be called at each frame - def frame_function(batch_meta, frame_meta, dict_data): + def frame_function(batch_meta, frame_meta, dict_data, gst_buffer): pass tracker_qty_expected = { @@ -130,7 +130,7 @@ def frame_function(batch_meta, frame_meta, dict_data): "confidence": 464, "age": 464} - def user_function(batch_meta, user_meta, dict_data): + def user_function(batch_meta, user_meta, dict_data, gst_buffer): if not user_meta: return if not user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_TRACKER_PAST_FRAME_META: @@ -155,11 +155,28 @@ def user_function(batch_meta, user_meta, dict_data): tracker_data["age"].add(miscDataFrame.confidence) # defining the function to be called at each object - def box_function(batch_meta, frame_meta, obj_meta, dict_data): + def box_function(batch_meta, frame_meta, obj_meta, dict_data, gst_buffer): obj_counter = dict_data["obj_counter"] pgie_class_id = dict_data["pgie_class_id"] obj_counter[pgie_class_id[obj_meta.class_id]] += 1 + l_obj_user_meta = obj_meta.obj_user_meta_list + while l_obj_user_meta is not None: + try: + user_meta=pyds.NvDsUserMeta.cast(l_obj_user_meta.data) + if not user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_TRACKER_OBJ_REID_META: + continue + reid=pyds.NvDsObjReid.cast(user_meta.user_meta_data) + vec = reid.get_host_reid_vector() + assert reid.featureSize == vec.size + # print(f"reid featureSize {reid.featureSize} == {vec.__class__} == {vec.size}") + except StopIteration: + break + try: + l_obj_user_meta=l_obj_user_meta.next + except StopIteration: + break + tracker_cfg = get_tracker_properties_from_config("ds_tracker_config.txt") properties = { "file-source": { @@ -214,3 +231,103 @@ def box_function(batch_meta, frame_meta, obj_meta, dict_data): for key, expected_qty in tracker_qty_expected.items(): qty = len(data_probe["tracker_data"][key]) assert qty > 0 + + +def test_pipeline3(): + ### INIT DATA + + # Creating the pipeline + sp = PipelineFakesink(STANDARD_PROPERTIES1, is_integrated_gpu()) + + # Create Context for Object Encoding. + # Takes GPU ID as a parameter. + obj_ctx_handle = pyds.nvds_obj_enc_create_context (0) + + # defining the function to be called at each frame + def frame_function(batch_meta, frame_meta, dict_data, gst_buffer): + frame_number=frame_meta.frame_num + if frame_number < 3: + frameData = pyds.NvDsObjEncUsrArgs() + frameData.isFrame = 1 + frameData.saveImg = False + frameData.attachUsrMeta = True + frameData.scaleImg = False + frameData.scaledWidth = 0 + frameData.scaledHeight = 0 + frameData.quality = 80 + frameData.calcEncodeTime = 1 + pyds.nvds_obj_enc_process (obj_ctx_handle, frameData, hash(gst_buffer), None, frame_meta) + + # defining the function to be called at each object + def box_function(batch_meta, frame_meta, obj_meta, dict_data, gst_buffer): + count = 0 + frame_number=frame_meta.frame_num + num_obj = frame_meta.num_obj_meta + if frame_number < 3 and count == 0: + count += 1 + objData = pyds.NvDsObjEncUsrArgs() + objData.saveImg = False + objData.attachUsrMeta = True + objData.scaleImg = False + objData.scaledWidth = 0 + objData.scaledHeight = 0 + objData.objNum = num_obj + objData.quality = 80 + objData.calcEncodeTime = 1 + pyds.nvds_obj_enc_process (obj_ctx_handle, objData, hash(gst_buffer), obj_meta, frame_meta) + + def post_process(gst_buffer): + pyds.nvds_obj_enc_finish(obj_ctx_handle) + + # Creating the probe function + probe_function = FrameIterator(frame_function, box_function, None, None, post_process) + # registering the probe function + sp.set_fix_elem_probe("primary-inference", "src", probe_function) + + def frame_function2(batch_meta, frame_meta, dict_data, gst_buffer): + fusrMetaList = frame_meta.frame_user_meta_list + frame_number = frame_meta.frame_num + while fusrMetaList is not None: + try: + fuser_meta = pyds.NvDsUserMeta.cast(fusrMetaList.data) + if fuser_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_CROP_IMAGE_META: + fenc_output = pyds.NvDsObjEncOutParams.cast(fuser_meta.user_meta_data) + foutput = fenc_output.outBuffer() + assert foutput is not None + foutput.tofile(f"frame-{frame_number}-out.jpg") + except StopIteration: + break + try: + fusrMetaList = fusrMetaList.next + except StopIteration: + break + + def box_function2(batch_meta, frame_meta, obj_meta, dict_data, gst_buffer): + frame_number = frame_meta.frame_num + usrMetaList = obj_meta.obj_user_meta_list + count = 0 + while usrMetaList is not None: + try: + user_meta = pyds.NvDsUserMeta.cast(usrMetaList.data) + if user_meta.base_meta.meta_type == pyds.NvDsMetaType.NVDS_CROP_IMAGE_META: + enc_output = pyds.NvDsObjEncOutParams.cast(user_meta.user_meta_data) + output = enc_output.outBuffer() + assert output is not None + output.tofile(f"frame-{frame_number}-obj-{count}-out.jpg") + count += 1 + except StopIteration: + break + try: + usrMetaList = usrMetaList.next + except StopIteration: + break + + probe_function2 = FrameIterator(frame_function2, box_function2, None) + sp.set_probe(probe_function2) + + ### LAUNCH BEHAVIOR + # Running the pipeline + sp.run() + + # Destroy context for Object Encoding + pyds.nvds_obj_enc_destroy_context (obj_ctx_handle) diff --git a/tests/integration/tracker_config.yml b/tests/integration/tracker_config.yml index 394f04d..4e9125b 100644 --- a/tests/integration/tracker_config.yml +++ b/tests/integration/tracker_config.yml @@ -1,74 +1,129 @@ %YAML:1.0 -################################################################################ -# SPDX-FileCopyrightText: Copyright (c) 2019-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 +#################################################################################################### +# SPDX-FileCopyrightText: Copyright (c) 2021-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: LicenseRef-NvidiaProprietary # -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ +# NVIDIA CORPORATION, its affiliates and licensors retain all intellectual +# property and proprietary rights in and to this material, related +# documentation and any modifications thereto. Any use, reproduction, +# disclosure or distribution of this material and related documentation +# without an express license agreement from NVIDIA CORPORATION or +# its affiliates is strictly prohibited. +#################################################################################################### BaseConfig: - minDetectorConfidence: 0 # If the confidence of a detector bbox is lower than this, then it won't be considered for tracking + minDetectorConfidence: 0.1894 # If the confidence of a detector bbox is lower than this, then it won't be considered for tracking TargetManagement: - enableBboxUnClipping: 1 # In case the bbox is likely to be clipped by image border, unclip bbox - maxTargetsPerStream: 150 # Max number of targets to track per stream. Recommended to set >10. Note: this value should account for the targets being tracked in shadow mode as well. Max value depends on the GPU memory capacity + enableBboxUnClipping: 1 # In case the bbox is likely to be clipped by image border, unclip bbox + preserveStreamUpdateOrder: 0 # When assigning new target ids, preserve input streams' order to keep target ids in a deterministic order over multuple runs + maxTargetsPerStream: 150 # Max number of targets to track per stream. Recommended to set >10. Note: this value should account for the targets being tracked in shadow mode as well. Max value depends on the GPU memory capacity # [Creation & Termination Policy] - minIouDiff4NewTarget: 0.5 # If the IOU between the newly detected object and any of the existing targets is higher than this threshold, this newly detected object will be discarded. - minTrackerConfidence: 0.2 # If the confidence of an object tracker is lower than this on the fly, then it will be tracked in shadow mode. Valid Range: [0.0, 1.0] - probationAge: 3 # If the target's age exceeds this, the target will be considered to be valid. - maxShadowTrackingAge: 30 # Max length of shadow tracking. If the shadowTrackingAge exceeds this limit, the tracker will be terminated. - earlyTerminationAge: 1 # If the shadowTrackingAge reaches this threshold while in TENTATIVE period, the target will be terminated prematurely. + minIouDiff4NewTarget: 0.3686 # If the IOU between the newly detected object and any of the existing targets is higher than this threshold, this newly detected object will be discarded. + minTrackerConfidence: 0.1513 # If the confidence of an object tracker is lower than this on the fly, then it will be tracked in shadow mode. Valid Range: [0.0, 1.0] + probationAge: 2 # If the target's age exceeds this, the target will be considered to be valid. + maxShadowTrackingAge: 42 # Max length of shadow tracking. If the shadowTrackingAge exceeds this limit, the tracker will be terminated. + earlyTerminationAge: 1 # If the shadowTrackingAge reaches this threshold while in TENTATIVE period, the target will be terminated prematurely. TrajectoryManagement: - useUniqueID: 0 # Use 64-bit long Unique ID when assignining tracker ID. Default is [true] + useUniqueID: 0 # Use 64-bit long Unique ID when assignining tracker ID. Default is [true] + enableReAssoc: 1 # Enable Re-Assoc + + # [Re-Assoc Metric: Thresholds for valid candidates] + minMatchingScore4Overall: 0.6622 # min matching score for overall + minTrackletMatchingScore: 0.2940 # min tracklet similarity score for re-assoc + minMatchingScore4ReidSimilarity: 0.0771 # min reid similarity score for re-assoc + + # [Re-Assoc Metric: Weights] + matchingScoreWeight4TrackletSimilarity: 0.7981 # weight for tracklet similarity score + matchingScoreWeight4ReidSimilarity: 0.3848 # weight for reid similarity score + + # [Re-Assoc: Motion-based] + minTrajectoryLength4Projection: 34 # min trajectory length required to make projected trajectory + prepLength4TrajectoryProjection: 58 # the length of the trajectory during which the state estimator is updated to make projections + trajectoryProjectionLength: 33 # the length of the projected trajectory + maxAngle4TrackletMatching: 67 # max angle difference for tracklet matching [degree] + minSpeedSimilarity4TrackletMatching: 0.0574 # min speed similarity for tracklet matching + minBboxSizeSimilarity4TrackletMatching: 0.1013 # min bbox size similarity for tracklet matching + maxTrackletMatchingTimeSearchRange: 27 # the search space in time for max tracklet similarity + trajectoryProjectionProcessNoiseScale: 0.0100 # trajectory projector's process noise scale w.r.t. state estimator + trajectoryProjectionMeasurementNoiseScale: 100 # trajectory projector's measurement noise scale w.r.t. state estimator + trackletSpacialSearchRegionScale: 0.0100 # the search region scale for peer tracklet + + # [Re-Assoc: Reid based. Reid model params are set in ReID section] + reidExtractionInterval: 8 # frame interval to extract reid features per target DataAssociator: - dataAssociatorType: 0 # the type of data associator among { DEFAULT= 0 } - associationMatcherType: 0 # the type of matching algorithm among { GREEDY=0, GLOBAL=1 } - checkClassMatch: 1 # If checked, only the same-class objects are associated with each other. Default: true + dataAssociatorType: 0 # the type of data associator among { DEFAULT= 0 } + associationMatcherType: 1 # the type of matching algorithm among { GREEDY=0, CASCADED=1 } + checkClassMatch: 1 # If checked, only the same-class objects are associated with each other. Default: true # [Association Metric: Thresholds for valid candidates] - minMatchingScore4Overall: 0.0 # Min total score - minMatchingScore4SizeSimilarity: 0.6 # Min bbox size similarity score - minMatchingScore4Iou: 0.0 # Min IOU score - minMatchingScore4VisualSimilarity: 0.7 # Min visual similarity score + minMatchingScore4Overall: 0.0222 # Min total score + minMatchingScore4SizeSimilarity: 0.3552 # Min bbox size similarity score + minMatchingScore4Iou: 0.0548 # Min IOU score + minMatchingScore4VisualSimilarity: 0.5043 # Min visual similarity score # [Association Metric: Weights] - matchingScoreWeight4VisualSimilarity: 0.6 # Weight for the visual similarity (in terms of correlation response ratio) - matchingScoreWeight4SizeSimilarity: 0.0 # Weight for the Size-similarity score - matchingScoreWeight4Iou: 0.4 # Weight for the IOU score + matchingScoreWeight4VisualSimilarity: 0.3951 # Weight for the visual similarity (in terms of correlation response ratio) + matchingScoreWeight4SizeSimilarity: 0.6003 # Weight for the Size-similarity score + matchingScoreWeight4Iou: 0.4033 # Weight for the IOU score + + # [Association Metric: Tentative detections] only uses iou similarity for tentative detections + tentativeDetectorConfidence: 0.1024 # If a detection's confidence is lower than this but higher than minDetectorConfidence, then it's considered as a tentative detection + minMatchingScore4TentativeIou: 0.2852 # Min iou threshold to match targets and tentative detection StateEstimator: - stateEstimatorType: 1 # the type of state estimator among { DUMMY=0, SIMPLE=1, REGULAR=2 } + stateEstimatorType: 1 # the type of state estimator among { DUMMY=0, SIMPLE=1, REGULAR=2 } # [Dynamics Modeling] - processNoiseVar4Loc: 2.0 # Process noise variance for bbox center - processNoiseVar4Size: 1.0 # Process noise variance for bbox size - processNoiseVar4Vel: 0.1 # Process noise variance for velocity - measurementNoiseVar4Detector: 4.0 # Measurement noise variance for detector's detection - measurementNoiseVar4Tracker: 16.0 # Measurement noise variance for tracker's localization + processNoiseVar4Loc: 6810.8668 # Process noise variance for bbox center + processNoiseVar4Size: 1541.8647 # Process noise variance for bbox size + processNoiseVar4Vel: 1348.4874 # Process noise variance for velocity + measurementNoiseVar4Detector: 100.0000 # Measurement noise variance for detector's detection + measurementNoiseVar4Tracker: 293.3238 # Measurement noise variance for tracker's localization VisualTracker: - visualTrackerType: 1 # the type of visual tracker among { DUMMY=0, NvDCF=1 } + visualTrackerType: 1 # the type of visual tracker among { DUMMY=0, NvDCF=1 } # [NvDCF: Feature Extraction] - useColorNames: 1 # Use ColorNames feature - useHog: 0 # Use Histogram-of-Oriented-Gradient (HOG) feature - featureImgSizeLevel: 2 # Size of a feature image. Valid range: {1, 2, 3, 4, 5}, from the smallest to the largest - featureFocusOffsetFactor_y: -0.2 # The offset for the center of hanning window relative to the feature height. The center of hanning window would move by (featureFocusOffsetFactor_y*featureMatSize.height) in vertical direction + useColorNames: 1 # Use ColorNames feature + useHog: 1 # Use Histogram-of-Oriented-Gradient (HOG) feature + featureImgSizeLevel: 3 # Size of a feature image. Valid range: {1, 2, 3, 4, 5}, from the smallest to the largest + featureFocusOffsetFactor_y: -0.1054 # The offset for the center of hanning window relative to the feature height. The center of hanning window would move by (featureFocusOffsetFactor_y*featureMatSize.height) in vertical direction # [NvDCF: Correlation Filter] - filterLr: 0.075 # learning rate for DCF filter in exponential moving average. Valid Range: [0.0, 1.0] - filterChannelWeightsLr: 0.1 # learning rate for the channel weights among feature channels. Valid Range: [0.0, 1.0] - gaussianSigma: 0.75 # Standard deviation for Gaussian for desired response when creating DCF filter [pixels] + filterLr: 0.0767 # learning rate for DCF filter in exponential moving average. Valid Range: [0.0, 1.0] + filterChannelWeightsLr: 0.0339 # learning rate for the channel weights among feature channels. Valid Range: [0.0, 1.0] + gaussianSigma: 0.5687 # Standard deviation for Gaussian for desired response when creating DCF filter [pixels] + +ReID: + reidType: 2 # The type of reid among { DUMMY=0, NvDEEPSORT=1, Reid based reassoc=2, both NvDEEPSORT and reid based reassoc=3} + outputReidTensor: 1 + + # [Reid Network Info] + batchSize: 100 # Batch size of reid network + workspaceSize: 1000 # Workspace size to be used by reid engine, in MB + reidFeatureSize: 256 # Size of reid feature + reidHistorySize: 100 # Max number of reid features kept for one object + inferDims: [3, 256, 128] # Reid network input dimension CHW or HWC based on inputOrder + networkMode: 1 # Reid network inference precision mode among {fp32=0, fp16=1, int8=2 } + + # [Input Preprocessing] + inputOrder: 0 # Reid network input order among { NCHW=0, NHWC=1 }. Batch will be converted to the specified order before reid input. + colorFormat: 0 # Reid network input color format among {RGB=0, BGR=1 }. Batch will be converted to the specified color before reid input. + offsets: [123.6750, 116.2800, 103.5300] # Array of values to be subtracted from each input channel, with length equal to number of channels + netScaleFactor: 0.01735207 # Scaling factor for reid network input after substracting offsets + keepAspc: 1 # Whether to keep aspc ratio when resizing input objects for reid + + # [Output Postprocessing] + addFeatureNormalization: 1 # If reid feature is not normalized in network, adding normalization on output so each reid feature has l2 norm equal to 1 + minVisibility4GalleryUpdate: 0.6 # Add ReID embedding to the gallery only if the visibility is not lower than this + + # [Paths and Names] + onnxFile: "/opt/nvidia/deepstream/deepstream/samples/models/Tracker/resnet50_market1501_aicity156.onnx" # NVIDIA TAO model path + modelEngineFile: "/opt/nvidia/deepstream/deepstream/samples/models/Tracker/resnet50_market1501_aicity156.onnx_b16_gpu0_fp16.engine" # Engine file path + #tltEncodedModel: "/opt/nvidia/deepstream/deepstream/samples/models/Tracker/resnet50_market1501.etlt" # NVIDIA TAO model path + #tltModelKey: "nvidia_tao" # NVIDIA TAO model key + #modelEngineFile: "/opt/nvidia/deepstream/deepstream/samples/models/Tracker/resnet50_market1501.etlt_b100_gpu0_fp16.engine" # Engine file path \ No newline at end of file diff --git a/tests/testcommon/frame_iterator.py b/tests/testcommon/frame_iterator.py index 9557b16..a5606a8 100644 --- a/tests/testcommon/frame_iterator.py +++ b/tests/testcommon/frame_iterator.py @@ -24,22 +24,26 @@ class FrameIterator: - def __init__(self, fun_frame, fun_obj, data_dict, fun_user=None): + def __init__(self, fun_frame, fun_obj, data_dict, fun_user=None, fun_post_process=None): self._fun_frame = fun_frame self._fun_obj = fun_obj self._fun_user = fun_user self._data_dict = data_dict + self._fun_post_process = fun_post_process - def _process_frame_function(self, batch_meta, frame_meta): + def _process_frame_function(self, batch_meta, frame_meta, gst_buffer): + self._fun_frame(batch_meta, frame_meta, self._data_dict, gst_buffer) - self._fun_frame(batch_meta, frame_meta, self._data_dict) + def _process_obj_function(self, batch_meta, frame_meta, obj_meta, gst_buffer): + self._fun_obj(batch_meta, frame_meta, obj_meta, self._data_dict, gst_buffer) - def _process_obj_function(self, batch_meta, frame_meta, obj_meta): - self._fun_obj(batch_meta, frame_meta, obj_meta, self._data_dict) - - def _process_user_function(self, batch_meta, user_meta): + def _process_user_function(self, batch_meta, user_meta, gst_buffer): if self._fun_user: - self._fun_user(batch_meta, user_meta, self._data_dict) + self._fun_user(batch_meta, user_meta, self._data_dict, gst_buffer) + + def _post_process_function(self, gst_buffer): + if self._fun_post_process: + self._fun_post_process(gst_buffer) def __call__(self, pad, info, u_data): @@ -62,14 +66,14 @@ def __call__(self, pad, info, u_data): obj_meta = pyds.NvDsObjectMeta.cast(l_obj.data) except StopIteration: break - self._process_obj_function(batch_meta, frame_meta, obj_meta) + self._process_obj_function(batch_meta, frame_meta, obj_meta, gst_buffer) try: l_obj = l_obj.next except StopIteration: break - self._process_frame_function(batch_meta, frame_meta) + self._process_frame_function(batch_meta, frame_meta, gst_buffer) try: l_frame = l_frame.next @@ -82,10 +86,12 @@ def __call__(self, pad, info, u_data): user_meta = pyds.NvDsUserMeta.cast(l_user.data) except StopIteration: break - self._process_user_function(batch_meta, user_meta) + self._process_user_function(batch_meta, user_meta, gst_buffer) try: l_user = l_user.next except StopIteration: break + self._post_process_function(gst_buffer) + return Gst.PadProbeReturn.OK diff --git a/tests/testcommon/pipeline_fakesink.py b/tests/testcommon/pipeline_fakesink.py index e381dfd..5dc7e82 100644 --- a/tests/testcommon/pipeline_fakesink.py +++ b/tests/testcommon/pipeline_fakesink.py @@ -40,6 +40,7 @@ def __init__(self, properties, is_integrated_gpu): ] pipeline_arm64 = [ ] + self.pipeline_base = pipeline_base super().__init__(properties, is_integrated_gpu, pipeline_base, pipeline_arm64) @@ -51,6 +52,16 @@ def set_probe(self, probe_function): osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, probe_function, 0) + def set_fix_elem_probe(self, elem_name, direction, probe_function): + assert elem_name in [item[1] for item in self.pipeline_base] + assert direction in ["src", "sink"] + element = self._get_elm_by_name(elem_name) + pad = element.get_static_pad(direction) + if not pad: + sys.stderr.write("Unable to get sink pad of {elem_name} \n") + + pad.add_probe(Gst.PadProbeType.BUFFER, probe_function, 0) + def _link_elements(self): gebn = lambda n: self._get_elm_by_name(n) source = gebn("file-source")