STM32N6 NPU Deployment — Politecnico di Milano  1.0
Documentation for Neural Network Deployment on STM32N6 NPU - Politecnico di Milano 2024-2025
stm32ai_main.py File Reference

Main entry point for the STM32AI Model Zoo Services pipeline for pose estimation. More...

Go to the source code of this file.

Namespaces

 stm32ai_main
 

Functions

None stm32ai_main.chain_qd (DictConfig cfg=None, str float_model_path=None, tf.data.Dataset train_ds=None, tf.data.Dataset quantization_ds=None)
 
None stm32ai_main.chain_eqeb (DictConfig cfg=None, str float_model_path=None, tf.data.Dataset train_ds=None, tf.data.Dataset valid_ds=None, tf.data.Dataset quantization_ds=None, tf.data.Dataset test_ds=None)
 
None stm32ai_main.chain_qb (DictConfig cfg=None, str float_model_path=None, tf.data.Dataset train_ds=None, tf.data.Dataset quantization_ds=None)
 
None stm32ai_main.chain_eqe (DictConfig cfg=None, str float_model_path=None, tf.data.Dataset train_ds=None, tf.data.Dataset valid_ds=None, tf.data.Dataset quantization_ds=None, tf.data.Dataset test_ds=None)
 
None stm32ai_main.chain_tqeb (DictConfig cfg=None, tf.data.Dataset train_ds=None, tf.data.Dataset valid_ds=None, tf.data.Dataset quantization_ds=None, tf.data.Dataset test_ds=None)
 
None stm32ai_main.chain_tqe (DictConfig cfg=None, tf.data.Dataset train_ds=None, tf.data.Dataset valid_ds=None, tf.data.Dataset quantization_ds=None, tf.data.Dataset test_ds=None)
 
None stm32ai_main.process_mode (str mode=None, DictConfig configs=None, tf.data.Dataset train_ds=None, tf.data.Dataset valid_ds=None, tf.data.Dataset quantization_ds=None, tf.data.Dataset test_ds=None, Optional[str] float_model_path=None, Optional[bool] fake=False)
 
None stm32ai_main.main (DictConfig cfg)
 

Variables

 stm32ai_main.SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 Add the parent directory to sys.path so that shared modules in common/ are importable. More...
 
 stm32ai_main.parser = argparse.ArgumentParser()
 
 stm32ai_main.type
 
 stm32ai_main.str
 
 stm32ai_main.default
 
 stm32ai_main.help
 
 stm32ai_main.nargs
 
 stm32ai_main.args = parser.parse_args()
 

Detailed Description

Main entry point for the STM32AI Model Zoo Services pipeline for pose estimation.

This script orchestrates the full lifecycle of a neural network model for deployment on STM32 microcontrollers, specifically the STM32N6570-DK board equipped with an NPU.

The pipeline supports the following operation modes:

  • training: Train a model from scratch or fine-tune a pre-trained one.
  • evaluation: Evaluate model accuracy on a validation or test dataset.
  • quantization: Convert a float32 model to int8 for embedded deployment.
  • benchmarking: Measure inference latency and memory usage on the target board.
  • deployment: Generate C code, compile firmware and flash it onto the STM32N6 board.
  • prediction: Run inference on new data using the deployed model.

Composite chains combine multiple steps in a single command:

  • chain_tqeb: Training → Quantization → Evaluation → Benchmarking
  • chain_tqe: Training → Quantization → Evaluation
  • chain_eqe: Evaluation → Quantization → Evaluation
  • chain_qb: Quantization → Benchmarking
  • chain_eqeb: Evaluation → Quantization → Evaluation → Benchmarking
  • chain_qd: Quantization → Deployment

The script is configured via a YAML file (user_config.yaml) managed by Hydra. Experiment tracking is handled by MLflow and optionally by ClearML.

Note
This file is part of the STM32AI Model Zoo Services repository by STMicroelectronics. Comments and documentation added for educational purposes as part of the Multidisciplinary Project — Neural Network Deployment on STM32N6 NPU. Politecnico di Milano, A.Y. 2024-2025. Authors: Giacomo Colosio, Sebastiano Colosio

Definition in file stm32ai_main.py.