Home

Awesome

FastFace: Lightweight Face Detection Framework

PyPI Documentation Status Downloads PyPI - Python Version PyPI - License

Easy-to-use face detection framework, developed using pytorch-lightning.<br> Checkout documentation for more.

Key Features

Contents

Installation

From PyPI

pip install fastface -U

From source

git clone https://github.com/borhanMorphy/fastface.git
cd fastface
pip install .

Pretrained Models

Pretrained models can be accessable via fastface.FaceDetector.from_pretrained(<name>)

NameArchitectureConfigurationParametersModel SizeLink
lffd_originallffdoriginal2.3M9mbweights
lffd_slimlffdslim1.5M6mbweights

Demo

Using package

import fastface as ff
import imageio
from pytorch_lightning.utilities.model_summary import ModelSummary

# load image as RGB
img = imageio.imread("<your_image_file_path>")[:,:,:3]

# build model with pretrained weights
model = ff.FaceDetector.from_pretrained("lffd_original")
# model: pl.LightningModule

# get model summary
ModelSummary(model, max_depth=1)

# set model to eval mode
model.eval()

# [optional] move model to gpu
model.to("cuda")

# model inference
preds, = model.predict(img, det_threshold=.8, iou_threshold=.4)
# preds: {
#    'boxes': [[xmin, ymin, xmax, ymax], ...],
#    'scores':[<float>, ...]
# }

Using demo.py script

python demo.py --model lffd_original --device cuda --input <your_image_file_path>

sample output; alt text

Benchmarks

Following results are obtained with this repository

WIDER FACE

validation set results

NameEasyMediumHard
lffd_original0.8930.8660.758
lffd_slim0.8660.8540.742

Tutorials

References

Citations

@inproceedings{LFFD,
    title={LFFD: A Light and Fast Face Detector for Edge Devices},
    author={He, Yonghao and Xu, Dezhong and Wu, Lifang and Jian, Meng and Xiang, Shiming and Pan, Chunhong},
    booktitle={arXiv:1904.10633},
    year={2019}
}