out_retina.mp4
Tiny-Face is an ultra-lightweight face detection model optimized for mobile and edge devices. Built upon the concepts of RetinaFace, this model achieves high precision and speed in face detection with minimal resource requirements.
Note
This repository refines lightweight architectures like RetinaFace (mobile), Slim and RFB with a focus on Tiny-level efficiency.
Models | Pretrained on ImageNet | Easy | Medium | Hard | #Params(M) | Size(MB) |
---|---|---|---|---|---|---|
SlimFace | False | 79.50% | 79.40% | 68.36% | 0.343 | 1.4 |
RFB | False | 80.49% | 81.51% | 75.73% | 0.359 | 1.5 |
RetinaFace | True | 87.69% | 86.39% | 80.21% | 0.426 | 1.8 |
Models | Pretrained on ImageNet | Easy | Medium | Hard | #Params(M) |
---|---|---|---|---|---|
SlimFace | False | 87.10% | 84.36% | 67.38% | 0.343 |
RFB | False | 87.09% | 84.61% | 69.22% | 0.359 |
RetinaFace | True | 90.26% | 87.48% | 72.85% | 0.426 |
- Tiny-sized Efficiency: Ultra-lightweight and optimized for low-resource devices.
- Mobile-friendly: Includes Slim, RFB, and MobileNetV1_0.25 configurations.
- Pretrained Backbones: Models suitable for mobile and embedded systems.
All weights are available in GitHub release v0.0.1.
Models | PyTorch Weights | ONNX Weights | Input Size |
---|---|---|---|
SlimFace | slimface.pth | slimface.onnx | 640x640 |
RFB | rfb.pth | rfb.onnx | 640x640 |
RetinaFace | retinaface.pth | retinaface.onnx | 640x640 |
-
Clone the repository:
git clone https://github.com/yakhyo/tiny-face-pytorch.git cd tiny-face-pytorch
-
Install dependencies:
pip install -r requirements.txt
-
Download the Dataset:
- Download the WIDERFACE dataset.
- Download annotations (face bounding boxes & five facial landmarks) from Baidu Cloud (password:
fstq
) or Dropbox.
-
Organize the Dataset Directory:
Structure your dataset directory as follows:
data/ βββ widerface/ βββ train/ β βββ images/ β βββ label.txt βββ val/ βββ images/ βββ wider_val.txt
Note
wider_val.txt
only includes val file names but not label information.
There is also an organized dataset (as shown above): Link from Google Drive or Baidu Cloud (password: ruck). Thanks to biubug6 for the organized dataset.
To train a model, specify the network backbone:
python train.py --network slim # Replace 'slim' with your choice of model
Available Models:
retinaface
slim
rfb
Inference the model using:
python detect.py --network retinaface --weights weights/retinaface.pth
slim weights/slim.pth
rfb weights/rfb.pth
- RetinaFace: 459
- RFB: 430
- Slim: 384
- Clone the WiderFace evaluation repository inside the
tiny-face-pytorch
folder:git clone https://github.com/yakhyo/widerface_evaluation
- Navigate to the
widerface_evaluation
folder and build the required extension:cd widerface_evaluation python3 setup.py build_ext --inplace
- Return to the
tiny-face-pytorch
folder after installation is complete:cd ..
Run the following command to evaluate your model with WiderFace, specifying the model architecture (mobilenetv1_0.25
in this example) and the path to the trained weights. Predictions will be stored in widerface_txt
inside the widerface_evaluation
folder.
python evaluate_widerface.py --network retinaface --weights weights/retinaface.pth
slim weights/slim.pth
rfb weights/rfb.pth
After generating predictions, navigate to the widerface_evaluation folder and run the following command to compare predictions with the ground truth annotations:
cd widerface_evaluation
python evaluation.py -p widerface_txt -g ground_truth
Note
Ensure ground_truth
is the path to the WiderFace ground truth directory.
This will begin the evaluation process of your model on the WiderFace dataset.
This project is licensed under the MIT License. See the LICENSE file for details.