Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added action recognition pipeline and Python bindings #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
527 changes: 527 additions & 0 deletions apps/deepstream-3d-action-recognition/deepstream_action_recog.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[property]
gpu-id=0

#onnx-file=/opt/nvidia/deepstream/deepstream-7.1/sources/apps/sample_apps/deepstream-3d-action-recognition/resnet18_3d_rgb_hmdb5_32.onnx
model-engine-file=/opt/nvidia/deepstream/deepstream-7.1/sources/apps/sample_apps/deepstream-3d-action-recognition/resnet18_3d_rgb_hmdb5_32.onnx_b4_gpu0_fp16.engine

labelfile-path=labels.txt
batch-size=4
process-mode=1

# requries preprocess metadata input
input-tensor-from-meta=1

## 0=FP32, 1=INT8, 2=FP16 mode
network-mode=2
gie-unique-id=1

# 1: classifier, 100: custom
network-type=1

# Let application to parse the inference tensor output
output-tensor-meta=1
tensor-meta-pool-size=8
1 change: 1 addition & 0 deletions apps/deepstream-3d-action-recognition/labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
push;fall_floor;walk;run;ride_bike
5 changes: 3 additions & 2 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ endfunction()
check_variable_set(PYTHON_MAJOR_VERSION 3)
check_variable_set(PYTHON_MINOR_VERSION 10)

check_variable_set(DS_PATH "/opt/nvidia/deepstream/deepstream")
check_variable_set(DS_PATH "/opt/nvidia/deepstream/deepstream-7.1")
if (DEFINED IS_SBSA)
message("IS_SBSA is set. Enabling definitions for ARM_SBSA")
add_compile_definitions(IS_SBSA)
Expand Down Expand Up @@ -74,7 +74,8 @@ add_library(pyds SHARED src/pyds.cpp src/utils.cpp src/bindanalyticsmeta.cpp
src/bindfunctions.cpp src/bindgstnvdsmeta.cpp
src/bindmeta360.cpp src/bindnvbufsurface.cpp src/bindnvdsinfer.cpp
src/bindnvdsmeta.cpp src/bindnvosd.cpp src/bindopticalflow.cpp
src/bindschema.cpp src/bindtrackermeta.cpp src/custom_binding/bindcustom.cpp)
src/bindschema.cpp src/bindtrackermeta.cpp src/custom_binding/bindcustom.cpp
src/bindnvdspreprocess_meta.cpp src/bindnvds_roi_meta.cpp)

set_target_properties(pyds PROPERTIES PREFIX "")
set_target_properties(pyds PROPERTIES OUTPUT_NAME "pyds")
Expand Down
Binary file not shown.
Binary file added bindings/dist/pyds-1.2.0.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions bindings/docstrings/nvdsmetadoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace pydsdoc
constexpr const char* NVDS_GST_CUSTOM_META=R"pyds(metadata type to be set for metadata attached by nvidia gstreamer plugins before nvstreammux gstreamer plugin. It is set as user metadata inside :class:`NvDsFrameMeta`. NVIDIA specific gst meta are in the range from NVDS_GST_CUSTOM_META to NVDS_GST_CUSTOM_META + 4096)pyds";
constexpr const char* NVDS_START_USER_META=R"pyds(NVDS_START_USER_META)pyds";
constexpr const char* NVDS_FORCE32_META=R"pyds(NVDS_FORCE32_META)pyds";
constexpr const char* NVDS_PREPROCESS_BATCH_META=R"pyds(NVDS_PREPROCESS_BATCH_META)pyds";
}

namespace NvDsComp_BboxInfoDoc
Expand Down
36 changes: 36 additions & 0 deletions bindings/docstrings/nvdspreprocessmetadoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2022 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 nvdspreprocessmetadoc
{
namespace NvDsPreProcessTensorMetaDoc {
constexpr const char* descr = R"pyds(Metadata structure for preprocessed tensors.)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to NvDsPreProcessTensorMeta)pyds";
}

// Descriptions for GstNvDsPreProcessBatchMeta fields
namespace GstNvDsPreProcessBatchMetaDoc {
constexpr const char* descr = R"pyds(Batch metadata structure for preprocessing operations)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to GstNvDsPreProcessBatchMeta)pyds";
}
}
}

63 changes: 63 additions & 0 deletions bindings/docstrings/nvdsroimetadoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2022 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 NvDsRoiMetaDoc
{
namespace NvDsDataTypeDoc {
constexpr const char* descr = R"pyds(*Enumerator*. Specifies the type of meta data.)pyds";

constexpr const char* NvDsDataType_FP32=R"pyds(NvDsDataType_FP32)pyds";
constexpr const char* NvDsDataType_UINT8=R"pyds(NvDsDataType_UINT8)pyds";
constexpr const char* NvDsDataType_INT8=R"pyds(NvDsDataType_INT8)pyds";
constexpr const char* NvDsDataType_UINT32=R"pyds(NvDsDataType_UINT32)pyds";
constexpr const char* NvDsDataType_INT32=R"pyds(NvDsDataType_INT32)pyds";
constexpr const char* NvDsDataType_FP16=R"pyds(NvDsDataType_FP16)pyds";
}

namespace NvDsUnitTypeDoc {
constexpr const char* descr = R"pyds(*Enumerator*. Specifies the type of meta data.)pyds";

constexpr const char* NvDsUnitType_FullFrame=R"pyds(NvDsUnitType_FullFrame)pyds";
constexpr const char* NvDsUnitType_ROI=R"pyds(NvDsUnitType_ROI)pyds";
constexpr const char* NvDsUnitType_Object=R"pyds(NvDsUnitType_Object)pyds";
}

namespace NvDsRoiMetaDoc {
constexpr const char* descr = R"pyds(Batch metadata structure for roi operations)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to NvDsRoiMetaDoc)pyds";
}

namespace NvBufSurfaceParams {
constexpr const char* descr = R"pyds(Batch metadata structure for roi operations)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to NvBufSurfaceParams)pyds";
}

namespace NvDsFrameMeta {
constexpr const char* descr = R"pyds(Batch metadata structure for roi operations)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to NvDsFrameMeta)pyds";
}

namespace NvDsObjectMeta {
constexpr const char* descr = R"pyds(Batch metadata structure for roi operations)pyds";
constexpr const char* cast = R"pyds(Casts a pointer to NvDsObjectMeta)pyds";
}
}
}
8 changes: 8 additions & 0 deletions bindings/include/bind/bindnvds_roi_meta.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "../../docstrings/nvdsroimetadoc.h"
#include "pyds.hpp"

namespace py = pybind11;

namespace pydeepstream {
void bindnvds_roi_meta(py::module &m);
}
8 changes: 8 additions & 0 deletions bindings/include/bind/bindnvdspreprocess_meta.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "pyds.hpp" // Include this "base" header file for all other dependencies
#include "../docstrings/nvdspreprocessmetadoc.h" // include the header file for the docstrings of this submodule

namespace py = pybind11;

namespace pydeepstream {
void bindnvdspreprocess_meta(py::module &m); // Declare the bindings function for this submodule
}
11 changes: 11 additions & 0 deletions bindings/pyds.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Metadata-Version: 2.2
Name: pyds
Version: 1.2.0
Summary: Install precompiled DeepStream Python bindings extension
Home-page: nvidia.com
Author: NVIDIA
Requires-Python: >=3.10
Dynamic: author
Dynamic: home-page
Dynamic: requires-python
Dynamic: summary
103 changes: 103 additions & 0 deletions bindings/pyds.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
CMakeLists.txt
MANIFEST.in
README.md
pyproject.toml
setup.py
3rdparty/pybind11/CMakeLists.txt
3rdparty/pybind11/include/pybind11/attr.h
3rdparty/pybind11/include/pybind11/buffer_info.h
3rdparty/pybind11/include/pybind11/cast.h
3rdparty/pybind11/include/pybind11/chrono.h
3rdparty/pybind11/include/pybind11/common.h
3rdparty/pybind11/include/pybind11/complex.h
3rdparty/pybind11/include/pybind11/eigen.h
3rdparty/pybind11/include/pybind11/embed.h
3rdparty/pybind11/include/pybind11/eval.h
3rdparty/pybind11/include/pybind11/functional.h
3rdparty/pybind11/include/pybind11/gil.h
3rdparty/pybind11/include/pybind11/gil_safe_call_once.h
3rdparty/pybind11/include/pybind11/iostream.h
3rdparty/pybind11/include/pybind11/numpy.h
3rdparty/pybind11/include/pybind11/operators.h
3rdparty/pybind11/include/pybind11/options.h
3rdparty/pybind11/include/pybind11/pybind11.h
3rdparty/pybind11/include/pybind11/pytypes.h
3rdparty/pybind11/include/pybind11/stl.h
3rdparty/pybind11/include/pybind11/stl_bind.h
3rdparty/pybind11/include/pybind11/type_caster_pyobject_ptr.h
3rdparty/pybind11/include/pybind11/typing.h
3rdparty/pybind11/include/pybind11/detail/class.h
3rdparty/pybind11/include/pybind11/detail/common.h
3rdparty/pybind11/include/pybind11/detail/descr.h
3rdparty/pybind11/include/pybind11/detail/init.h
3rdparty/pybind11/include/pybind11/detail/internals.h
3rdparty/pybind11/include/pybind11/detail/type_caster_base.h
3rdparty/pybind11/include/pybind11/detail/typeid.h
3rdparty/pybind11/include/pybind11/eigen/common.h
3rdparty/pybind11/include/pybind11/eigen/matrix.h
3rdparty/pybind11/include/pybind11/eigen/tensor.h
3rdparty/pybind11/include/pybind11/stl/filesystem.h
3rdparty/pybind11/tests/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/installed_embed/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/installed_function/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/installed_target/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/subdirectory_function/CMakeLists.txt
3rdparty/pybind11/tests/test_cmake_build/subdirectory_target/CMakeLists.txt
3rdparty/pybind11/tests/test_embed/CMakeLists.txt
docstrings/analyticsmetadoc.h
docstrings/customdoc.h
docstrings/functionsdoc.h
docstrings/gstnvdsmetadoc.h
docstrings/meta360doc.h
docstrings/nvbufsurfacedoc.h
docstrings/nvdsinferdoc.h
docstrings/nvdsmetadoc.h
docstrings/nvdspreprocessmetadoc.h
docstrings/nvdsroimetadoc.h
docstrings/nvosddoc.h
docstrings/opticalflowdoc.h
docstrings/schemadoc.h
docstrings/trackermetadoc.h
docstrings/utilsdoc.h
include/pyds.hpp
include/utils.hpp
include/bind/bind_string_property_definitions.h
include/bind/bindanalyticsmeta.hpp
include/bind/bindfunctions.hpp
include/bind/bindgstnvdsmeta.hpp
include/bind/bindmeta360.hpp
include/bind/bindnvbufsurface.hpp
include/bind/bindnvds_roi_meta.hpp
include/bind/bindnvdsinfer.hpp
include/bind/bindnvdsmeta.hpp
include/bind/bindnvdspreprocess_meta.hpp
include/bind/bindnvosd.hpp
include/bind/bindopticalflow.hpp
include/bind/bindschema.hpp
include/bind/bindtrackermeta.hpp
include/nvds/nvds_360d_meta.h
pyds.egg-info/PKG-INFO
pyds.egg-info/SOURCES.txt
pyds.egg-info/dependency_links.txt
pyds.egg-info/not-zip-safe
pyds.egg-info/top_level.txt
src/bindanalyticsmeta.cpp
src/bindfunctions.cpp
src/bindgstnvdsmeta.cpp
src/bindmeta360.cpp
src/bindnvbufsurface.cpp
src/bindnvds_roi_meta.cpp
src/bindnvdsinfer.cpp
src/bindnvdsmeta.cpp
src/bindnvdspreprocess_meta.cpp
src/bindnvosd.cpp
src/bindopticalflow.cpp
src/bindschema.cpp
src/bindtrackermeta.cpp
src/pyds.cpp
src/utils.cpp
src/custom_binding/bindcustom.cpp
src/custom_binding/include/bindcustom.hpp
src/custom_binding/include/custom_data.hpp
1 change: 1 addition & 0 deletions bindings/pyds.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions bindings/pyds.egg-info/not-zip-safe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions bindings/pyds.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyds
59 changes: 59 additions & 0 deletions bindings/src/bindnvds_roi_meta.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// NvDsRoiMeta

#include "bind_string_property_definitions.h"
#include "bindnvds_roi_meta.hpp"
#include "nvdsmeta.h"

namespace py = pybind11;

namespace pydeepstream {
void bindnvds_roi_meta(py::module &m) {
py::enum_<NvDsDataType>(m, "NvDsDataType",
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::descr)
.value("NvDsDataType_FP32", NvDsDataType_FP32,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_FP32)
.value("NvDsDataType_UINT8", NvDsDataType_UINT8,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_UINT8)
.value("NvDsDataType_INT8", NvDsDataType_INT8,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_INT8)
.value("NvDsDataType_UINT32", NvDsDataType_UINT32,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_UINT32)
.value("NvDsDataType_INT32", NvDsDataType_INT32,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_INT32)
.value("NvDsDataType_FP16", NvDsDataType_FP16,
pydsdoc::NvDsRoiMetaDoc::NvDsDataTypeDoc::NvDsDataType_FP16)
.export_values();

py::enum_<NvDsUnitType>(m, "NvDsUnitType",
pydsdoc::NvDsRoiMetaDoc::NvDsUnitTypeDoc::descr)
.value("NvDsUnitType_FullFrame", NvDsUnitType_FullFrame,
pydsdoc::NvDsRoiMetaDoc::NvDsUnitTypeDoc::NvDsUnitType_FullFrame)
.value("NvDsUnitType_ROI", NvDsUnitType_ROI,
pydsdoc::NvDsRoiMetaDoc::NvDsUnitTypeDoc::NvDsUnitType_ROI)
.value("NvDsUnitType_Object", NvDsUnitType_Object,
pydsdoc::NvDsRoiMetaDoc::NvDsUnitTypeDoc::NvDsUnitType_Object)
.export_values();


py::class_<NvDsRoiMeta>(m, "NvDsRoiMeta",
pydsdoc::NvDsRoiMetaDoc::NvDsRoiMetaDoc::descr)
.def(py::init<>())
.def_readwrite("roi", &NvDsRoiMeta::roi)
.def_readwrite("converted_buffer", &NvDsRoiMeta::converted_buffer)
.def_readwrite("frame_meta", &NvDsRoiMeta::frame_meta)
.def_readwrite("scale_ratio_x", &NvDsRoiMeta::scale_ratio_x)
.def_readwrite("scale_ratio_y", &NvDsRoiMeta::scale_ratio_y)
.def_readwrite("offset_left", &NvDsRoiMeta::offset_left)
.def_readwrite("offset_top", &NvDsRoiMeta::offset_top)
.def_readwrite("classifier_meta_list", &NvDsRoiMeta::classifier_meta_list)
.def_readwrite("roi_user_meta_list", &NvDsRoiMeta::roi_user_meta_list)
.def_readwrite("object_meta", &NvDsRoiMeta::object_meta)

.def("cast",
[](void *data) {
return (NvDsRoiMeta *) data;
},
py::return_value_policy::reference,
pydsdoc::NvDsRoiMetaDoc::NvDsRoiMetaDoc::cast);
}
}
2 changes: 2 additions & 0 deletions bindings/src/bindnvdsmeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ namespace pydeepstream {
pydsdoc::nvmeta::MetaTypeDoc::NVDS_START_USER_META)
.value("NVDS_FORCE32_META", NVDS_FORCE32_META,
pydsdoc::nvmeta::MetaTypeDoc::NVDS_FORCE32_META)
.value("NVDS_PREPROCESS_BATCH_META", NVDS_PREPROCESS_BATCH_META,
pydsdoc::nvmeta::MetaTypeDoc::NVDS_PREPROCESS_BATCH_META)
.export_values();


Expand Down
Loading