Skip to content

Commit

Permalink
Update to 1.1.2 release
Browse files Browse the repository at this point in the history
This release is compatible with DeepStream SDK 6.1

Ubuntu 20.04
Python 3.8
DeepStream SDK 6.1

Features:
- New Preprocess test app which demonstrates using nvdspreprocess plugin with custom ROIs
- Enhanced Test3 to support Triton, no-display mode, file-loop, and silent mode
- Minor improvements and bug fixes
  • Loading branch information
nv-rpaliwal committed May 19, 2022
1 parent 31d1d1a commit e4da85d
Show file tree
Hide file tree
Showing 55 changed files with 1,508 additions and 293 deletions.
14 changes: 7 additions & 7 deletions HOWTO.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ This guide provides resources for DeepStream application development in Python.
<a name="prereqs"></a>
## Prerequisites

* Ubuntu 18.04
* [DeepStream SDK 6.0.1](https://developer.nvidia.com/deepstream-download) or later
* Python 3.6+
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.14.5
* Ubuntu 20.04
* [DeepStream SDK 6.1](https://developer.nvidia.com/deepstream-download) or later
* Python 3.8
* [Gst Python](https://gstreamer.freedesktop.org/modules/gst-python.html) v1.16.2

Gst python should be already installed on Jetson.
If missing, install with the following steps:
Expand All @@ -28,7 +28,7 @@ If missing, install with the following steps:
$ export GST_CFLAGS="-pthread -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include"
$ git clone https://github.com/GStreamer/gst-python.git
$ cd gst-python
$ git checkout 1a8f48a
$ git checkout 5343aeb
$ ./autogen.sh PYTHON=python3
$ ./configure PYTHON=python3
$ make
Expand All @@ -45,11 +45,11 @@ Note: Compiling bindings now also generates a pip installable python wheel for t
<a name="run_samples"></a>
## Running Sample Applications

Clone the deepstream_python_apps repo under <DeepStream 6.0.1 ROOT>/sources:
Clone the deepstream_python_apps repo under <DeepStream 6.1 ROOT>/sources:
git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps

This will create the following directory:
```<DeepStream 6.0.1 ROOT>/sources/deepstream_python_apps```
```<DeepStream 6.1 ROOT>/sources/deepstream_python_apps```

The Python apps are under the "apps" directory.
Go into each app directory and follow instructions in the README.
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

This repository contains Python bindings and sample applications for the [DeepStream SDK](https://developer.nvidia.com/deepstream-sdk).

SDK version supported: 6.0.1
SDK version supported: 6.1

<b>NEW: The bindings sources along with build instructions are now available under [bindings](bindings)! </b>
<b>The bindings sources along with build instructions are now available under [bindings](bindings)! </b>

<b>This release comes with Operating System upgrades (from Ubuntu 18.04 to Ubuntu 20.04) for DeepStreamSDK 6.1 support. This translates to upgrade in Python version to 3.8 and [gst-python](3rdparty/gst-python/) version has also been upgraded to 1.16.2 !</b>

Download the latest release package complete with bindings and sample applications from the [release section](../../releases).

Expand Down Expand Up @@ -41,7 +43,7 @@ To run the sample applications or write your own, please consult the [HOW-TO Gui
We currently provide the following sample applications:
* [deepstream-test1](apps/deepstream-test1) -- 4-class object detection pipeline
* [deepstream-test2](apps/deepstream-test2) -- 4-class object detection, tracking and attribute classification pipeline
* [deepstream-test3](apps/deepstream-test3) -- multi-stream pipeline performing 4-class object detection
* <b>UPDATE</b> [deepstream-test3](apps/deepstream-test3) -- multi-stream pipeline performing 4-class object detection - now also supports triton inference server, no-display mode, file-loop and silent mode
* [deepstream-test4](apps/deepstream-test4) -- msgbroker for sending analytics results to the cloud
* [deepstream-imagedata-multistream](apps/deepstream-imagedata-multistream) -- multi-stream pipeline with access to image buffers
* [deepstream-ssd-parser](apps/deepstream-ssd-parser) -- SSD model inference via Triton server with output parsing in Python
Expand All @@ -53,6 +55,7 @@ We currently provide the following sample applications:
* [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
* [deepstream-rtsp-in-rtsp-out](apps/deepstream-rtsp-in-rtsp-out) -- multi-stream pipeline with RTSP input/output
* <b>NEW</b> [deepstream-preprocess-test](apps/deepstream-preprocess-test) -- multi-stream pipeline using nvdspreprocess plugin with custom ROIs


Detailed application information is provided in each application's subdirectory under [apps](apps).
Expand Down
32 changes: 13 additions & 19 deletions apps/README
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,46 @@
DeepStream SDK Python Bindings
================================================================================
Setup pre-requisites:
- Ubuntu 18.04
- NVIDIA DeepStream SDK 6.0.1
- Python 3.6
- Ubuntu 20.04
- NVIDIA DeepStream SDK 6.1
- Python 3.8
- Gst-python

--------------------------------------------------------------------------------
Package Contents
--------------------------------------------------------------------------------
The DeepStream Python package includes:
1. Python bindings for DeepStream Metadata libraries
These bindings are installed as part of the SDK at:
/opt/nvidia/deepstream/deepstream/lib/pyds.so

Sample applications that import is_aarch_64 automatically
have this path added.
1. DeepStream Python bindings located in bindings dir
with installation instructions in bindings/README.md

A setup.py is also provided to install this extension into standard path.
Currently this needs to be run manually:
$ cd /opt/nvidia/deepstream/deepstream/lib
$ python3 setup.py install

2. DeepStream test apps in Python
The following test apps are available:
deepstream-test1
deepstream-test2
deepstream-test3
deepstream-test4
deepstream-imagedata-multistream
deepstream-imagedata-multistream-redaction
deepstream-ssd-parser
deepstream-test1-rtsp-out
deepstream-rtsp-in-rtsp-out
deepstream-test1-usbcam
deepstream-opticalflow
deepstream-segmentation
deepstream-nvdsanalytics
deepstream-preprocess-test
runtime_source_add_delete

--------------------------------------------------------------------------------
Installing Pre-requisites:
--------------------------------------------------------------------------------

DeepStream SDK 6.0.1
DeepStream SDK 6.1
--------------------
Download and install from https://developer.nvidia.com/deepstream-download

Python 3.6
Python 3.8
----------
Should be already installed with Ubuntu 18.04
Should be already installed with Ubuntu 20.04

Gst-python
----------
Expand All @@ -76,7 +70,7 @@ $ sudo apt install python3-gi python3-dev python3-gst-1.0 -y
--------------------------------------------------------------------------------
Running the samples
--------------------------------------------------------------------------------
The apps are configured to work from inside the DeepStream SDK 6.0.1 installation.
The apps are configured to work from inside the DeepStream SDK 6.1 installation.

Clone the deepstream_python_apps repo under <DeepStream ROOT>/sources:
$ git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps
Expand Down
50 changes: 36 additions & 14 deletions apps/common/FPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,52 @@
################################################################################

import time
from threading import Lock
start_time=time.time()
frame_count=0

fps_mutex = Lock()

class GETFPS:
def __init__(self,stream_id):
global start_time
self.start_time=start_time
self.is_first=True
global frame_count
self.frame_count=frame_count
self.frame_count=0
self.stream_id=stream_id
def get_fps(self):
end_time=time.time()
if(self.is_first):
self.start_time=end_time
self.is_first=False
if(end_time-self.start_time>5):
print("**********************FPS*****************************************")
print("Fps of stream",self.stream_id,"is ", float(self.frame_count)/5.0)
self.frame_count=0
self.start_time=end_time

def update_fps(self):
end_time = time.time()
if self.is_first:
self.start_time = end_time
self.is_first = False
else:
self.frame_count=self.frame_count+1
global fps_mutex
with fps_mutex:
self.frame_count = self.frame_count + 1

def get_fps(self):
end_time = time.time()
with fps_mutex:
stream_fps = float(self.frame_count/(end_time - self.start_time))
self.frame_count = 0
self.start_time = end_time
return round(stream_fps, 2)

def print_data(self):
print('frame_count=',self.frame_count)
print('start_time=',self.start_time)

class PERF_DATA:
def __init__(self, num_streams=1):
self.perf_dict = {}
self.all_stream_fps = {}
for i in range(num_streams):
self.all_stream_fps["stream{0}".format(i)]=GETFPS(i)

def perf_print_callback(self):
self.perf_dict = {stream_index:stream.get_fps() for (stream_index, stream) in self.all_stream_fps.items()}
print ("\n**PERF: ", self.perf_dict, "\n")
return True

def update_fps(self, stream_index):
self.all_stream_fps[stream_index].update_fps()
2 changes: 1 addition & 1 deletion apps/common/bus_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import gi
import sys
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst
from gi.repository import Gst
def bus_call(bus, message, loop):
t = message.type
if t == Gst.MessageType.EOS:
Expand Down
10 changes: 4 additions & 6 deletions apps/deepstream-imagedata-multistream-redaction/README
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
################################################################################

Prerequisites:
- DeepStreamSDK 6.0.1
- Python 3.6
- DeepStreamSDK 6.1
- Python 3.8
- Gst-python
- NumPy package
- OpenCV package
Expand All @@ -39,10 +39,8 @@ Yet, we need to install the introspection typelib package:
$ sudo apt-get install gobject-introspection gir1.2-gst-rtsp-server-1.0

Download Peoplenet model:
$ cd /opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models
$ mkdir -p ../../models/tao_pretrained_models/peoplenet && wget https://api.ngc.nvidia.com/v2/models/nvidia/tao/peoplenet/versions/pruned_v2.1/files/resnet34_peoplenet_pruned.etlt \
-O ../../models/tao_pretrained_models/peoplenet/resnet34_peoplenet_pruned.etlt
$ wget https://api.ngc.nvidia.com/v2/models/nvidia/tao/peoplenet/versions/pruned_v2.1/files/labels.txt -O ../../../configs/tao_pretrained_models/labels_peoplenet.txt
Please follow instructions from the README.md located at : /opt/nvidia/deepstream/deepstream/samples/configs/tao_pretrained_models/README.md
to download latest supported peoplenet model (V2.5 for this release)

To run:
$ python3 deepstream_imagedata-multistream_redaction.py -i <uri1> [uri2] ... [uriN] -c {H264,H265} -b BITRATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
gpu-id=0
net-scale-factor=0.0039215697906911373
tlt-model-key=tlt_encode
tlt-encoded-model=../../../../samples/models/tao_pretrained_models/peoplenet/resnet34_peoplenet_pruned.etlt
labelfile-path=../../../../samples/configs/tao_pretrained_models/labels_peoplenet.txt
model-engine-file=../../../../samples/models/tao_pretrained_models/peoplenet/resnet34_peoplenet_pruned.etlt_b1_gpu0_fp16.engine
tlt-encoded-model=../../../../samples/models/tao_pretrained_models/peopleNet/V2.5/resnet34_peoplenet_int8.etlt
labelfile-path=../../../../samples/models/tao_pretrained_models/peopleNet/V2.5/labels.txt
model-engine-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.5/resnet34_peoplenet_int8.etlt_b1_gpu0_int8.engine
int8-calib-file=../../../../samples/models/tao_pretrained_models/peopleNet/V2.5/resnet34_peoplenet_int8.txt
input-dims=3;544;960;0
uff-input-blob-name=input_1
batch-size=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import GObject, Gst, GstRtspServer
from gi.repository import GLib
from gi.repository import GLib, Gst, GstRtspServer
from ctypes import *
import time
import sys
Expand All @@ -36,15 +35,15 @@
from common.is_aarch_64 import is_aarch64
from common.bus_call import bus_call

from common.FPS import GETFPS
from common.FPS import PERF_DATA
import numpy as np
import pyds
import cv2
import os
import os.path
from os import path

fps_streams = {}
perf_data = None
frame_count = {}
saved_count = {}
global PGIE_CLASS_ID_PERSON
Expand Down Expand Up @@ -152,8 +151,10 @@ def tiler_sink_pad_buffer_probe(pad, info, u_data):

print("Frame Number=", frame_number, "Number of Objects=", num_rects, "Face_count=",
obj_counter[PGIE_CLASS_ID_FACE], "Person_count=", obj_counter[PGIE_CLASS_ID_PERSON])
# Get frame rate through this probe
fps_streams["stream{0}".format(frame_meta.pad_index)].get_fps()
# Update frame rate through this probe
stream_index = "stream{0}".format(frame_meta.pad_index)
global perf_data
perf_data.update_fps(stream_index)
if save_image:
img_path = "{}/stream_{}/frame_{}.jpg".format(folder_name, frame_meta.pad_index, frame_number)
cv2.imwrite(img_path, frame_copy)
Expand Down Expand Up @@ -247,12 +248,11 @@ def create_source_bin(index, uri):
return None
return nbin


def main(uri_inputs,codec,bitrate ):
# Check input arguments
number_sources = len(uri_inputs)
for i in range(0, number_sources ):
fps_streams["stream{0}".format(i)] = GETFPS(i)
global perf_data
perf_data = PERF_DATA(number_sources)

global folder_name
folder_name = "out_crops"
Expand All @@ -264,7 +264,6 @@ def main(uri_inputs,codec,bitrate ):
os.mkdir(folder_name)
print("Frames will be saved in ", folder_name)
# Standard GStreamer initialization
GObject.threads_init()
Gst.init(None)

# Create gstreamer elements */
Expand Down Expand Up @@ -352,7 +351,7 @@ def main(uri_inputs,codec,bitrate ):
if is_aarch64():
encoder.set_property('preset-level', 1)
encoder.set_property('insert-sps-pps', 1)
encoder.set_property('bufapi-version', 1)
#encoder.set_property('bufapi-version', 1)

# Make the payload-encode video into RTP packets
if codec == "H264":
Expand Down Expand Up @@ -430,7 +429,7 @@ def main(uri_inputs,codec,bitrate ):
rtppay.link(sink)

# create an event loop and feed gstreamer bus mesages to it
loop = GObject.MainLoop()
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
Expand All @@ -454,6 +453,8 @@ def main(uri_inputs,codec,bitrate ):
sys.stderr.write(" Unable to get sink pad \n")
else:
tiler_sink_pad.add_probe(Gst.PadProbeType.BUFFER, tiler_sink_pad_buffer_probe, 0)
# perf callback function to print fps every 5 sec
GLib.timeout_add(5000, perf_data.perf_print_callback)


print("Starting pipeline \n")
Expand Down
4 changes: 2 additions & 2 deletions apps/deepstream-imagedata-multistream/README
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
################################################################################

Prerequisites:
- DeepStreamSDK 6.0.1
- Python 3.6
- DeepStreamSDK 6.1
- Python 3.8
- Gst-python
- NumPy package
- OpenCV package
Expand Down
Loading

0 comments on commit e4da85d

Please sign in to comment.