Deepstrem 5.0 Python yolo

• Jetson Nano
• DeepStream5.0
• JetPack 4.4
• TensorRT 7.1.0.16

Hello everyone
How can I use the yoloV3 model in deepstream_python_apps,
I have been in “deepstream-app -c deepstream_app_config_yoloV3_tiny.txt” is successful

you can modify the python/apps/deepstream-test1/dstest1_pgie_config.txt to use YoloV3 model , and run with deepstream_test_1.py

Blockquote[property]
gpu-id=0
net-scale-factor=0.0039215697906911373
model-file=…/…/…/…/samples/models/Primary_Detector/resnet10.caffemodel
proto-file=…/…/…/…/samples/models/Primary_Detector/resnet10.prototxt
model-engine-file=…/…/…/…/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
labelfile-path=…/…/…/…/samples/models/Primary_Detector/labels.txt
int8-calib-file=…/…/…/…/samples/models/Primary_Detector/cal_trt.bin
batch-size=1
network-mode=1
num-detected-classes=4
interval=0
gie-unique-id=1
output-blob-names=conv2d_bbox;conv2d_cov/Sigmoid

Blockquote
I need to modify these configurations, right?(model-file、proto-file、model-engine-file)
How to operate yoloV3 cfg and weights files

# cd  /opt/nvidia/deepstream/deepstream-5.0/sources/python/apps/deepstream-test1/
# cp ../../../objectDetector_Yolo/config_infer_primary_yoloV3_tiny.txt   dstest1_pgie_config.txt
# cp ../../../objectDetector_Yolo/yolov3-tiny.cfg ./
# cp ../../../objectDetector_Yolo/yolov3-tiny.weights  ./
# mkdir  nvdsinfer_custom_impl_Yolo
# cp ../../../objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so ./nvdsinfer_custom_impl_Yolo/
# cp ../../../objectDetector_Yolo/labels.txt ./
# python deepstream_test_1.py ../../../../samples/streams/sample_720p.h264

Blockquotepython deepstream_test_1.py …/…/…/…/samples/streams/sample_720p.h264
Creating Pipeline

Creating Source

Creating H264Parser

Creating Decoder

Creating EGLSink

Playing file …/…/…/…/samples/streams/sample_720p.h264
Warn: ‘threshold’ parameter has been deprecated. Use ‘pre-cluster-threshold’ instead.
Adding elements to Pipeline

Linking elements in the Pipeline

Starting pipeline

Using winsys: x11
Opening in BLOCKING MODE
0:00:01.287811562 29336 0x10ba9860 INFO nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1591> [UID = 1]: Trying to create engine from model files
WARNING: INT8 not supported by platform. Trying FP16 mode.
Loading pre-trained weights…
Loading weights of yolov3 complete!
Total Number of weights read : 61587112
Loading pre-trained weights…
Loading weights of yolov3 complete!
Total Number of weights read : 61587112
Building Yolo network…
layer inp_size out_size weightPtr
(0) conv-bn-leaky 3 x 512 x 512 32 x 512 x 512 992
(1) conv-bn-leaky 32 x 512 x 512 64 x 256 x 256 19680
(2) conv-bn-leaky 64 x 256 x 256 32 x 256 x 256 21856


(82) yolo 24 x 16 x 16 24 x 16 x 16 56392312
(83) route - 512 x 16 x 16 56392312
(84) conv-bn-leaky 512 x 16 x 16 256 x 16 x 16 56524408
INFO: [TRT]: mm1_85: broadcasting input0 to make tensors conform, dims(input0)=[1,32,16][NONE] dims(input1)=[256,16,16][NONE].
INFO: [TRT]: mm2_85: broadcasting input1 to make tensors conform, dims(input0)=[256,32,16][NONE] dims(input1)=[1,16,32][NONE].
(85) upsample 256 x 16 x 16 256 x 32 x 32 -
(86) route - 768 x 32 x 32 56524408
(87) conv-bn-leaky 768 x 32 x 32 256 x 32 x 32 56722040
(88) conv-bn-leaky 256 x 32 x 32 512 x 32 x 32 57903736


(105) conv-linear 256 x 64 x 64 24 x 64 x 64 61587112
(106) yolo 24 x 64 x 64 24 x 64 x 64 61587112
Output yolo blob names :
yolo_83
yolo_95
yolo_107
Total number of yolo layers: 257
Building yolo network complete!
Building the TensorRT Engine…
INFO: [TRT]: mm1_85: broadcasting input0 to make tensors conform, dims(input0)=[1,32,16][NONE] dims(input1)=[256,16,16][NONE].
INFO: [TRT]: mm2_85: broadcasting input1 to make tensors conform, dims(input0)=[256,32,16][NONE] dims(input1)=[1,16,32][NONE].
INFO: [TRT]: mm1_97: broadcasting input0 to make tensors conform, dims(input0)=[1,64,32][NONE] dims(input1)=[128,32,32][NONE].
INFO: [TRT]: mm2_97: broadcasting input1 to make tensors conform, dims(input0)=[128,64,32][NONE] dims(input1)=[1,32,64][NONE].
INFO: [TRT]: Some tactics do not have sufficient workspace memory to run. Increasing workspace size may increase performance, please check verbose output.
INFO: [TRT]: Detected 1 inputs and 3 output network tensors.
Building complete!
0:12:04.697368317 29336 0x10ba9860 INFO nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1624> [UID = 1]: serialize cuda engine to file: /opt/nvidia/deepstream/deepstream-5.0/sources/python/apps/deepstream-test1/model_b1_gpu0_fp16.engine successfully
INFO: [Implicit Engine Info]: layers num: 4
0 INPUT kFLOAT data 3x512x512
1 OUTPUT kFLOAT yolo_83 24x16x16
2 OUTPUT kFLOAT yolo_95 24x32x32
3 OUTPUT kFLOAT yolo_107 24x64x64

0:12:11.237900398 29336 0x10ba9860 INFO nvinfer gstnvinfer_impl.cpp:311:notifyLoadModelStatus: [UID 1]: Load new model:/opt/nvidia/deepstream/deepstream/sources/objectDetector_Yolo/config_infer_primary_yoloV3.txt sucessfully
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Segmentation fault (core dumped)

This is a log, there is no video window, what is the problem

did you try my steps? If not, can you elabrfate your op steps?

My fault, the yolov3-tiny model ran successfully, thank you,
But yolov3-tiny is not accurate enough, I want to use yolov3,
When I run the yolov3 model, I get a warning “low memory”,
Automatically killed the process

0:09:06.427075729 381 0x1809c260 INFO nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1624> [UID = 1]: serialize cuda engine to file: /opt/nvidia/deepstream/deepstream-5.0/sources/python/apps/deepstream-test1/model_b1_gpu0_fp16.engine successfully
INFO: [Implicit Engine Info]: layers num: 4
0 INPUT kFLOAT data 3x512x512
1 OUTPUT kFLOAT yolo_83 24x16x16
2 OUTPUT kFLOAT yolo_95 24x32x32
3 OUTPUT kFLOAT yolo_107 24x64x64

0:09:07.751888280 381 0x1809c260 INFO nvinfer gstnvinfer_impl.cpp:311:notifyLoadModelStatus: [UID 1]: Load new model:dstest1_pgie_config.txt sucessfully
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
[1] Killed python deepstream_test_1.py …/…/…/…/samples/streams/sample_720p.h264
Segmentation fault (core dumped)

could you share the “dmesg” kernel log after failure?

Thanks!

I use a custom yolov3 model, prompting the following information

[ 9295.546565] active_anon:179897 inactive_anon:78410 isolated_anon:59
active_file:10203 inactive_file:8591 isolated_file:0
unevictable:3011 dirty:3 writeback:21944 unstable:0
slab_reclaimable:9836 slab_unreclaimable:21453
mapped:10133 shmem:232 pagetables:5749 bounce:0
free:16901 free_pcp:95 free_cma:3153
[ 9295.546575] Node 0 active_anon:719588kB inactive_anon:313640kB active_file:40812kB inactive_file:34364kB unevictable:12044kB isolated(anon):236kB isolated(file):0kB mapped:40532kB dirty:12kB writeback:87776kB shmem:928kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 55296kB writeback_tmp:0kB unstable:0kB pages_scanned:125 all_unreclaimable? no
[ 9295.546586] DMA free:44076kB min:22636kB low:28292kB high:33948kB active_anon:402676kB inactive_anon:185260kB active_file:31944kB inactive_file:25176kB unevictable:0kB writepending:73636kB present:2076672kB managed:2042608kB mlocked:0kB slab_reclaimable:3536kB slab_unreclaimable:10224kB kernel_stack:384kB pagetables:4940kB bounce:0kB free_pcp:380kB local_pcp:0kB free_cma:12612kB
[ 9295.546589] lowmem_reserve: 0 1961 1961 1961
[ 9295.546611] Normal free:23528kB min:22416kB low:28020kB high:33624kB active_anon:316912kB inactive_anon:128432kB active_file:8868kB inactive_file:9188kB unevictable:12044kB writepending:14152kB present:2082816kB managed:2008608kB mlocked:16kB slab_reclaimable:35808kB slab_unreclaimable:75588kB kernel_stack:10016kB pagetables:18056kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[ 9295.546614] lowmem_reserve: 0 0 0 0
[ 9295.546628] DMA: 22524kB (UMC) 8798kB (UMEC) 32116kB (UMC) 8532kB (UMC) 5464kB (UMC) 42128kB (UM) 37256kB (UM) 4512kB (UM) 01024kB 02048kB 04096kB = 44248kB
[ 9295.546681] Normal: 3121
4kB (UME) 11018kB (UME) 8516kB (UMH) 232kB (H) 864kB (UH) 2128kB (H) 1256kB (H) 0512kB 01024kB 02048kB 04096kB = 23740kB
[ 9295.546734] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
[ 9295.546737] 50459 total pagecache pages
[ 9295.546741] 28425 pages in swap cache
[ 9295.546746] Swap cache stats: add 1300087, delete 1271908, find 522768/583998
[ 9295.546749] Free swap = 3793412kB
[ 9295.546751] Total swap = 6219900kB
[ 9295.546755] 1039872 pages RAM
[ 9295.546758] 0 pages HighMem/MovableOnly
[ 9295.546760] 27068 pages reserved
[ 9295.546763] 118784 pages cma reserved
[ 9980.986203] nvmap_alloc_handle: PID 22271: python: WARNING: All NvMap Allocations must have a tag to identify the subsystem allocating memory.Please pass the tag to the API call NvRmMemHanldeAllocAttr() or relevant.

The memory is full and stopped at the following location

INFO: [TRT]: Some tactics do not have sufficient workspace memory to run. Increasing workspace size may increase performance, please check verbose output.
INFO: [TRT]: Detected 1 inputs and 3 output network tensors.
Building complete!
0:12:44.884436688 22271 0x251e4060 INFO nvinfer gstnvinfer.cpp:602:gst_nvinfer_logger: NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::buildModel() <nvdsinfer_context_impl.cpp:1624> [UID = 1]: serialize cuda engine to file: /opt/nvidia/deepstream/deepstream-5.0/sources/python/apps/deepstream-test1/model_b1_gpu0_fp16.engine successfully
INFO: [Implicit Engine Info]: layers num: 4
0 INPUT kFLOAT data 3x512x512
1 OUTPUT kFLOAT yolo_83 24x16x16
2 OUTPUT kFLOAT yolo_95 24x32x32
3 OUTPUT kFLOAT yolo_107 24x64x64
0:12:54.695244132 22271 0x251e4060 INFO nvinfer gstnvinfer_impl.cpp:311:notifyLoadModelStatus: [UID 1]: Load new model:dstest1_pgie_config.txt sucessfully
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261

could you share all the difference?

I just tried yolov3 on NANO, it works well.

It is due to the abnormality caused by the video file. I used deepstream-test3 to run mp4 successfully, thanks

Good to know, thanks!

I am trying to get YOLO v3 to run with Python examples’
I need the Python mets data to interface with another program
I am using a mp4 file so I am using the deepstream-test3 example on my Xavier NX
I have done this:
cd /opt/nvidia/deepstream/deepstream-5.0/sources/python/apps/deepstream-test3/
cp …/…/…/objectDetector_Yolo/config_infer_primary_yoloV3.txt dstest3_pgie_config.txt
cp …/…/…/objectDetector_Yolo/yolov.cfg ./
cp …/…/…/objectDetector_Yolo/yolov.weights ./
mkdir nvdsinfer_custom_impl_Yolo
cp …/…/…/objectDetector_Yolo/nvdsinfer_custom_impl_Yolo/libnvdsinfer_custom_impl_Yolo.so ./nvdsinfer_custom_impl_Yolo/
cp …/…/…/objectDetector_Yolo/labels.txt ./
python deepstream_test_1.py …/…/…/…/samples/streams/bird1.mp4

When I run this:
python3 deepstream_test_3.py file:///opt/nvidia/deepstream/deepstream-5.0/samples/streams/bird1.mp4
it runs at 4 fps

When I run this:
deepstream-app -c deepstream_app_config_yoloV3.txt
it runs at 60 fps

How do I modify the :
python3 deepstream_test_3.py
To get it to run at least 30fps

1 Like

Hi adventuredaisy,

Please help to open a new topic for your issue. Thanks

have you resolved this or opened a new thread about it? thank you

Yes
I used MQTT to do it