레이블이 Object Tracking인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Object Tracking인 게시물을 표시합니다. 모든 게시물 표시

2020년 8월 12일 수요일

Xavier NX-DeepStream 5.0 #3 - Run Python Samples (test2)

 

 Prerequisites

I use python virtual environment in Xavier NX. Also, Tensorflow and PyTorch, which are frequently used frameworks, have been installed in the virtual environment in advance. Please proceed with the above process in advance and then follow the instructions below. And I installed DeepStream 5.0 and Python examples from my previous blog.

 In my previous blog, I explained an example of finding vehicles, bicycles, people, and roadsigns by analyzing streams from video or webcams in real time using DeepStream 5.0 and Python. This example will look at the second example apps/deepstream-test2. This example uses the same model as the previous blog.

 

Example 2

 The second example code is in deepstream_python_apps/apps/ deepstream-test2.

(python) spypiggy@XavierNX:~/src/deepstream_python_apps/apps/deepstream-test2$ ls -al
total 64
drwxrwxr-x  2 spypiggy spypiggy  4096 Aug  9 09:32 .
drwxrwxr-x 11 spypiggy spypiggy  4096 Aug  6 06:57 ..
-rw-rw-r--  1 spypiggy spypiggy 12296 Aug  9 09:32 deepstream_test_2.py
-rw-rw-r--  1 spypiggy spypiggy  3841 Aug  9 09:16 dstest2_pgie_config.txt
-rw-rw-r--  1 spypiggy spypiggy  4215 Aug  9 09:17 dstest2_sgie1_config.txt
-rw-rw-r--  1 spypiggy spypiggy  4202 Aug  9 09:18 dstest2_sgie2_config.txt
-rw-rw-r--  1 spypiggy spypiggy  4262 Aug  9 09:19 dstest2_sgie3_config.txt
-rw-rw-r--  1 spypiggy spypiggy  1787 Aug  6 06:57 dstest2_tracker_config.txt
-rw-rw-r--  1 spypiggy spypiggy  3292 Aug  6 06:57 README
-rw-rw-r--  1 spypiggy spypiggy  3236 Aug  6 06:57 tracker_config.yml


PipeLine

PipeLined of GStreamer Elements used in example deepstream_test_2.py is as follows.
 
<Pipeline Diagram of deepstream_test_2.py>
 
Elements in the area indicated by the blue dotted line are newly added ones. The connection of elements is quite intuitive and easy to understand. The elements to be looked at carefully are as follows.
  • nvtracker : This plugin tracks detected objects and gives each new object a unique ID. When you run the example after a while, objects recognized by DeepStream are assigned numbers. This number is retained even if the frame changes. That is, a tracking function considering the movement of objects is implemented. However, for the same object, if a frame that fails to recognize is displayed during frame progress, a new number is assigned. In other words, it is judged as a new object. The resnet18.caffemodel model used in DeepStream 5.0 has excellent speed, but its accuracy is relatively inferior to the model based on ResNet-50. Therefore, it often happens that the tracking number of an object changes during tracking.
 And the newly added configuration files that the nvinfer element will use are as follows. These files contain various information such as the model and label values that the nvinfer element will use.
  • dstest2_sgie1.config.txt : This configuration file contains information about the model that identifies the color of the car. If you look at the label.txt file in the /opt/nvidia/deepstream/deepstream/samples/models/Secondary_CarColor directory, the colors those this model can recognize are as follows. black, blue, brown, gold, green, gray, maroon, orange, red, silver, white, yellow
  • dstest2_sgie2.config.txt : This configuration file contains information about the model that identifies the maker of the car. If you look at the label.txt file in the /opt/nvidia/deepstream/deepstream/samples/models/Secondary_CarMaker directory, the makers those this model can recognize are as follows. acura, audi, bmw, chevrolet, chrysler, dodge, ford, gmc, honda, hyundai, infiniti, jeep, kia, lexus, mazda, mercedes, nissan, subaru, toyota, volkswagen
  • dstest2_sgie3.config.txt : This configuration file contains information about the model that identifies the vehicle types. If you look at the label.txt file in the /opt/nvidia/deepstream/deepstream/samples/models/Secondary_VehicleTypes directory, the vehicle types those this model can recognize are as follows. coupe, largevehicle, sedan, suv, truck, van

 Therefore, the above pipeline is an example of searching for 4 objects(vehicle, bicycle, person, roadsign)  in a frame of a video stream and then finding the car color, car maker, and car type for the car. In addition, a function to track found objects by assigning a unique ID is added.
 

Configuration

Change the property section of dstest2_pgie_config.txt, dstest2_sgie1_config.txt, dstest2_sgie2_config.txt, dstest2_sgie3_config.txt files as follows. Depending on your DeepStream installation location, this value may vary.
 
[property]
gpu-id=0
net-scale-factor=0.0039215697906911373

model-file=/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/resnet10.caffemodel
#model-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel

proto-file=/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/resnet10.prototxt
#proto-file=../../../../samples/models/Primary_Detector/resnet10.prototxt

#model-engine-file=/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine
#model-engine-file=../../../../samples/models/Primary_Detector/resnet10.caffemodel_b1_gpu0_int8.engine

labelfile-path=/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/labels.txt
#labelfile-path=../../../../samples/models/Primary_Detector/labels.txt

int8-calib-file=/opt/nvidia/deepstream/deepstream/samples/models/Primary_Detector/cal_trt.bin
#int8-calib-file=../../../../samples/models/Primary_Detector/cal_trt.bin
......


Be Careful : Do not put tabs or space characters at the end of the line.
 
 

Test

Since I will display the video webcam output result on the screen, I connected a monitor to Xavier NX instead of ssh.
 
Now run the code.

spypiggy@XavierNX:~/src/deepstream_python_apps/apps/deepstream-test2$ source /home/spypiggy/python/bin/activate
(python) spypiggy@XavierNX:~/src/deepstream_python_apps/apps/deepstream-test2$ python3 deepstream_test_2.py /opt/nvidia/deepstream/deepstream/samples/streams/sample_720p.h264

If you can see the following screen, it is running successfully.
 
 
 It's not much different from the previous blog example. The first nvinfer element recognizes 4 types of objects and draws a box, so the overall shape is the same. However, the text describing the box is slightly different. In the previous blog test, only Person, Car, etc. were displayed, but this time, a number such as Person 141 is added. This number is a unique ID value that identifies the recognized object. And in the case of cars, it is marked as Car 159 white toyota, Car 160 red coupe, and car 191 silver bmw suv. The back part of the unique ID is the value of the car color, car maker, and car type recognized by the remaining nvinfer elements.
 
 

Under the Hood

Benefits of GStreamer PipeLine

Using GStreamer's pipeline, you can easily add, delete, and change the order of elements. So, if you are not interested in car makers, you can exclude them from the pipeline above.

Original code
sgie1.link(sgie2)
sgie2.link(sgie3)
sgie3.link(nvvidconv)

To
sgie1.link(sgie3)
sgie3.link(nvvidconv)

Perhaps you will no longer be able to see car maker information.

And the sgie1, sgie2, sgie3 elements can work in any order. So even if you change the order of links in the pipeline, there is no problem at all. However, the order of the screen output text might change.

Be Careful : sgie1, sgie2, sgie3 elements should follow the nvtrack element.

Process_Mode

The dstest2_sgie1.config.txt, dstest2_sgie2.config.txt, and dstest2_sgie3.config.txt have one major difference compared to the dstest2_pgie.config.txt file. In the dstest2_pgie.config.txt file, 'process-mode=1' is defined, but 'process-mode=2' is set in these three files. The process-mode defines whether the nvinfer element will process a full frame image or only a part of the image.
If this value is 1, the full frame is used, and if it is 2, the clip object image is used. In the first nvinfer element that uses the dstest2_pgie.config.txt configuration file, this value is 1. Therefore, in the first nvinfer element, processing is performed using full frames. For the rest of the nvinfer elements, this value is 2. That is, the clip object image is used. The clip object used here is object information obtained from the first nvinfer element. Therefore, it is possible to process quickly without performing object recognition repeatedly. When you run the example, the reason there is no big difference between the first example and the execution speed is that the configuration is optimized to avoid unnecessary repetitions.

Tips : You must use the model in the Primary_Detector directory as the first pipeline of nvinfer. And the models in the Secondary_CarColor, Secondary_CarMaker, and Secondary_VehicleType directories should be applied to the nvinfer element next.

Wrapping Up

So far, we have seen how to add a Seconrary model to the pipeline to try new recognition for an already recognized area.
Next time, I will look at how to find the location (box coordinates) of the recognition object, which is the data we actually need in the Probe function.



2020년 8월 6일 목요일

Xavier NX-DeepStream 5.0 #1 - Installation

DeepStream, as the name implies, is NVIDIA's platform for processing continuous frames through video or cameras. In a previous blog, I implemented object tracking using YOLOv4 and DeepSORT. However, the Jetson Nano had a performance as low as 0.3 FPS. At this processing speed, the moving distance of the object is too large at a frame interval that takes about 3.3 seconds, which greatly reduces accuracy. Therefore, it is necessary to optimize the video stream processing. In the next few blogs, I'll look at DeepStream, which is optimized for video and camera processing, and explore how to improve the performance of the object tracking function.

Prerequisites

I use python virtual environment in Xavier NX. Also, Tensorflow and PyTorch, which are frequently used frameworks, have been installed in the virtual environment in advance. Please proceed with the above process in advance and then follow the instructions below.


What is DeepStream?

NVIDIA's official site for the DeepStream SDK is https://developer.nvidia.com/deepstream-sdk.

DeepStream has the following features.
  • NVIDIA DeepStream simplifies the development of scalable intelligent video analytics (IVA) applications
  • Developers can now use this to quickly build new applications to transform video into valuable insight.
  • Applications for the DeepStream SDK include image classification, scene understanding, video categorization, content filtering etc.

<DeepStream Architecture>

NVIDIA’s DeepStream SDK delivers a complete streaming analytics toolkit for AI-based multi-sensor processing, video and image understanding.
DeepStream is for vision AI developers, software partners, startups and OEMs building IVA apps and services.
 
The following table is NVIDIA's DeepStream frame processing speed.



Jetson Nano
Jetson Xavier NX
Jetson AGX Xavier
T4
Model Architecture
Inference Resolution
Precision
Model Accuracy
GPU (FPS)
GPU (FPS)
DLA1 (FPS)
DLA2 (FPS)
GPU (FPS)
DLA1 (FPS)
DLA2 (FPS)
GPU (FPS)
PeopleNet-ResNet34
960x544
FP16
84%
10
60
30
30
120
60
60
460
TrafficCamNet-ResNet18
960x544
INT8
83.5%
19*
180
90
90
420
120
120
1300
DashCamNet-ResNet18
960x544
INT8
80%
18*
180
90
90
390
120
120
1280
FaceDetect-IR-ResNet18
384x240
INT8
96%
95*
1080
570
570
1950
780
780
2160
Tabulated data is in FPS with 1080p input
* FP16 inference on Jetson Nano
Running on the DLAs for AGX Xavier and NX frees up GPU for other tasks

Xavier NX records from a minimum of 30 FPS to a maximum of 1080 FPS. If the processing speed exceeds 10 FPS, it can be considered to be used in commercial systems.


Tip : DeepStream 5.0, installed on JetPack 4.4 and earlier, has properly implemented Python bindings. In JetPack 4.4 + DeepStream 5.0, installing DeepStream5.0 automatically installs the Python bindings, making it easy to implement DeepStream in Python. Therefore, users of previous version must upgrade to version 5.0 or later.

DeepStream 5.0 on the Xavier NX

DeepStream 5.0 was first released in April 2020 and is the DP (Developer Preview) version until June. And DeepStream 5.0 only works with JetPack 4.4 and above. The DeepStream 5.0 General Availability version was now released. You should use General Availability version not DP versoin.

The following are the contents published by https://docs.nvidia.com/metropolis/deepstream/DeepStream_5.0_Release_Notes.pdf and are not solved by DeepStream 5.0. Previous versions of Deepstream were difficult to implement in Python and had to build the pyds.so (python deepstream) file through a separate binding build. This file connects Python code and Deepstream implemented in native c/c++.

Limitations

  • With V4L2 codecs only MAX 1024 (decode + encode) instances are provided. The maximum number of instances can be increased by doing changes in open source code.
  • detected-min-w and detected-min-h must be set to values larger than 32 in the primary inference configuration file (config_infer_primary.txt) for gstdsexample on Jetson.
  • The Kafka protocol adapter sometimes does not automatically reconnect when the Kafka Broker to which it is connected goes down and comes back up, thereby requiring application restart.
  • If the nvds log file, ds.log, has been deleted, then to restart logging you must delete the file /run/rsyslogd.pid within the container before reenabling logging by running the setup_nvds_logger.sh script as described in the “nvds_logger” section of the DeepStream Plugin Development Guide.
  • On NVIDIA® Jetson AGX Xavier™, more than 50 instances of certain 1080p H.265 streams are not working due to limited memory for the decoder.
  • On Jetson, running a DeepStream application over SSH (via putty) with X11 forwarding does not work.
  • DeepStream currently expects model network width to be a multiple of 4 and network height to be a multiple of 2.
  • Triton Inference Server implementation in DeepStream currently supports a single GPU. The models need to be configured to use a single GPU.
  • For some models sometime output in DeepStream is not exactly same as observed in Transfer Learning Toolkit. This is due to input scaling algorithm differences.
  • DRC support is Alpha quality.
  • On the fly Model update only supports same type of Model with same Network parameters.

Installing DeepStream on Jetson Xavier NX

I will explain in the assumption that your Xavier NX has the General Availability version JetPack 4.4 installed, not the DP version. If you need information on installing JetPack 4.4 on Xavier NX, see Jetson Xavier NX-JetPack 4.4 (production release) headless setup.

First download the DeepStream SDK from https://developer.nvidia.com/deepstream-getting-started. To download the SDK, you will probably need an NVidia developer account. I will download and install the deb file.

After downloading the file, copy it to Xavier NX. Then install the downloaded deepstream_sdk_5.0_arm64.deb file.

spypiggy@XavierNX:~/download$ sudo apt-get install libgstrtspserver-1.0-0
spypiggy@XavierNX:~/download$ sudo dpkg -i deepstream_sdk_5.0_arm64.deb
......
......
 --------------------------------------------------------------------------------------- NOTE: sources and samples folders will be found in /opt/nvidia/deepstream/deepstream-5.0 ---------------------------------------------------------------------------------------


You can see that it is properly installed in the /opt/nvidia/deepstream/deepstream-5.0 directory. The pyds.so file, which is essential for Python bindings, is located in the following directory.

spypiggy@XavierNX:~$ ls -al /opt/nvidia/deepstream/deepstream-5.0/lib/pyds.so
-rw-r--r-- 1 root root 1023352 Jul 27 04:19 /opt/nvidia/deepstream/deepstream-5.0/lib/pyds.so


Installing deepstream_python_apps

If you installed DeepStream 5.0 properly, download the example files to implement DeepStream in Python.

spypiggy@XavierNX:~$ source /home/spypiggy/python/bin/activate
(python) spypiggy@XavierNX:~$ 
(python) spypiggy@XavierNX:~$ cd ~/src
(python) spypiggy@XavierNX:~/src$ git clone https://github.com/NVIDIA-AI-IOT/deepstream_python_apps.git
(python) spypiggy@XavierNX:~/src$ cd deepstream_python_apps/
(python) spypiggy@XavierNX:~/src/deepstream_python_apps$ ls -al
total 1420
drwxrwxr-x  5 spypiggy spypiggy    4096 Aug  6 06:57 .
drwxr-xr-x 12 spypiggy spypiggy    4096 Aug  6 06:57 ..
drwxrwxr-x 11 spypiggy spypiggy    4096 Aug  6 06:57 apps
-rw-rw-r--  1 spypiggy spypiggy    5410 Aug  6 06:57 FAQ.md
drwxrwxr-x  8 spypiggy spypiggy    4096 Aug  6 06:57 .git
-rw-rw-r--  1 spypiggy spypiggy    9674 Aug  6 06:57 HOWTO.md
-rw-rw-r--  1 spypiggy spypiggy    1097 Aug  6 06:57 LICENSE
drwxrwxr-x  2 spypiggy spypiggy    4096 Aug  6 06:57 notebooks
-rw-rw-r--  1 spypiggy spypiggy  316866 Aug  6 06:57 .python-app-pipeline.png
-rw-rw-r--  1 spypiggy spypiggy    2818 Aug  6 06:57 README.md
-rw-rw-r--  1 spypiggy spypiggy 1081940 Aug  6 06:57 .test3-app.png

Sample files are in the apps directory. You can simply check if DeepStream 5.0 integration works using Python.

(python) spypiggy@XavierNX:~/src/deepstream_python_apps$ cd apps/
(python) spypiggy@XavierNX:~/src/deepstream_python_apps/apps$ python3
Python 3.6.9 (default, Jul 17 2020, 12:50:27)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('../')
>>> import platform
>>> import configparser
>>>
>>> import gi
>>> gi.require_version('Gst', '1.0')
>>> from gi.repository import GObject, Gst
>>> from common.is_aarch_64 import is_aarch64
>>> from common.bus_call import bus_call
>>>
>>> import pyds
>>>

If the libraries for using DeepStream 5.0 in Python are imported without errors as above, the installation is successful.

Wrapping Up

DeepStream is a framework optimized by TensorRT from NVidia to process video streams with high performance. If you've been hungry for performance while using video, cameras, etc. in the Jetson series, DeepStream is definitely a good choice. And since DeepStream is an important part of NVidia's Metropolis framework that processes video streams from a large number of IoT devices at high speed, performance will continue to be improved and updated in the future.

Important features such as Python bindings have been properly built into the framework since DeepStream 5.0. Therefore, if you are starting for the first time, be sure to start using the latest DeepStream 5.0 from JetPack 4.4 General Availability version. Existing users are also recommended to upgrade to 5.0. And, whenever the latest version is released in the future, please check for new features and keep your system up to date with the latest DeepStream whenever possible.

In the next blog I will continue to look at examples of using DeepStream in Python.







2020년 6월 30일 화요일

Jetson Nano - YoloV4 Object Tracking

We have already learned how to distinguish objects in an image.
Previous blogs showed how to use Tensorflow, Pytorch Detectron2, DETR, and NVIDIA DNN Vision Library.
And recently I also looked at object detection using YOLOv4.
So far, Object Detection has been performed using still images, video files, or webcams.
When using video and webcams, the main concerns were whether the recognition was correct on a frame-by-frame basis and processing speed (FPS).

Object Tracking is mainly used in video. Object tracking is to determine whether objects recognized in consecutive frames are the same or not, and to track the path of movement in the case of the same objects.
For example, Object Tracking is essential to count floating populations on the street.
With Object Detection technology, the number of people in one frame can be counted, but the number of people who have passed a distance for an hour cannot be counted without using Object Tracking technology. Object Tracking is diverse. There are many algorithms and many methods like "Centroid Tracking", "SORT(Simple Online and Realtime Tracking)".  Among them, SORT is a popular object tracking technology. SORT is highly accurate because it uses a Kalman filter that removes noise when predicting the moving path of an object. Recently, DeepSORT, which adds Deep Learning technology to SORT, is also widely used.

SORT and DeepSORT

SORT consists of Object Detection, KalmanFilter, and Hungarian algorithm.

  • Object Detection : You can use various frameworks such as YOLO, PyTorch Detectron, Tensorflow Object Detection.
  • KalmanFilter : After removing noise components from the moving path and speed of the previous object, predict the next position.
  • Hungarian algorithm : The Hungarian algorithm determines the movement of the same object, the appearance of new objects, and the disappearance of existing objects by calculating the positions predicted by the Kalman filter and the positions of real objects.
<SORT >

However, there are weaknesses in the Hungarian algorithm. If the positions of two objects overlap, the object recognized in the next frame is reversed. This is because the Hungarian algorithm does not take into account the features of things. Because humans understand both the location and features of objects perceived by the eyes, even if the overlapping objects become farther away, they can be accurately identified and tracked without confusion. DeepSORT complements this weakness. DeepSORT is an improvement that enables the tracking of objects more accurately by reflecting the features of objects in the Hungarian algorithm.



<DeepSORT >



DeepSORT Object Tracking using Tensorflow,  YOLOv4

As mentioned before, it is not necessary to use the YOLOv4 Object Detection model to use DeepSORT. You can also use PyTorch Detectron2 or NVIDIA vision library. Here, we will convert the YOLOv4 model for Tensorflow.
There are many examples of DeepSORT on github. Most cover similar content. In this article, I'll use yehengchen's github (https://github.com/yehengchen/Object-Detection-and-Tracking), modified for Jetson Nano.

Prerequisites

This article assumes that Jetson Nano uses JetPack 4.4 DP or higher. Installation instructions are explained at https://spyjetson.blogspot.com/2020/06/jetson-nano-jetpack-44-dp-and-pytorch.html.

And this project requires a lot of memory. Jetson Nano's 4GB of memory is quite scarce. Therefore, if the memory is not secured as much as possible, an error may occur due to insufficient memory in the process.

The Jetson Nano's Ubuntu desktop occupies about 1.5 GB of memory. Therefore, only 2.5 GB of memory is actually available.
Please delete Ubuntu Desktop and replace it with LXDE. Then, you can free up about 1 GB of memory.
Securing additional memory by changing the desktop was described in "Use more memory by changing Ububtu desktop to LXDE".

Why should I install TensorFlow?

YOLO is sufficient to implement Object Detection. However, we will use DeepSORT tracking technology. Models needed for DeepSORT are in the model_data directory.
The extension pb files, market1501.pb, mars.pb, and mars-small128.pb files are models required for DeepSORT. These files work with Tensorflow.
Therefore, Tensorflow must be installed for DeepSORT. If you are using the model for DeepSORT for PyTorch, you might need to install PyTorch instead of Tensorflow.

Install Tensorflow

In the Jetson series, tensorflow should not be built according to the contents of the Tensorflow homepage. Download and install Tensorflow for Jetson provided by NVidia. We will be using Tensorflow version 1.5 for JetPack 4.4.
To install Tensorflow for Jetpack 4.4, follow the instructions in "JetsonNano-Installing Tensorflow".

Install necessary packages

Keras, scipy, scikit-learn, etc. used by yehengchen's github are version sensitive. Therefore, please keep the version indicated below.

apt-get install liblapack-dev libatlas-base-dev gfotran

#numpy to 1.19.0
pip3 install --upgrade numpy 
pip3 install Keras==2.3.1
pip3 install scikit-learn==0.21.2
pip3 install scipy
#scipy to 1.5.0
pip3 install --upgrade scipy

Install yehengchen's github

Now that you're ready, download the source code .

cd /usr/local/src
git clone https://github.com/yehengchen/Object-Detection-and-Tracking.git

## Download the YOLOv4 model
cd Object-Detection-and-Tracking/OneStage/yolo/deep_sort_yolov4/ wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights
cd model_data/
cp "/usr/local/src/Object-Detection-and-Tracking/OneStage/yolo/Train-a-YOLOv4-model/cfg/yolov4.cfg" ./
cp yolo_anchors.txt yolo4_anchors.txt

## Convert the YOLOv4 models to Keras model
## If there are not enough memory, the conversion process might fail.
cd ..
python3 convert.py "model_data/yolov4.cfg" "model_data/yolov4.weights" "model_data/yolo.h5"


##Download the test video clip
wget https://git.kpi.fei.tuke.sk/ml163fe/atvi/-/raw/4f70d8fd9c263b5a90dcdbc7a94b1176a520124c/python_objects_detection/TownCentreXVID.avi -O test_video/TownCentreXVID.avi


Object tracking with sample video

Now let's check whether it works properly using the video clip downloaded earlier.
I modified the main.py file to print the FPS value. The FPS values ​​were divided into two FPS values, including the time to process the inference frame in the model and the time to output the screen and write it to a new video file. The modified main.py file can be downloaded from my github.

This command, TownCentreXVID.avi file has the following properties.
  • Total 11475 frames, 15 frames/second, 1920 X 1080 frame size.
Therefore, it takes a lot of time to process this video clip. If you want to abort, press Ctrl+C during execution.

root@jetpack-4:/usr/local/src/Object-Detection-and-Tracking/OneStage/yolo/deep_sort_yolov4# python3 main.py -c person -i "./test_video/TownCentreXVID.avi"  
Using TensorFlow backend.
2020-06-30 18:40:19.078024: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.2
/usr/local/lib/python3.6/dist-packages/sklearn/utils/linear_assignment_.py:21: DeprecationWarning: The linear_assignment_ module is deprecated in 0.21 and will be removed from 0.23. Use scipy.optimize.linear_sum_assignment instead.
  DeprecationWarning)
WARNING:tensorflow:From main.py:27: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2020-06-30 18:40:31.516170: W tensorflow/core/platform/profile_utils/cpu_utils.cc:98] Failed to find bogomips in /proc/cpuinfo; cannot determine CPU frequency

..........
2020-06-30 18:41:59.919461: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.8
2020-06-30 18:42:07.822707: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.75GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-06-30 18:42:07.823401: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-06-30 18:42:15.321959: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 1.21GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-06-30 18:42:16.545443: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.06GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
2020-06-30 18:42:17.661731: W tensorflow/core/common_runtime/bfc_allocator.cc:239] Allocator (GPU_0_bfc) ran out of memory trying to allocate 2.06GiB with freed_by_count=0. The caller indicates that this is not a failure, but may mean that there could be performance gains if more memory were available.
..........

Net FPS:0.016420
FPS:0.015778
Net FPS:0.257968
FPS:0.234274
Net FPS:0.321014
FPS:0.291949
Net FPS:0.314152
FPS:0.287686

The following image captures a frame from the output.avi file created in the output directory.
<output.avi>

You can see the 0.27 FPS value displayed at the top left. You can see that tracking works by playing the created video file. However, the 0.3 FPS value is problematic. Because video frames are processed sequentially, the accuracy is the same except for the time-consuming problem, but it is a big problem in real-time video capture.
If it takes about 3 seconds or more to process 1 frame, the accuracy of tracking is too low when the position change value of the object (person) is too large when trying to process the next frame.


Wrapping up

I implemented object tracking using YOLOv4 and Deep SORT in Jetson Nano.
Unfortunately, it achieved a low performance of 0.3 FPS. Applying this value to a real-time camera makes object tracking accuracy too low. Therefore, it is inappropriate to use YOLOv4 + DeepSORT in Jetson Nano. Sooner or later, I will make an opportunity to find out how to apply the YOLOv4 tiny model or run this example on the Jetson Xavier NX to speed up.