SeetaFace detection library for the Rust programming language
Example of demo program output
- SEETAFACE C++ – Github repository for the original library
- PYTHON BINDINGS – call Rustface from Python code
- LICENSE – licensed under permissive BSD 2-Clause
SeetaFace Detection is an implementation of Funnel-Structured cascade, which is designed for real-time multi-view face detection. FuSt aims at a good trade-off between accuracy and speed by using a coarse-to-fine structure. It consists of multiple view-specific fast LAB cascade classifiers at early stages, followed by coarse Multilayer Perceptron (MLP) cascades at later stages. The final stage is one unified fine MLP cascade, processing all proposed windows in a centralized style.
You can run the criterion benchmarks using
Using nightly Rust
nightly branch contains a slightly (~20%) faster version of rustface. This speedup is made possible by using explicit SIMD intrinsics. If you want to use this branch, you need an older nightly toolchain.
Regarding the performance of the
nightly branch: crude manual benchmarking showed that this nightly Rust version of SeetaFace is slightly faster than the original C++ version. In this particular test the Rust version has been 4% faster on average than its C++ counterpart. When using multiple threads and enabling LTO (link-time optimization), Rust performance is a tad better (I observe a 8% boost):
How to build
The project is a library crate and also contains a runnable example for demonstration purposes.
Then just use the standard Cargo
Code for the demo is located in
examples/image_demo.rs file. It performs face detection for a given image and saves the result into a file in the working directory.
You can run the demo using:
Please note that this library makes use of Rayon framework to parallelize some computations. By default, Rayon spawns the same number of threads as the number of CPUs (logicals cores) available. Instead of making things faster, the penalty of switching between so many threads may severely hurt the performance, so it's strongly advised to keep the number of threads small by manually setting
RAYON_NUM_THREADS environment variable.
Note that Rayon can be disabled entirely at compile time by providing the
- Use stable SIMD intrinsics when available
- Benchmark benefit of parallelisation. Compiler improvements may have reduced the relative benefit of parallel processing, especially when running on smaller images. Simplify where possible.
- Parallelize remaining CPU intensive loops
- Tests (it would make sense to start with an integration test for
Detector::detect, based on the results retrieved from the original library)
Andrei Tomashpolskiy @atomashpolskiy
Original developer and maintainer
Jurriaan BW @jjhbw
Contributor and chief maintainer
Contributor. Added the switch from OpenCV to Image.
This library is based on the following works:
Face detection method described in the paper: "Funnel-structured cascade for multi-view face detection with alignment awareness, Shuzhe Wu, Meina Kan, Zhenliang He, Shiguang Shan, Xilin Chen. In Neurocomputing (under review)"
original C++ implementation
Original SeetaFace Detection is released under the BSD 2-Clause license. This project is a derivative work and uses the same license as the original.