LY54 / YOLOv4-pytorch

This is a repository of YOLOv4-pytorch with PASCAL VOC and COCO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YOLOv4-pytorch

This is a PyTorch re-implementation of YOLOv4 architecture based on the official darknet implementation AlexeyAB/darknet with PASCAL VOC, COCO and Custom dataset

This repo is simple to use,easy to read and uncomplicated to improve compared with others!!!

results


Environment

  • Nvida GeForce RTX 2070
  • CUDA10.0
  • CUDNN7.0
  • windows or linux
  • python 3.6
# install packages
pip3 install -r requirements.txt --user

Brief

  • Mish
  • Custom data
  • Data Augment (RandomHorizontalFlip, RandomCrop, RandomAffine, Resize)
  • Multi-scale Training (320 to 640)
  • focal loss
  • GIOU
  • Label smooth
  • Mixup
  • cosine lr

Prepared work

1、Git clone YOLOv4 repository

git clone github.com/argusswift/YOLOv4-pytorch.git

update the "PROJECT_PATH" in the config/yolov4_config.py.


2、Download dataset

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...)

3、Download weight file

Make dir weight/ in the YOLOv4 and put the weight file in.


To train

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 &

To detect

modify your detecte img path:DATA_TEST=/path/to/your/test_data # your own images

for VOC dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_voc.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval --mode det
for COCO dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_coco.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval --mode det

The images can be seen in the output/


To evaluate

modify your evaluate dataset path:DATA_TEST=/path/to/your/test_data # your own images

for VOC dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_voc.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval --mode val
for COCO dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_coco.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval --mode val

The images can be seen in the output/


To visualize heatmaps

set showatt=Ture in val_voc.py and you will see the heatmaps emerged from network' output

for VOC dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_voc.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval
for COCO dataset:
CUDA_VISIBLE_DEVICES=0 python3 val_coco.py --weight_path weight/best.pt --gpu_id 0 --visiual $DATA_TEST --eval

The heatmaps can be seen in the output/ like this:

heatmaps

Reference

About

This is a repository of YOLOv4-pytorch with PASCAL VOC and COCO


Languages

Language:Python 100.0%