Tuesday, August 23, 2022

Train YOLOv4 CrowdHuman on Colab for NVIDIA Jetson

Train YOLOv4 CrowdHuman on Colab for NVIDIA Jetson

For doing training on Google Colab, I use a "416x416" yolov4 model as example. I have put all data processing and training commands into an IPython Notebook. So training the "yolov4-crowdhuman-416x416" model on Google Colab is just as simple as: 

(1) opening the Notebook on Google Colab, 

(2) mount your Google Drive, 

(3) run all cells in the Notebook.

CrowdHuman is a benchmark dataset to better evaluate detectors in crowd scenarios. The CrowdHuman dataset is large, rich-annotated and contains high diversity. CrowdHuman contains 15000, 4370 and 5000 images for training, validation, and testing, respectively. There are a total of 470K human instances from train and validation subsets and 23 persons per image, with various kinds of occlusions in the dataset. Each human instance is annotated with a head bounding-box, human visible-region bounding-box and human full-body bounding-box. We hope our dataset will serve as a solid baseline and help promote future research in human detection tasks.

We've 2 choices for Training Model.

  1. Darknet method
  2. Pytorch method


For DarkNet Method and Source Code

https://github.com/jkjung-avt/yolov4_crowdhuman


Deploying onto Jetson

To deploy the trained "yolov4-crowdhuman-416x416" model onto Jsetson Nano, I'd use my jkjung-avt/tensorrt_demos code to build/deploy it as a TensorRT engine. Here are the detailed steps:


Download the "yolov4-crowdhuman-416x416" model. More specifically, get "yolov4-crowdhuman-416x416.cfg" from this repository and download "yolov4-crowdhuman-416x416_best.weights" file from your Google Drive. Rename the .weights file so that it matches the .cfg file.

$ cd ${HOME}/project/tensorrt_demos/yolo
$ wget https://raw.githubusercontent.com/jkjung-avt/yolov4_crowdhuman/master/cfg/yolov4-crowdhuman-416x416.cfg


Then build the TensorRT (FP16) engine. Note the "-c 2" in the command-line option is for specifying that the model is for detecting 2 classes of objects.

$ python3 yolo_to_onnx.py -c 2 -m yolov4-crowdhuman-416x416
$ python3 onnx_to_tensorrt.py -c 2 -m yolov4-crowdhuman-416x416

Test the TensorRT engine. 

$ python3 trt_yolo.py -c 2 -m yolov4-crowdhuman-416-416 \
--image /home/jetson/Pictures/your_image.jpg

Part 2 Deploy Yolov4 CrowdHuman to NVIDIA Jetson

 


Run YOLOv4 CrowdHuman 416x416 on NVIDIA Jetson Nano


Run YOLOv4 CrowdHuman 416x416 on NVIDIA Jetson Xavier NX


Compare Performance 



Run YOLOv4-tiny CrowdHuman 416x416 on NVIDIA Jetson Nano


Performance 11-13 FPS





Compare YOLOv4 vs. YOLOv4-tiny on NVIDIA Jetson Nano


Reference

CrownHuman Dataset https://www.crowdhuman.org/

DarkNet YOLO https://github.com/AlexeyAB/darknet

TensorRT YOLO For Custom Trained Models https://jkjung-avt.github.io/trt-yolo-custom-updated/