sentis-blazeface

Google MediaPipe BlazeFace short-range face detector converted to Unity Inference Engine (Sentis) FP32. Made for selfie / front-camera distances (faces within ~2 m that fill a good part of the frame); detects faces with a bounding box, a confidence score and 6 keypoints.

Files

blazeface_short_fp32.sentis   # image [1, 128, 128, 3] RGB 0-1 (NHWC) -> faces [1, 896, 17]
BlazeFace.cs   # self-contained Unity Sentis inference

Inference

BlazeFace letterboxes any Texture (Texture2D, WebCamTexture, RenderTexture) into the 128x128 model input on the GPU (aspect ratio kept, image top-left aligned), runs the model and decodes the packed output in C# with score thresholding and NMS. Preprocessing is baked into the model, so no manual normalization is needed. Results are in source-texture pixels with the origin at the top-left (y down).

A complete self-contained implementation lives in BlazeFace.cs. Minimal usage:

var detector = new BlazeFace(BackendType.GPUCompute);
detector.Load(modelRoot);            // folder holding blazeface_short_fp32.sentis
detector.Warmup();

foreach (var face in detector.Detect(texture))
{
    // face.Box (Rect, pixels, top-left origin), face.Score, face.Landmarks (6 points)
}

Tune ScoreThreshold (default 0.5) and NmsThreshold (default 0.3) for your scene. For per-frame use (e.g. a WebCamTexture) prefer DetectAsync, which reads the result back without stalling the main thread.

Conversion notes

  • Source: face_detection_short_range.tflite from google-ai-edge/mediapipe (MediaPipe model assets), imported directly by the Sentis LiteRT importer.
  • Preprocessing (x x 2 - 1) is prepended to the graph, and the regressor / classifier outputs are packed into one [1, 896, 17] tensor.
  • Decoding uses the MediaPipe SSD anchors (16x16x2 + 8x8x6, fixed anchor size) and a sigmoid on the score logit. Overlapping boxes are reduced with plain NMS (MediaPipe uses weighted blending).
  • Unity Sentis output matches the source model run in LiteRT on the same input.

License & attribution

Apache-2.0. Converted from the BlazeFace short-range model of google-ai-edge/mediapipe (Apache-2.0). Paper: BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs.

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Paper for Sky-Kim/com.sky.sentis.blazeface