Skip to content

SpaceView/yolov5-face

 
 

Repository files navigation

This is a forked version from deepcam-cn/yolov5-face, adapted to WINDOWS specifically

PATH format of images & labels folder

./data/widerface/
    train/
      images/0--Parade/*.jpg
      images/1--Handshaking/*.jpg
      ...
      images/61--Street_Battle/*.jpg
      label.txt
    val/
      images/0--Parade/*.jpg
      images/1--Handshaking/*.jpg
      ...
      images/61--Street_Battle/*.jpg
      label.txt
      wider_val.txt

Widerface Evaluation On Windows

With their original code, I cannot reproduce their evaluation on windows. some changes are made as follows, in test_widerface.py, weights and dataset_folder are directly set

parser.add_argument('--weights', nargs='+', type=str, default='./weights/yolov5s-face.pt', help='model.pt path(s)')
parser.add_argument('--dataset_folder', default='./data/widerface/val/images/', type=str, help='dataset path')

The organized widerface dataset can be downloaded from google driver, thanks to biubug6,

and I add a for to loop through all the folders,

for image_dir in tqdm(glob.glob(os.path.join(testset_folder, '*'))):
        for image_path in tqdm(glob.glob(os.path.join(image_dir, '*'))):

Now you can evaluate it directly

python test_widerface.py
python ./widerface_evaluate/evaluation.py

e.g. the Generated results are save as follows

./widerface_evaluate/widerface_txt/0--Parade/0_Parade_marchingband_1_1004.txt
......
./widerface_evaluate/widerface_txt/1--Handshaking/1_Handshaking_Handshaking_1_107.txt
......

the content of this example file (0_Parade_marchingband_1_1004.txt) contains the obtained results,

0_Parade_marchingband_1_20
61
540 357 40 45 0.835
29 403 29 36 0.820
465 355 29 33 0.793
82 391 23 27 0.789
....

Training Data Preparation on Windows

I don't want to change the before mentioned Evaluation folders, so in train2yolo.py I changed the destination folders to widerfaceyolo

#save_path = '/ssd_1t/derron/yolov5-face/data/widerface/train'
#aa=WiderFaceDetection("/ssd_1t/derron/yolov5-face/data/widerface/widerface/train/label.txt")
save_path = './data/widerfaceyolo/train'
aa=WiderFaceDetection("./data/widerface/train/label.txt")

For this reason, the ./data/widerface.yaml has to be adapted too, as below,

#train: /ssd_1t/derron/yolov5-face/data/widerface/train  # 16551 images
#val: /ssd_1t/derron/yolov5-face/data/widerface/val  # 16551 images
train: ./data/widerfaceyolo/train  # 16551 images
val: ./data/widerface/val  # 16551 images

Consequently, relevant changes are also made in ./data/val2yolo.py!

Train you model on Windows

You'd better commented out the wandb (wandb=none) if you don't wana bother to make an account!




===================================================================================== =====================================================================================

Original README.md in deepcam-cn/yolov5-face

What's New

2021.08: Yolov5-face to TensorRT.
Inference time on rxt2080ti.

Backbone Pytorch TensorRT_FP16
yolov5n-0.5 11.9ms 2.9ms
yolov5n-face 20.7ms 2.5ms
yolov5s-face 25.2ms 3.0ms
yolov5m-face 61.2ms 3.0ms
yolov5l-face 109.6ms 3.6ms

Note: (1) Model inference (2) Resolution 640x640

2021.08: Add new training dataset Multi-Task-Facial,improve large face detection.

Method Easy Medium Hard
YOLOv5s 94.56 92.92 83.84
YOLOv5m 95.46 93.87 85.54

Introduction

Yolov5-face is a real-time,high accuracy face detection.

Performance

Single Scale Inference on VGA resolution(max side is equal to 640 and scale).

Large family

Method Backbone Easy Medium Hard #Params(M) #Flops(G)
DSFD (CVPR19) ResNet152 94.29 91.47 71.39 120.06 259.55
RetinaFace (CVPR20) ResNet50 94.92 91.90 64.17 29.50 37.59
HAMBox (CVPR20) ResNet50 95.27 93.76 76.75 30.24 43.28
TinaFace (Arxiv20) ResNet50 95.61 94.25 81.43 37.98 172.95
SCRFD-34GF(Arxiv21) Bottleneck Res 96.06 94.92 85.29 9.80 34.13
SCRFD-10GF(Arxiv21) Basic Res 95.16 93.87 83.05 3.86 9.98
- - - - - - -
YOLOv5s CSPNet 94.67 92.75 83.03 7.075 5.751
YOLOv5s6 CSPNet 95.48 93.66 82.8 12.386 6.280
YOLOv5m CSPNet 95.30 93.76 85.28 21.063 18.146
YOLOv5m6 CSPNet 95.66 94.1 85.2 35.485 19.773
YOLOv5l CSPNet 95.78 94.30 86.13 46.627 41.607
YOLOv5l6 CSPNet 96.38 94.90 85.88 76.674 45.279

Small family

Method Backbone Easy Medium Hard #Params(M) #Flops(G)
RetinaFace (CVPR20 MobileNet0.25 87.78 81.16 47.32 0.44 0.802
FaceBoxes (IJCB17) 76.17 57.17 24.18 1.01 0.275
SCRFD-0.5GF(Arxiv21) Depth-wise Conv 90.57 88.12 68.51 0.57 0.508
SCRFD-2.5GF(Arxiv21) Basic Res 93.78 92.16 77.87 0.67 2.53
- - - - - - -
YOLOv5n ShuffleNetv2 93.74 91.54 80.32 1.726 2.111
YOLOv5n-0.5 ShuffleNetv2 90.76 88.12 73.82 0.447 0.571

Pretrained-Models

Name Easy Medium Hard FLOPs(G) Params(M) Link
yolov5n-0.5 90.76 88.12 73.82 0.571 0.447 Link: https://pan.baidu.com/s/1UgiKwzFq5NXI2y-Zui1kiA pwd: s5ow, https://drive.google.com/file/d/1XJ8w55Y9Po7Y5WP4X1Kg1a77ok2tL_KY/view?usp=sharing
yolov5n 93.61 91.52 80.53 2.111 1.726 Link: https://pan.baidu.com/s/1xsYns6cyB84aPDgXB7sNDQ pwd: lw9j,https://drive.google.com/file/d/18oenL6tjFkdR1f5IgpYeQfDFqU4w3jEr/view?usp=sharing
yolov5s 94.33 92.61 83.15 5.751 7.075 Link: https://pan.baidu.com/s/1fyzLxZYx7Ja1_PCIWRhxbw Link: eq0q,https://drive.google.com/file/d/1zxaHeLDyID9YU4-hqK7KNepXIwbTkRIO/view?usp=sharing
yolov5m 95.30 93.76 85.28 18.146 21.063 Link: https://pan.baidu.com/s/1oePvd2K6R4-gT0g7EERmdQ pwd: jmtk
yolov5l 95.78 94.30 86.13 41.607 46.627 Link: https://pan.baidu.com/s/11l4qSEgA2-c7e8lpRt8iFw pwd: 0mq7

Data preparation

  1. Download WIDERFace datasets.
  2. Download annotation files from google drive.
python3 train2yolo.py
python3 val2yolo.py

Training

CUDA_VISIBLE_DEVICES="0,1,2,3" python3 train.py --data data/widerface.yaml --cfg models/yolov5s.yaml --weights 'pretrained models'

WIDERFace Evaluation

python3 test_widerface.py --weights 'your test model' --img-size 640

cd widerface_evaluate
python3 evaluation.py

Test

Android demo

https://github.com/FeiGeChuanShu/ncnn_Android_face/tree/main/ncnn-android-yolov5_face

opencv dnn demo

https://github.com/hpc203/yolov5-dnn-cpp-python-v2

References

https://github.com/ultralytics/yolov5

https://github.com/DayBreak-u/yolo-face-with-landmark

https://github.com/xialuxi/yolov5_face_landmark

https://github.com/biubug6/Pytorch_Retinaface

https://github.com/deepinsight/insightface

Citation

  • If you think this work is useful for you, please cite

    @article{YOLO5Face,
    title = {YOLO5Face: Why Reinventing a Face Detector},
    author = {Delong Qi and Weijun Tan and Qi Yao and Jingfeng Liu},
    booktitle = {ArXiv preprint ArXiv:2105.12931},
    year = {2021}
    }
    

Main Contributors

https://github.com/derronqi

https://github.com/changhy666

https://github.com/bobo0810

About

YOLO5Face: Why Reinventing a Face Detector (https://arxiv.org/abs/2105.12931)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.5%
  • Shell 2.8%
  • Other 0.7%