All Projects → atomashpolskiy → Rustface

atomashpolskiy / Rustface

Licence: other
Face detection library for the Rust programming language

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rustface

Jeelizfacefilter
Javascript/WebGL lightweight face tracking library designed for augmented reality webcam filters. Features : multiple faces detection, rotation, mouth opening. Various integration examples are provided (Three.js, Babylon.js, FaceSwap, Canvas2D, CSS3D...).
Stars: ✭ 2,042 (+659.11%)
Mutual labels:  library, face-detection
Sod
An Embedded Computer Vision & Machine Learning Library (CPU Optimized & IoT Capable)
Stars: ✭ 1,460 (+442.75%)
Mutual labels:  library, face-detection
Discordeno
Discord API library for Deno
Stars: ✭ 254 (-5.58%)
Mutual labels:  library
Prdownloader
PRDownloader - A file downloader library for Android with pause and resume support
Stars: ✭ 2,947 (+995.54%)
Mutual labels:  library
Node Window Manager
Manage windows in Windows, macOS and Linux using Node.js
Stars: ✭ 263 (-2.23%)
Mutual labels:  library
Floyd
A raft consensus implementation that is simply and understandable
Stars: ✭ 259 (-3.72%)
Mutual labels:  library
Public Transport Enabler
Unleash public transport data in your Java project.
Stars: ✭ 264 (-1.86%)
Mutual labels:  library
Stripe
A comprehensive PHP Library for the Stripe.
Stars: ✭ 256 (-4.83%)
Mutual labels:  library
Cordova Plugin Dialogs
Apache Cordova Plugin dialogs
Stars: ✭ 267 (-0.74%)
Mutual labels:  library
Hypre
Parallel solvers for sparse linear systems featuring multigrid methods.
Stars: ✭ 260 (-3.35%)
Mutual labels:  library
Ristretto
A high performance memory-bound Go cache
Stars: ✭ 3,584 (+1232.34%)
Mutual labels:  library
Incrementproductview
Interesting concept of products incrementation
Stars: ✭ 262 (-2.6%)
Mutual labels:  library
Reachability
You can easily access the top of the screen in Android. Like a iPhone 6 & 6 Plus.
Stars: ✭ 259 (-3.72%)
Mutual labels:  library
Zformat
The Hoa\Zformat library.
Stars: ✭ 265 (-1.49%)
Mutual labels:  library
Trianglify
Highly customizable library to generate beautiful triangle art views for android.
Stars: ✭ 259 (-3.72%)
Mutual labels:  library
Landscapist
🍂 Jetpack Compose image loading library which can fetch and display network images using Glide, Coil, and Fresco.
Stars: ✭ 264 (-1.86%)
Mutual labels:  library
Ngx Smart Modal
Modal/Dialog component crafted for Angular
Stars: ✭ 256 (-4.83%)
Mutual labels:  library
Ui Neumorphism
📕 React component library designed on the "new skeuomorphism" or "neumorphism" UI/UX trend.
Stars: ✭ 258 (-4.09%)
Mutual labels:  library
Rapidcsv
C++ CSV parser library
Stars: ✭ 261 (-2.97%)
Mutual labels:  library
I Use Arch Btw
"I use Arch btw" but it's a Turing-complete programming language.
Stars: ✭ 266 (-1.12%)
Mutual labels:  library

Rustface


SeetaFace detection library for the Rust programming language

Bt Example Example of demo program output

crates.io docs.rs Linux build License

About

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.

Read more...

Performance

You can run the criterion benchmarks using cargo bench.

Using nightly Rust

The 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.

rustup toolchain install nightly-2018-01-15
rustup default nightly-2018-01-15

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):

Multi-threaded (Rayon threads set to 2)
LTO enabled

* Rustface *
samples (ms): 787,789,795,795,787,785,791,799,795,788
mean (ms): 791.1
stddev (ms): 4.39

Usage example

extern crate rustface;

use rustface::{Detector, FaceInfo, ImageData};

fn main() {
    let mut detector = rustface::create_detector("/path/to/model").unwrap();
    detector.set_min_face_size(20);
    detector.set_score_thresh(2.0);
    detector.set_pyramid_scale_factor(0.8);
    detector.set_slide_window_step(4, 4);
    
    let mut image = ImageData::new(bytes, width, height);
    for face in detector.detect(&mut image).into_iter() {
        // print confidence score and coordinates
        println!("found face: {:?}", face);
    }
}

How to build

The project is a library crate and also contains a runnable example for demonstration purposes.

Then just use the standard Cargo build command:

cargo build --release

Run demo

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.

The simplest way to run the demo is to use the bin/test.sh script:

./bin/test.sh <path-to-image>

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.

# empirically found to be the sweet spot for the number of threads
export RAYON_NUM_THREADS=2
cargo run --release --example image_demo model/seeta_fd_frontal_v1.0.bin <path-to-image>

Note that Rayon can be disabled entirely at compile time by providing the --no-default-features flag.

TODO

  • 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)

Authors

  • Andrei Tomashpolskiy @atomashpolskiy

    Original developer and maintainer

  • Jurriaan BW @jjhbw

    Contributor and chief maintainer

  • Ashley @expenses

    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

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].