Skip to content

Commit be3a20b

Browse files
authored
Merge pull request #204 from KelvinCPChiu/master
Added the Required Nvinfer Plugin and DeepStream Config File
2 parents deec3c5 + ac0a2de commit be3a20b

16 files changed

+2498
-3
lines changed

DeepStream/Readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1+
# This should be run in JetPack 4.4 / JetPack 4.4 G.A. with DeepStream 5.0 / DeepStream 5.0 GA .
12

3+
1. Compile the custom plugin for Yolo
4+
2. Convert the ONNX file to TRT with TRTEXEC / TensorRT
5+
3. Change the model-engine-file in config_infer_primary_yoloV4.txt
6+
4. In the deepstream_app_config_yoloV4.txt, change
7+
a) source0 : uri=file:<your file> directory.
8+
b) primary-gie : model-engine-file=<your_onnx_engine>
9+
# Note that for multi-batch, overhead is large owing to NMS is not used.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
################################################################################
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
23+
# Following properties are mandatory when engine files are not specified:
24+
# int8-calib-file(Only in INT8), model-file-format
25+
# Caffemodel mandatory properties: model-file, proto-file, output-blob-names
26+
# UFF: uff-file, input-dims, uff-input-blob-name, output-blob-names
27+
# ONNX: onnx-file
28+
#
29+
# Mandatory properties for detectors:
30+
# num-detected-classes
31+
#
32+
# Optional properties for detectors:
33+
# cluster-mode(Default=Group Rectangles), interval(Primary mode only, Default=0)
34+
# custom-lib-path
35+
# parse-bbox-func-name
36+
#
37+
# Mandatory properties for classifiers:
38+
# classifier-threshold, is-classifier
39+
#
40+
# Optional properties for classifiers:
41+
# classifier-async-mode(Secondary mode only, Default=false)
42+
#
43+
# Optional properties in secondary mode:
44+
# operate-on-gie-id(Default=0), operate-on-class-ids(Defaults to all classes),
45+
# input-object-min-width, input-object-min-height, input-object-max-width,
46+
# input-object-max-height
47+
#
48+
# Following properties are always recommended:
49+
# batch-size(Default=1)
50+
#
51+
# Other optional properties:
52+
# net-scale-factor(Default=1), network-mode(Default=0 i.e FP32),
53+
# model-color-format(Default=0 i.e. RGB) model-engine-file, labelfile-path,
54+
# mean-file, gie-unique-id(Default=0), offsets, process-mode (Default=1 i.e. primary),
55+
# custom-lib-path, network-mode(Default=0 i.e FP32)
56+
#
57+
# The values in the config file are overridden by values set through GObject
58+
# properties.
59+
60+
[property]
61+
gpu-id=0
62+
net-scale-factor=0.0039215697906911373
63+
#0=RGB, 1=BGR
64+
model-color-format=0
65+
model-engine-file=<onnx_engine_file>
66+
labelfile-path=labels.txt
67+
## 0=FP32, 1=INT8, 2=FP16 mode
68+
network-mode=2
69+
num-detected-classes=80
70+
gie-unique-id=1
71+
network-type=0
72+
is-classifier=0
73+
## 0=Group Rectangles, 1=DBSCAN, 2=NMS, 3= DBSCAN+NMS Hybrid, 4 = None(No clustering)
74+
cluster-mode=2
75+
maintain-aspect-ratio=1
76+
parse-bbox-func-name=NvDsInferParseCustomYoloV4
77+
custom-lib-path=nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so
78+
engine-create-func-name=NvDsInferYoloCudaEngineGet
79+
#scaling-filter=0
80+
#scaling-compute-hw=0
81+
#output-blob-names=2012
82+
83+
[class-attrs-all]
84+
nms-iou-threshold=0.2
85+
pre-cluster-threshold=0.4
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
################################################################################
2+
# Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
23+
[application]
24+
enable-perf-measurement=1
25+
perf-measurement-interval-sec=5
26+
#gie-kitti-output-dir=streamscl
27+
28+
[tiled-display]
29+
enable=0
30+
rows=1
31+
columns=1
32+
width=1280
33+
height=720
34+
gpu-id=0
35+
#(0): nvbuf-mem-default - Default memory allocated, specific to particular platform
36+
#(1): nvbuf-mem-cuda-pinned - Allocate Pinned/Host cuda memory, applicable for Tesla
37+
#(2): nvbuf-mem-cuda-device - Allocate Device cuda memory, applicable for Tesla
38+
#(3): nvbuf-mem-cuda-unified - Allocate Unified cuda memory, applicable for Tesla
39+
#(4): nvbuf-mem-surface-array - Allocate Surface Array memory, applicable for Jetson
40+
nvbuf-memory-type=0
41+
42+
[source0]
43+
enable=1
44+
#Type - 1=CameraV4L2 2=URI 3=MultiURI
45+
type=3
46+
uri=file:<Your_file_source>
47+
48+
num-sources=1
49+
gpu-id=0
50+
# (0): memtype_device - Memory type Device
51+
# (1): memtype_pinned - Memory type Host Pinned
52+
# (2): memtype_unified - Memory type Unified
53+
cudadec-memtype=0
54+
55+
[sink0]
56+
enable=1
57+
#Type - 1=FakeSink 2=EglSink 3=File
58+
type=2
59+
sync=1
60+
source-id=0
61+
gpu-id=0
62+
63+
[osd]
64+
enable=1
65+
gpu-id=0
66+
border-width=1
67+
text-size=12
68+
text-color=1;1;1;1;
69+
text-bg-color=0.3;0.3;0.3;1
70+
font=Serif
71+
show-clock=0
72+
clock-x-offset=800
73+
clock-y-offset=820
74+
clock-text-size=12
75+
clock-color=1;0;0;0
76+
nvbuf-memory-type=0
77+
78+
[streammux]
79+
gpu-id=0
80+
##Boolean property to inform muxer that sources are live
81+
live-source=0
82+
batch-size=1
83+
##time out in usec, to wait after the first buffer is available
84+
##to push the batch even if the complete batch is not formed
85+
batched-push-timeout=40000
86+
## Set muxer output width and height
87+
width=1280
88+
height=720
89+
##Enable to maintain aspect ratio wrt source, and allow black borders, works
90+
##along with width, height properties
91+
enable-padding=0
92+
nvbuf-memory-type=0
93+
94+
# config-file property is mandatory for any gie section.
95+
# Other properties are optional and if set will override the properties set in
96+
# the infer config file.
97+
[primary-gie]
98+
enable=1
99+
gpu-id=0
100+
model-engine-file=<onnx_engine_file>
101+
labelfile-path=labels.txt
102+
#batch-size=1
103+
#Required by the app for OSD, not a plugin property
104+
bbox-border-color0=1;0;0;1
105+
bbox-border-color1=0;1;1;1
106+
bbox-border-color2=0;0;1;1
107+
bbox-border-color3=0;1;0;1
108+
interval=0
109+
gie-unique-id=1
110+
nvbuf-memory-type=0
111+
config-file=config_infer_primary_yoloV4.txt
112+
113+
[sink1]
114+
enable=1
115+
type=3
116+
#1=mp4 2=mkv
117+
container=1
118+
#1=h264 2=h265 3=mpeg4
119+
codec=1
120+
#encoder type 0=Hardware 1=Software
121+
enc-type=0
122+
sync=0
123+
bitrate=4000000
124+
#H264 Profile - 0=Baseline 2=Main 4=High
125+
#H265 Profile - 0=Main 1=Main10
126+
profile=0
127+
output-file=fp16_clip1_cam1.mp4
128+
source-id=0
129+
130+
[tracker]
131+
enable=1
132+
# For the case of NvDCF tracker, tracker-width and tracker-height must be a multiple of 32, respectively
133+
tracker-width=608
134+
tracker-height=608
135+
#ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_mot_iou.so
136+
#ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_nvdcf.so
137+
ll-lib-file=/opt/nvidia/deepstream/deepstream-5.0/lib/libnvds_mot_klt.so
138+
#ll-config-file required for IOU only
139+
#ll-config-file=iou_config.txt
140+
gpu-id=0
141+
142+
[tests]
143+
file-loop=0

DeepStream/labels.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
person
2+
bicycle
3+
car
4+
motorcycle
5+
airplane
6+
bus
7+
train
8+
truck
9+
boat
10+
traffic light
11+
fire hydrant
12+
stop sign
13+
parking meter
14+
bench
15+
bird
16+
cat
17+
dog
18+
horse
19+
sheep
20+
cow
21+
elephant
22+
bear
23+
zebra
24+
giraffe
25+
backpack
26+
umbrella
27+
handbag
28+
tie
29+
suitcase
30+
frisbee
31+
skis
32+
snowboard
33+
sports ball
34+
kite
35+
baseball bat
36+
baseball glove
37+
skateboard
38+
surfboard
39+
tennis racket
40+
bottle
41+
wine glass
42+
cup
43+
fork
44+
knife
45+
spoon
46+
bowl
47+
banana
48+
apple
49+
sandwich
50+
orange
51+
broccoli
52+
carrot
53+
hot dog
54+
pizza
55+
donut
56+
cake
57+
chair
58+
couch
59+
potted plant
60+
bed
61+
dining table
62+
toilet
63+
tv
64+
laptop
65+
mouse
66+
remote
67+
keyboard
68+
cell phone
69+
microwave
70+
oven
71+
toaster
72+
sink
73+
refrigerator
74+
book
75+
clock
76+
vase
77+
scissors
78+
teddy bear
79+
hair drier
80+
toothbrush
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
################################################################################
2+
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a
5+
# copy of this software and associated documentation files (the "Software"),
6+
# to deal in the Software without restriction, including without limitation
7+
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
8+
# and/or sell copies of the Software, and to permit persons to whom the
9+
# Software is furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in
12+
# all copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19+
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20+
# DEALINGS IN THE SOFTWARE.
21+
################################################################################
22+
23+
CUDA_VER?=
24+
ifeq ($(CUDA_VER),)
25+
$(error "CUDA_VER is not set")
26+
endif
27+
CC:= g++
28+
NVCC:=/usr/local/cuda-$(CUDA_VER)/bin/nvcc
29+
30+
CFLAGS:= -Wall -std=c++11 -shared -fPIC -Wno-error=deprecated-declarations
31+
CFLAGS+= -I../../includes -I/usr/local/cuda-$(CUDA_VER)/include
32+
33+
LIBS:= -lnvinfer_plugin -lnvinfer -lnvparsers -L/usr/local/cuda-$(CUDA_VER)/lib64 -lcudart -lcublas -lstdc++fs
34+
LFLAGS:= -shared -Wl,--start-group $(LIBS) -Wl,--end-group
35+
36+
INCS:= $(wildcard *.h)
37+
SRCFILES:= nvdsinfer_yolo_engine.cpp \
38+
nvdsparsebbox_Yolo.cpp \
39+
yoloPlugins.cpp \
40+
trt_utils.cpp \
41+
yolo.cpp \
42+
kernels.cu
43+
TARGET_LIB:= libnvdsinfer_custom_impl_Yolo.so
44+
45+
TARGET_OBJS:= $(SRCFILES:.cpp=.o)
46+
TARGET_OBJS:= $(TARGET_OBJS:.cu=.o)
47+
48+
all: $(TARGET_LIB)
49+
50+
%.o: %.cpp $(INCS) Makefile
51+
$(CC) -c -o $@ $(CFLAGS) $<
52+
53+
%.o: %.cu $(INCS) Makefile
54+
$(NVCC) -c -o $@ --compiler-options '-fPIC' $<
55+
56+
$(TARGET_LIB) : $(TARGET_OBJS)
57+
$(CC) -o $@ $(TARGET_OBJS) $(LFLAGS)
58+
59+
clean:
60+
rm -rf $(TARGET_LIB)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export CUDA_VER=X.Y
2+
make

0 commit comments

Comments
 (0)