Fork of deepcam-cn/yolov5-face
Differences between original repository and fork:
- Compatibility with PyTorch >=2.5. (🔥)
- Original pretrained models and converted ONNX models from GitHub releases page. (🔥)
- Installation with requirements.txt file.
- The wider_val.txt file for WIDERFace evaluation.
- The following deprecations and errors has been fixed:
- UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument.
- DeprecationWarning: 'np.float' is a deprecated alias for builtin 'float'.
- FutureWarning: You are using 'torch.load' with 'weights_only=False'.
- FutureWarning: Cython directive 'language_level' not set.
- Cython Warning: Using deprecated NumPy API.
- AttributeError: module 'numpy' has no attribute 'int'.
- RuntimeError: result type Float can't be cast to the desired output type long int.
- Fixed face bounding box drawing problem in the TensorRT example.
- NameError: name 'warnings' is not defined.
pip install -r requirements.txt
- Download links:
Name | Model Size (MB) | Link | SHA-256 |
---|---|---|---|
YOLOv5-BlazeFace | 0.5 4.4 |
PyTorch ONNX |
942997451c57981608d9e7eb7b0e964f2a83583b8add2409a2c5254a1f36f2d9 071cbb36cdb8d0d3dfb9305ba30f96c08a24342a4e835f48b4cc6bf1b185a564 |
YOLOv5n-0.5-Face | 1.1 5.7 |
PyTorch ONNX |
9f7cdbcf5cd63f454c47b18e7400a69630b96a01efb7559367e91b6e962ad3bd 269eb1e54313f9d1f7941ed9939fa247767539bca5801fc7aa7895960e93ca43 |
YOLOv5n-Face | 13.7 10.5 |
PyTorch ONNX |
794c94da54630f2ca66167fea25530c68133c61a2b14131b073c0d4064934e50 ee6ba4ccdc3c075d205c9703aec53a2aa3010c8d7fa08b0eff078e33a4b4fe6c |
YOLOv5s-Face | 54.4 30.9 |
PyTorch ONNX |
a594ade0f5e80f5cf15aef8997d285a3fb4b372a2af5262fbc6837d30318cda7 9083776982185402cfb3bd3cba8d453823068e72a0f9b0a6c6060439a850d9c5 |
YOLOv5m-Face | 161.2 84.2 |
PyTorch ONNX |
ca90ccc1b76c06d330a501bdb2cba63d3740fd3ef39baea89c7acc602557a4a2 c7ea51072e5f5c1ead34be14b3f4a23f44477448c271bc161b99d122fa0d8f10 |
YOLOv5l-Face | 356.4 181.7 |
PyTorch ONNX |
adfa3fbee5ba97ca86237cf8b45992aaea891ea481d59722da89bbd871a6a546 b8b13132e7dd609b82a7cf8ea76d7c6f7695cbd909dc77063e37166af0a12622 |
YOLOv5l-Face (non-original) | 89.3 181.7 |
PyTorch ONNX |
7e20bf0c79888b230264e2b5d812a12a69c68bcf1a234b469f86c30d82bd6c2a 5340f05f54f3e22ca63234aa4f2622975fd23a62ccd656158f78c94dbeaa33f2 |
- Evaluation results on WIDERFace dataset:
Name | Easy | Medium | Hard | GFLOPS | Params(M) |
---|---|---|---|---|---|
YOLOv5-BlazeFace | 90.4 | 88.7 | 78.0 | 2.6 | 0.182 |
YOLOv5n-0.5-Face | 90.76 | 88.12 | 73.82 | 1.5 | 0.447 |
YOLOv5n-Face | 93.61 | 91.52 | 80.53 | 5.6 | 1.726 |
YOLOv5s-Face | 94.33 | 92.61 | 83.15 | 15.2 | 7.075 |
YOLOv5m-Face | 95.30 | 93.76 | 85.28 | 48.2 | 21.063 |
YOLOv5l-Face | 95.78 | 94.30 | 86.13 | 110.6 | 46.627 |
YOLOv5l-Face (non-original) | 95.63 | 94.06 | 85.49 | 110.6 | 46.627 |
YOLOv5l-Face (non-original) model training took about 10.57 hours using NVIDIA RTX 4090. Results can be found in the yolov5l-face.txt file
python detect_face.py --weights weights/yolov5s-face.pt --source data/images/bus.jpg --save-img
- Download WIDERFace validation dataset.
- Move dataset to
data/widerface/val
directory.
python test_widerface.py --weights weights/yolov5s-face.pt --dataset_folder data/widerface/val/images
cd widerface_evaluate
python setup.py build_ext --inplace
python evaluation.py
pip install onnx onnxruntime
python export.py --weights weights/yolov5s-face.pt
pip install tensorrt pycuda
python export.py --weights weights/yolov5s-face.pt --onnx2trt
python torch2trt/main.py --trt_path weights/yolov5s-face.trt --img_path data/images/bus.jpg
python torch2trt/speed.py --torch_path weights/yolov5s-face.pt --trt_path weights/yolov5s-face.trt
- Download WIDERFace training dataset.
- Download WIDERFace validation dataset.
- Download annotation files.
- Move WIDERFace training images
WIDER_train/images
todata/widerface/tmp/train/images
. - Move WIDERFace validation images
WIDER_val/images
todata/widerface/tmp/val/images
. - Move training annotation file
train/label.txt
todata/widerface/tmp/train/label.txt
. - Move validation annotation file
val/label.txt
todata/widerface/tmp/val/label.txt
.
python data/train2yolo.py data/widerface/tmp/train data/widerface/train
python data/val2yolo.py data/widerface/tmp data/widerface/val
pip install tensorboard
- Start training:
python train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml
python train.py --data data/widerface.yaml --cfg models/yolov5l.yaml --weights weights/yolov5l.pt
- Resume training:
python train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml --resume
python train.py --data data/widerface.yaml --cfg models/yolov5l.yaml --resume