https://github.com/clibdev/yolov5-face

Yolov5Face

https://github.com/clibdev/yolov5-face

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (7.2%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Yolov5Face

Basic Info
  • Host: GitHub
  • Owner: clibdev
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 9.9 MB
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 1
Created about 3 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

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.

Installation

shell pip install -r requirements.txt

Pretrained models

  • 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

Inference

shell python detect_face.py --weights weights/yolov5s-face.pt --source data/images/bus.jpg --save-img

WIDERFace evaluation

shell python test_widerface.py --weights weights/yolov5s-face.pt --dataset_folder data/widerface/val/images shell cd widerface_evaluate shell python setup.py build_ext --inplace shell python evaluation.py

Export to ONNX format

shell pip install onnx onnxruntime shell python export.py --weights weights/yolov5s-face.pt

Export to TensorRT format

shell pip install tensorrt pycuda shell python export.py --weights weights/yolov5s-face.pt --onnx2trt

TensorRT Inference

shell python torch2trt/main.py --trt_path weights/yolov5s-face.trt --img_path data/images/bus.jpg

PyTorch vs TensorRT speed comparison

shell python torch2trt/speed.py --torch_path weights/yolov5s-face.pt --trt_path weights/yolov5s-face.trt

Training

  • Download WIDERFace training dataset.
  • Download WIDERFace validation dataset.
  • Download annotation files.
  • Move WIDERFace training images WIDER_train/images to data/widerface/tmp/train/images.
  • Move WIDERFace validation images WIDER_val/images to data/widerface/tmp/val/images.
  • Move training annotation file train/label.txt to data/widerface/tmp/train/label.txt.
  • Move validation annotation file val/label.txt to data/widerface/tmp/val/label.txt.

shell python data/train2yolo.py data/widerface/tmp/train data/widerface/train shell python data/val2yolo.py data/widerface/tmp data/widerface/val shell pip install tensorboard

  • Start training:

shell python train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml shell python train.py --data data/widerface.yaml --cfg models/yolov5l.yaml --weights weights/yolov5l.pt

  • Resume training:

shell python train.py --data data/widerface.yaml --cfg models/yolov5n-0.5.yaml --resume shell python train.py --data data/widerface.yaml --cfg models/yolov5l.yaml --resume

Owner

  • Login: clibdev
  • Kind: user

GitHub Events

Total
  • Watch event: 2
  • Push event: 1
Last Year
  • Watch event: 2
  • Push event: 1

Dependencies

utils/google_app_engine/Dockerfile docker
  • gcr.io/google-appengine/python latest build
requirements.txt pypi
  • Cython >=0.29.35
  • PyYAML >=6.0.0
  • opencv-python >=4.7.0
  • scipy >=1.10.0
  • seaborn >=0.12.0
  • thop >=0.1.1
  • torch >=2.0.0
  • torchvision >=0.15.0
  • tqdm >=4.65.0
utils/google_app_engine/additional_requirements.txt pypi
  • Flask ==1.0.2
  • gunicorn ==19.9.0
  • pip ==18.1
widerface_evaluate/setup.py pypi