In this repo, I have trained yolov9-c on the WIDER face dataset.
Clone this repo and install YOLOv9:
# Clone
git clone https://github.com/spacewalk01/yolov9-face-detection
cd yolov9-face-detection/yolov9
pip install -r requirements.txt
- Download the pretrained yolov9-c.pt model from google drive. Note that this model was trained on the WIDER dataset for 240 epochs.
The WIDER dataset comprises of more than 30k images with more than 390k faces, each with bouding box and other various label formats.
Dataset structure:
${ROOT}
└── yolov9
└── datasets/
└── widerface/
└── train/
└── val/
└── original-widerface/
└── train/
└── images/
└── label.txt
└── val/
└── images/
└── label.txt
└── train2yolo.py
└── val2yolo.py
└── widerface.yaml
To prepare the data:
- Download WIDER-FACE datasets.
- Download annotation files from google drive.
Run the following commands:
python train2yolo.py datasets/original-widerface/train [datasets/widerface/train]
python val2yolo.py datasets/original-widerface [datasets/widerface/val]
To train the model, use the following command:
cd yolov9
python train_dual.py --workers 4 --device 0 --batch 4 --data ../widerface.yaml --img 640 --cfg models/detect/yolov9-c.yaml --weights '' --name yolov9-c --hyp hyp.scratch-high.yaml --min-items 0 --epochs 500 --close-mosaic 15
For inference, run the following command:
python detect.py --weights runs/train/yolov9-c5/weights/best.pt --source assets/worlds-largest-selfie.jpg
- YOLOv9 - YOLOv9: Learning What You Want to Learn Using Programmable Gradient Information
- WIDER FACE - WIDER FACE: A Face Detection Benchmark