Face Detection models

The Face Detection services work on pretrained models of the STM32 model zoo, which you can find in the ST Edge AI Model Explorer, or on your own models. There is no training service. This page lists the supported model families, the pretrained models that can be loaded by name, and the model formats accepted by each service.

1. Model families

Set model.model_type to the family of your model. It is required in every configuration, also when you use model_path, because it selects the post-processing that decodes the model outputs.

model_type

Model

Detected keypoints

Zoo model

yunet

YuNet

5 (2 eyes, nose, 2 mouth corners)

yunetn, 320x320 input

facedetect_front

BlazeFace Front

6 (2 eyes, 2 ears, nose, mouth)

blazeface_front, 128x128 input

Both families are supported by all the operation modes of Face Detection. The footprints and inference times of the zoo models can be found in the ST Edge AI Model Explorer.

2. Load a pretrained model by name

Select a pretrained model with model_name, input_shape, model_precision, and the dataset it was trained on, widerface. Face Detection resolves these values to a pretrained model file, through the registry models_urls.py. Only the combinations below are registered; any other combination stops with a “No registered pretrained model” error.

model_name

model_type

model_precision

input_shape

File

yunetn

yunet

float32

(3, 320, 320)

.onnx

yunetn

yunet

w8a8_ptq

(3, 320, 320)

.onnx (QDQ, 8-bit)

blazeface_front

facedetect_front

float32

(3, 128, 128)

.onnx

blazeface_front

facedetect_front

w8a8_ptq

(128, 128, 3)

.tflite (8-bit)

model:
  model_type: yunet
  model_name: yunetn
  input_shape: (3, 320, 320)
  model_precision: w8a8_ptq
  pretrained_dataset_name: widerface    # optional if dataset.dataset_name is widerface
  • The input shape is channel-first for ONNX models and channel-last for TFLite models, so the float and the quantized BlazeFace models are registered with different shapes.

  • If pretrained_dataset_name is not set, it is taken from dataset.dataset_name, which must then be widerface. Set pretrained_dataset_name when the configuration has no dataset.dataset_name, as in the benchmarking and deployment examples.

  • If model_precision is not set, w8a8_ptq is used. In quantization and in the chained modes that quantize, the float model (float32) is loaded whatever the value you set.

  • model_name and model_path cannot be used together.

3. Use your own model

Set model_path to the model file instead of model_name, input_shape, and model_precision. You can also use the models of the zoo directly: download their model files from the ST Edge AI Model Explorer.

model:
  model_type: yunet
  model_path: /path/to/model.onnx

Supported model formats per operation mode:

Operation mode

Models

evaluation, prediction

Keras ( .keras, .h5), TFLite, ONNX. On the host, TFLite models are supported for facedetect_front only: use an ONNX model for yunet.

quantization and the chains that quantize

Float Keras model ( TFlite_converter or Onnx_quantizer) or float ONNX model ( Onnx_quantizer). TFLite models cannot be quantized.

benchmarking

Keras, TFLite, ONNX

deployment

ONNX for yunet, TFLite for facedetect_front

The model must have the input and output layout of the zoo model of its family, because the post-processing decodes the outputs of the YuNet (3 strides, 4 outputs each) or BlazeFace Front (SSD-style, 4 outputs) architectures.