Fork of deepcam-cn/yolov5-face
Differences between original repository and fork:
- Compatibility with PyTorch >=2.1. (🔥)
- 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: 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
Name | Easy | Medium | Hard | FLOPs(G) | Params(M) | Link |
---|---|---|---|---|---|---|
yolov5n-0.5 | 90.76 | 88.12 | 73.82 | 0.571 | 0.447 | PyTorch, ONNX |
yolov5n | 93.61 | 91.52 | 80.53 | 2.111 | 1.726 | PyTorch, ONNX |
yolov5s | 94.33 | 92.61 | 83.15 | 5.751 | 7.075 | PyTorch, ONNX |
yolov5m | 95.30 | 93.76 | 85.28 | 18.146 | 21.063 | PyTorch, ONNX |
yolov5l | 95.78 | 94.30 | 86.13 | 41.607 | 46.627 | |
yolov5l (non-original) | 95.63 | 94.06 | 85.49 | 41.607 | 46.627 | PyTorch, ONNX |
Note: Unable to download the YOLOv5l-Face model from the original repository due to an expired Google Drive link and a lack of access to Baidu Netdisk. So, the decision has been made to train the YOLOv5l-Face model from scratch. If someone have the original YOLOv5l-Face model, please create an issue with a new download link.
YOLOv5l-Face 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