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 |
Detected keypoints |
Zoo model |
|---|---|---|---|
|
|
YuNet |
5 (2 eyes, nose, 2 mouth corners) |
|
|
|
BlazeFace Front |
6 (2 eyes, 2 ears, nose, mouth) |
|
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.
|
|
|
|
|
File |
|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_nameis not set, it is taken fromdataset.dataset_name, which must then bewiderface. Setpretrained_dataset_namewhen the configuration has nodataset.dataset_name, as in the benchmarking and deployment examples.If
model_precisionis not set,w8a8_ptqis used. Inquantizationand in the chained modes that quantize, the float model (float32) is loaded whatever the value you set.model_nameandmodel_pathcannot 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 |
|---|---|
|
|
Keras (
|
|
|
Float Keras model (
|
|
|
Keras, TFLite, ONNX |
|
|
ONNX for
|
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.