Traffic sign recognition with AI can greatly benefit drivers and city infrastructure managers by improving safety, enhancing the driving experience, and increasing efficiency. By using advanced algorithms, the system can accurately detect and recognize traffic signs in real-time, providing drivers or city supervisors with timely and accurate information about speed limits, traffic signals or road sign mapping.
This can help reduce the risk of accidents caused by human error or distraction, making the roads safer for everyone. Moreover, the integration of this technology into transportation systems and traffic monitoring systems can also improve efficiency and reduce congestion.

Approach

The use case presented is based on a German traffic sign dataset to classify road signs. The solution proposes models trained on a public dataset providing very good accuracy while running on a STM32.
These models were trained thanks to the Python scripts provided in STM32 model zoo (read our tutorial on the training to learn more).

Here, after setting up our STM32 Model Zoo project, we downloaded the dataset and placed it in the appropriate structure. Then we updated the yaml file, which was used to configure the training, with the following settings:

general:
project_name: traffic_sign
dataset:
name: traffic
class_names: ['0001', '0002', ..., '0042']
training_path: datasets/train
validation_path:
test_path: datasets/test

Feel free to adjust those settings according to your use-case.
Finally, we simply ran the "train.py" script.

train.py_python_script train.py_python_script train.py_python_script

 

You will find everything you need in the STM32 model zoo to train and retrain any model with your own data. The models can also be easily deployed on a STM32H747 discovery kit with the Python scripts provided in the repository (read our tutorial on the deployment to learn more).
You can find details of all these steps in our Getting started video.

Sensor

Vision: Camera module bundle (reference: B-CAMS-OMV)

Data

Dataset The German Traffic Sign Recognition Benchmark*
Data format: The dataset is composed of more than 50 000 RGB images divided into 43 classes of traffic signs.

Results

The STM32 model zoo contains several models for image classification, so you can choose the one best suited to your project.
Here, we have trained 2 different models for the same use-case, each with its own performance and memory footprints:
Model MobileNetV2 alpha 0.35
Input size: 128x128x3
Memory footprint of the quantized model:
Total RAM: 272 KB

  • RAM activations: 224 KB
  • RAM runtime: 48 KB


Total Flash: 563 KB

  • Flash weights: 454 KB
  • Estimated flash code: 109 KB


Accuracy:
Float model: 99.87%
Quantized model: 99.57%
Performance on STM32H747 (High-perf) @ 400 MHz 
Inference time: 101 ms
Frame rate:  9.9 fps
Model FDMobileNet
Input size: 128x128x3
Memory footprint of the quantized model:
Total RAM: 65 KB

  • RAM activations: 51 KB
  • RAM runtime: 14 KB


Total Flash: 192 KB

  • Flash weights: 137 KB
  • Estimated flash code: 55 KB


Accuracy:
Float model: 99.78%
Quantized model: 99.51%
Performance on STM32H747 (High-perf) @ 400 MHz 
Inference time: 20.04 ms
Frame rate:  49.9 fps

use-case-stm32-cube-ai-confusion-matrix-traffic-sign-classification use-case-stm32-cube-ai-confusion-matrix-traffic-sign-classification use-case-stm32-cube-ai-confusion-matrix-traffic-sign-classification

 

Confusion matrix of the quantized MobiNetV2 model

Resources

Model repository ST EDGE AI MODEL ZOO

A collection of reference AI models optimized to run on ST devices with associated deployment scripts. The model zoo is a valuable resource to add edge AI capabilities to embedded applications.

ST EDGE AI MODEL ZOO ST EDGE AI MODEL ZOO ST EDGE AI MODEL ZOO

Optimized with STM32Cube.AI

A free STM32Cube expansion package, X-CUBE-AI allows developers to convert pretrained AI algorithms automatically, such as neural network and machine learning models, into optimized C code for STM32.

STM32Cube.AI STM32Cube.AI STM32Cube.AI

Compatible with STM32H7 series

The STM32 family of 32-bit microcontrollers based on the Arm Cortex®-M processor is designed to offer new degrees of freedom to MCU users. It offers products combining very high performance, real-time capabilities, digital signal processing, low-power / low-voltage operation, and connectivity, while maintaining full integration and ease of development.

STM32H7 series STM32H7 series STM32H7 series

You might also be interested by

Entertainment | Image recognition | Vision | STM32Cube.AI | Demo | Tutorial | GitHub | Video

Smart mirrors for fitness: pose estimation and multi-person tracking

Track and analyze users' body movements to provide feedback on exercise with STM32N6 at 28 FPS.

Object detection | Vision | STM32Cube.AI | Idea | GitHub | Video | Dataset | Smart building

Personal protective equipment detection

Detection of personal protective equipment on workers using an object detection AI model.

Smart city | Smart home | Smart office | Context awareness | Vision | AI for Linux | Idea | Video

People detection and counting solution

Optimized computer vision using an MPU running at 8 FPS.