/face-detector-inference-playground

A rust inference tool to detect faces using buffalo model.

Primary LanguageRust

Face Detection inference tool

Warning: this is just a toy project for playing around with buffalo face recognition model.

A blazingly-fast face detection inference tool built in Rust using ONNX Runtime. This tool can process both single images and directories of images, providing flexible output options for detection results.

img/sample.jpg img/output.jpg

Building from source

git clone https://github.com/your-username/face-detection-rs.git
cd face-detection-rs
cargo build --release

Usage

Obtain buffalo model from InsightFace. Note: this was tested with buffalo_l. Extract the det_10g.onnx file from the downloaded zip file and place it in the same directory as the executable. Prepare your images (note: 640x640 is recommended) and run the tool.

Basic Command Structure

face-detection -i <INPUT> [-o <OUTPUT>] [-t <THRESHOLD>] [-v]

Command Line Options

  • -i, --input <PATH>: Input image or directory path (required)
  • -o, --output <PATH>: Output file or directory path (optional)
  • -t, --threshold <FLOAT>: Detection confidence threshold (default: 0.5)
  • -v, --verbose: Print detection details to console
  • -m, --model: Model ONNX file path (default: det_10g.onnx)
  • -h, --help: Show help information
  • -V, --version: Show version information

Examples

  1. Process a single image and save with detection boxes:
face-detection -i image.jpg -o output.jpg -t 0.6
  1. Process an image and only print detections:
face-detection -i image.jpg -v
  1. Process all images in a directory and save results:
face-detection -i ./images -o ./processed -v
  1. Process directory and only print detections:
face-detection -i ./images -v