Improve YOLOv4 real time object detection on Jetson Nano

YOLOv4 was released at the end of April. It soon gained popularity among the machine learning community. You can check it out with following link.

Compared with YOLOv3, YOLOv4’s AP has increased by 10%, while its FPS has increased by 12%. But can Jetson Nano handle YOLOv4? If you have tried YOLOv3 (darknet version) on Jetson Nano to perform real-time object detection, especially using the darknet version, you know what I’m saying. Usually, Jetson can only run the detection at around 1 FPS.

YOLOv3 Performance (darknet version)

But with YOLOv4, Jetson Nano can run detection at more than 2 FPS.

YOLOv4 Performace (darknet version)

Although YOLOv4 runs 167 layers of neural network, which is about 50% more than YOLOv3, 2 FPS is still too low. Now let’s try to accelerate it with PyTorch.

Run the following command

1
2
3
4
5
git clone https://github.com/ultralytics/yolov3 && cd yolov3
#down load yolov4 pre-trained weights
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights
#convert darknet cfg/weights to pytorch model
python3  -c "from models import *; convert('cfg/yolov4.cfg', 'yolov4.weights')"

When success, you can run the YOLOv4 PyTorch model by using the following command

1
python3 detect.py --cfg cfg/yolov4.cfg --weights weights/yolov4.pt --source 0
YOLOv4 Performance

Although the accuracy has been improved, FPS is still not satisfying. But fortunately, YOLOv5 is now available. For more information about YOLOv5, please check my next blog.

Please follow and like us:

3 thoughts on “Improve YOLOv4 real time object detection on Jetson Nano

  1. I run “python3 -c “from models import *; convert(‘cfg/yolov4.cfg’, ‘yolov4.weights’)””, It show error “RuntimeError: shape ‘[512, 256, 3, 3]’ is invalid for input of size 282158”

Comments are closed.

Wordpress Social Share Plugin powered by Ultimatelysocial