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 |
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:
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 model inference result.
tiny-face-pytorch
folder:
git clone https://github.com/yakhyo/widerface_evaluation
widerface_evaluation
folder and build the required extension:
cd widerface_evaluation
python3 setup.py build_ext --inplace
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]
Ensureground_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.