Previous: Jetson AGX Xavier implements TensorRT to accelerate YOLOv5 for real-time detection
Next article: Jetson AGX Xavier implements TensorRT to accelerate YOLOv4
I. Introduction
Some time ago, I designed a target tracking car using the YOLOv5 algorithm. I probably have a rough understanding of the YOLOv5 algorithm. I saw on the Internet that the performance of YOLOv4 is also very good and has been recognized by the original author, so I also tested a wave of implementation effects in Xavier. Here are my implementation steps.
2. Installation preparation
1. Clone the YOLOv4 project
git clone https://github.com/AlexeyAB/darknet.git yolov4
2. Modify the Makefile in the yolov4 project as shown in the figure. If you do not need to use the python script in the project to detect pictures or videos, then the LIBSO item does not need to be changed. ARCH=72, which means ten times the computing power of Xavier's GPU.
3. Compile the project
make -j8
If the compilation is successful, a lot of codes will appear in the terminal. As long as there is no error, the compilation is successful. At this time, the files in the project are as follows.
4. Download the weight files yolov4.weights, yolov4-tiny.weights and put them in the yolov4 folder.
3. Test Algorithm
1. C++ version
① Image detection, open the terminal in the yolov4 folder.
#完整指令
./darknet detector test cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights data/dog.jpg
./darknet detector test cfg/coco.data cfg/yolov4.cfg yolov4.weights data/dog.jpg
#简写指令
./darknet detect cfg/yolov4-tiny.cfg yolov4-tiny.weights data/dog.jpg
./darknet detect cfg/yolov4.cfg yolov4.weights data/dog.jpg
②Test real-time detection of USB camera.
./darknet detector demo cfg/coco.data cfg/yolov4-tiny.cfg yolov4-tiny.weights -c 0
./darknet detector demo cfg/coco.data cfg/yolov4.cfg yolov4.weights -c 0
2. Python version
The python environment, this article uses the environment "yolov5env" I created for yolov5, you can view my homepage article.
①Test picture
python darknet_images.py --weight yolov4-tiny.weights
② USB camera real-time detection
python darknet_video.py --weights yolov4-tiny.weights #默认调用USB摄像头
Through the test, in Xavier, the real-time detection of yolov4 is about 5~10FPS. The test background of this paper is relatively complicated, and the detection accuracy is not bad, but the detection speed needs to be improved.
Four. Summary
At present, YOLOv4 has many python versions of projects. I have passed the test and feel that the effect will be slightly better than the original project. I don't know why. Of course, the same as the previous YOLOv5 article, in order to pursue a higher detection speed, TensorRT can also be used to accelerate it. After turning over one mountain, there is another mountain. See you on the next mountain.