Custom Yolov7 to detect face and estimate landmark.
pip3 install -r requirements.txt
pip3 install Cython
cd evaluation && sudo python3 setup.py install
Name | Dataset | Easy | Medium | Hard | Link |
---|---|---|---|---|---|
yolov7-tiny | Winderface | 0.9491 | 0.9312 | 0.8280 | Link |
yolov7 | Winderface |
- ./winderface
- WIDER_test/
- images/
- 0--Parade/
- ...
- WIDER_train/
- images/
- 0--Parade/
- ...
- WIDER_val/
- images/
- 0--Parade/
- ...
- train/
- labels.txt
- val/
- labels.txt
- test/
- labels.txt
- ground_truth/
- wider_easy_val.mat
- wider_medium_val.mat
- wider_hard_val.mat
- wider_face_val.mat
python3 scripts/convert_to_yolo.py --root ./widerface --image-folder WIDER_train/images --label-file train/label.txt --txt-file train.txt
python3 scripts/convert_to_yolo.py --root ./widerface --image-folder WIDER_val/images --label-file val/label.txt --txt-file val.txt
winderface
folder in data/winderface.yamlpython3 detect.py --weights ./weights/yolov7-tiny.pt --source inference/images --img-size 640 --conf-thres 0.2 --iou-thres 0.5 --device 1 --no-trace
python3 eval.py --weights ./weights/yolov7-tiny.pt --data-root ./winderface --img-size 640 --conf-thres 0.01 --iou-thres 0.5 --device 0 --no-trace
python3 evaluation/main.py -p ./outputs -g ./winderface/ground_truth
Download file yolov7-tiny.pt and save as ./weights/yolov7-tiny-origin.pt
.
Single GPU training: python3 ./train.py --device 0 --batch-size 16 --data data/widerface.yaml --img 640 640 --cfg cfg/yolov7-tiny-landmark.yaml --weights ./weights/yolov7-tiny-origin.pt --name yolov7-tiny --hyp data/hyp.scratch.tiny.yaml --noautoanchor --linear-lr --epochs 80
Multiple GPU training: torchrun --standalone --nnodes=1 --nproc_per_node 2 ./train.py --device 0,1 --batch-size 16 --data data/widerface.yaml --img 640 640 --cfg cfg/yolov7-tiny-landmark.yaml --weights ./weights/yolov7-tiny-origin.pt --name yolov7-tiny --hyp data/hyp.scratch.tiny.yaml --noautoanchor --sync-bn --linear-lr --epochs 80
python3 export.py --weights ./weights/yolov7-tiny.pt --img-size 640 --batch-size 1 --dynamic-batch --grid --end2end --max-wh 640 --topk-all 100 --iou-thres 0.5 --conf-thres 0.2 --device 1 --simplify --cleanup
Install custom TensorRT plugin
python3 export.py --weights ./weights/yolov7-tiny.pt --img-size 640 --batch-size 1 --dynamic-batch --grid --end2end --max-wh 640 --topk-all 100 --iou-thres 0.5 --conf-thres 0.2 --device 1 --simplify --cleanup --trt
/usr/src/tensorrt/bin/trtexec --onnx=./weights/yolov7-tiny.onnx --saveEngine=./weights/yolov7-tiny-nms-trt.trt --workspace=8192 --fp16 --minShapes=images:1x3x640x640 --optShapes=images:1x3x640x640 --maxShapes=images:4x3x640x640 --shapes=images:1x3x640x640