This is a PyTorch re-implementation of YOLOv4 architecture based on the official darknet implementation AlexeyAB/darknet with PASCAL VOC, COCO and Custom dataset
- Nvida GeForce RTX 2070
- CUDA10.0
- CUDNN7.0
- windows or linux
- python 3.6
# install packages
pip3 install -r requirements.txt --user
- Mish
- Custom data
- Data Augment (RandomHorizontalFlip, RandomCrop, RandomAffine, Resize)
- Multi-scale Training (320 to 640)
- focal loss
- GIOU
- Label smooth
- Mixup
- cosine lr
git clone github.com/argusswift/YOLOv4-pytorch.git
update the "PROJECT_PATH"
in the config/yolov4_config.py.
- Download Pascal VOC OR COCO dataset : For PASCAL VOC{VOC 2012_trainval 、VOC 2007_trainval、VOC2007_test}、 For COCO{train2017_img 、train2017_ann 、val2017_img 、val2017_ann 、test2017_img 、test2017_list }
put them in the dir, and update the "DATA_PATH"
in the params.py.
- Convert data format :use utils/voc.py or utils/coco.py convert the pascal voc *.xml format (COCO *.json format)to *.txt format (Image_path0 xmin0,ymin0,xmax0,ymax0,class0 xmin1,ymin1...)
- Darknet pre-trained weight : darknet53-448.weights
Make dir weight/
in the YOLOv4 and put the weight file in.
Run the following command to start training and see the details in the config/yolov4_config.py
CUDA_VISIBLE_DEVICES=0 nohup python -u train.py --weight_path weight/darknet53_448.weights --gpu_id 0 > nohup.log 2>&1 &
Also * It supports to resume training adding --resume
, it will load last.pt
automaticly by using commad
WEIGHT_PATH=weight/last.pt
CUDA_VISIBLE_DEVICES=0 nohup python -u train.py --weight_path $WEIGHT_PATH --gpu_id 0 > nohup.log 2>&1 &
modify your test img path:DATA_TEST=./data/test # your own images
CUDA_VISIBLE_DEVICES=0 python3 test.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval
The images can be seen in the data/