BlazeFaceONNX Android
Real-time face detection on Android using BlazeFace and ONNX Runtime. Supporting live camera inference and image-based detection directly on device.
BLAZEFACE DETECTOR
Live Detection
Model
ONNX
Runtime
On-device
01 / Overview
Project Overview
An Android implementation of BlazeFace that brings lightweight face detection to mobile devices using ONNX Runtime.
Face Detection on Android
This project integrates a pretrained BlazeFace ONNX model into an Android application. It supports real-time face detection from camera frames and image inference using pictures selected from device storage.
The application also separates debugging functionality from the main inference pipeline, making it easier to test camera input and model inference independently.
Model Information
02 / Capabilities
Application Features
Two primary inference workflows, supported by dedicated debugging utilities.
Real-time Camera Inference
Perform face detection continuously using live camera frames directly on Android devices.
Storage-based Inference
Select images from device storage and run face detection without requiring a live camera feed.
ONNX Runtime
Run the pretrained BlazeFace model using ONNX Runtime for on-device inference.
Dedicated Debugging
Separate camera checking and standalone inference pages to simplify development and troubleshooting.
03 / Architecture
Inference Workflow
The application supports two input sources that share the same model inference and post-processing stages.
Camera Inference
Real-time pipeline
Camera Input
Capture live camera frames.
Preprocessing
Prepare image frames for model input.
ONNX Runtime
Execute BlazeFace inference.
Post-processing
Decode predictions and filter detections.
Detection Results
Display detected faces.
Storage Inference
Image-based pipeline
Device Storage
Select an image from the device.
Preprocessing
Prepare the selected image for inference.
ONNX Runtime
Execute BlazeFace inference.
Post-processing
Decode predictions and filter detections.
Detection Results
Display detected faces.
04 / Development
Debugging Pages
Separate testing environments help isolate problems without running the complete inference pipeline.
Camera Inference
Real-time face detection using camera input.
camera_inference/Read Storage
Load images from device storage for face detection.
read_storage/Camera Check
Independent camera functionality and input debugging.
camera_check/Simple Inference
Test ONNX model inference independently.
simple_inference/Why separate debugging pages?
Camera Check focuses on camera functionality, while Simple Inference focuses on model execution. This separation helps identify whether an issue comes from camera handling, image preprocessing, or ONNX inference.
05 / Model Integration
From PyTorch to Android
The Android application uses the ONNX model exported from the companion BlazeFace conversion project.
Source Repository
BlazeFace ONNX
PyTorch model adaptation and ONNX conversion
PyTorch
Original pretrained model
ONNX Export
Simplified ONNX-compatible implementation
Android
On-device model inference
Model Assets
blaze_face.onnxExported ONNX modelblaze_face.onnx.dataExternal tensor data06 / Codebase
Project Structure
A look at the main Android source directories and model assets.
src/main/
Main Components
assets/Model files and external tensor data.
blaze_face/Inference, camera, storage, and debugging pages.
ui/theme/Application theme configuration.
MainActivity.ktAndroid application entry point.
Native Android
Kotlin implementation
Model execution is integrated into the Android application, allowing inference to run locally without requiring a separate inference server.