CoolFace
Modelpublic

STMicroelectronics/fdmobilenet

sourceHugging Faceotherupdated 8mo agoView on Hugging Face
0likes
Model Card

Fd-MobileNet

Use case : Image classification

Model description

Fd-MobileNet stands for Fast-downsampling MobileNet. It was initially introduced in this paper. This family of networks, inspired from Mobilenet, provides a good accuracy on various image classification tasks for very limited computational budgets. Thus it is an interesting solution for deep learning at the edge. As stated by the authors, the key idea is to apply a fast downsampling strategy to MobileNet framework with only half the layers of the original MobileNet. This design remarkably reduces the computational cost as well as the inference time.

The hyperparameter 'alpha' controls the width of the network, also denoted as width multiplier. It proportionally adjusts each layer width. Authorized values for 'alpha' are 0.25, 0.5, 0.75, 1.0. The model is quantized in int8 using Tensorflow Lite converter.

Performances of a ST custom model derived from Fd-MobileNet is also proposed below. It is named ST FdMobileNet v1. It is inspired from original FdMobilenet. Instead of having one unique 'alpha' dimensioning the width of the network, we use a list of 'alpha' values in order to give more or less importance to each of the individual sub-blocks. It is slightly more complex than FdMobilenet 0.25 due to higher number of channels for some sub-blocks but provides better accuracies. We believe it is a good compromise between size, complexity and accuracy for this family of networks.

Network information

Network InformationValue
FrameworkTensorFlow Lite
Params alpha=0.25125477
Quantizationint8
Paperhttps://arxiv.org/pdf/1802.03750.pdf

The models are quantized using tensorflow lite converter.

Network inputs / outputs

For an image resolution of NxM and P classes and 0.25 alpha parameter :

Input ShapeDescription
(1, N, M, 3)Single NxM RGB image with UINT8 values between 0 and 255
Output ShapeDescription
(1, P)Per-class confidence for P classes

Recommended platform

PlatformSupportedRecommended
STM32L0[][]
STM32L4[x][]
STM32U5[x][]
STM32H7[x][x]
STM32MP1[x][x]
STM32MP2[x][]
STM32N6[x][]

Performances

Metrics

  • Measures are done with default STM32Cube.AI configuration with enabled input / output allocated option.
  • tfs stands for "training from scratch", meaning that the model weights are randomly initialized before the training and all layers are actually trained.

Reference NPU memory footprint on food101 dataset (see Accuracy for details on dataset)

ModelFormatResolutionSeriesInternal RAM (KiB)External RAM (KiB)Weights Flash (KiB)STEdgeAI Core version
FdMobileNet 0.25 tfsInt8224x224x3STM32N62940.0148.343.0.0
ST FdMobileNet v1 tfsInt8224x224x3STM32N63430.0167.23.0.0
FdMobileNet 0.25 tfsInt8128x128x3STM32N6960.0146.663.0.0
ST FdMobileNet v1 tfsInt8128x128x3STM32N61120.0163.833.0.0

Reference NPU inference time on food101 dataset (see Accuracy for details on dataset)

ModelFormatResolutionBoardExecution EngineInference time (ms)Inf / secSTEdgeAI Core version
FdMobileNet 0.25 tfsInt8224x224x3STM32N6570-DKNPU/MCU1.29775.193.0.0
ST FdMobileNet v1 tfsInt8224x224x3STM32N6570-DKNPU/MCU1.67598.83.0.0
FdMobileNet 0.25 tfsInt8128x128x3STM32N6570-DKNPU/MCU0.751333.333.0.0
ST FdMobileNet v1 tfsInt8128x128x3STM32N6570-DKNPU/MCU0.91111.113.0.0

Reference MCU memory footprints based on Flowers dataset (see Accuracy for details on dataset)

ModelFormatResolutionSeriesActivation RAMRuntime RAMWeights FlashCode FlashTotal RAMTotal FlashSTEdgeAI Core version
FdMobileNet 0.25 tfsInt8224x224x3STM32H7157.03 KiB0.3 KiB128.32 KiB29.99 KiB157.33 KiB158.31 KiB3.0.0
ST FdMobileNet v1 tfsInt8224x224x3STM32H7211.64 KiB0.3 KiB144.93 KiB31.18 KiB211.94 KiB176.11 KiB3.0.0
FdMobileNet 0.25 tfsInt8128x128x3STM32H756.16 KiB0.3 KiB128.32 KiB29.95 KiB56.46 KiB158.27 KiB3.0.0
ST FdMobileNet v1 tfsInt8128x128x3STM32H774.23 KiB0.3 KiB144.93 KiB31.13 KiB74.53 KiB176.06 KiB3.0.0

Reference MCU inference time based on Flowers dataset (see Accuracy for details on dataset)

ModelFormatResolutionBoardExecution EngineFrequencyInference time (ms)STEdgeAI Core version
FdMobileNet 0.25 tfsInt8224x224x3STM32H747I-DISCO1 CPU400 MHz64.56 ms3.0.0
ST FdMobileNet v1 tfsInt8224x224x3STM32H747I-DISCO1 CPU400 MHz113.66 ms3.0.0
FdMobileNet 0.25 tfsInt8128x128x3STM32H747I-DISCO1 CPU400 MHz21.34 ms3.0.0
ST FdMobileNet v1 tfsInt8128x128x3STM32H747I-DISCO1 CPU400 MHz36.04 ms3.0.0
ST FdMobileNet v1 tfsInt8224x224x3STM32F769I-DISCO1 CPU216 MHz176.5 ms3.0.0
ST FdMobileNet v1 tfsInt8128x128x3STM32F769I-DISCO1 CPU216 MHz59.29 ms3.0.0

Reference MPU inference time based on Flowers dataset (see Accuracy for details on dataset)

ModelFormatResolutionQuantizationBoardExecution EngineFrequencyInference time (ms)%NPU%GPU%CPUX-LINUX-AI versionFramework
FdMobileNet 0.25 tfsInt8224x224x3per-channel**STM32MP257F-DK2NPU/GPU800 MHz6.4815.2584.750v6.1.0OpenVX
ST FdMobileNet v1 tfsInt8224x224x3per-channel**STM32MP257F-DK2NPU/GPU800 MHz7.8216.2983.710v6.1.0OpenVX
FdMobileNet 0.25 tfsInt8128x128x3per-channel**STM32MP257F-DK2NPU/GPU800 MHz2.0118.2581.750v6.1.0OpenVX
ST FdMobileNet v1 tfsInt8128x128x3per-channel**STM32MP257F-DK2NPU/GPU800 MHz2.7813.8086.200v6.1.0OpenVX
FdMobileNet 0.25 tfsInt8224x224x3per-channelSTM32MP157F-DK22 CPU800 MHz24.96NANA100v6.1.0TensorFlowLite 2.18.0
ST FdMobileNet v1 tfsInt8224x224x3per-channelSTM32MP157F-DK22 CPU800 MHz43.05NANA100v6.1.0TensorFlowLite 2.18.0
FdMobileNet 0.25 tfsInt8128x128x3per-channelSTM32MP157F-DK22 CPU800 MHz8.96NANA100v6.1.0TensorFlowLite 2.18.0
ST FdMobileNet v1 tfsInt8128x128x3per-channelSTM32MP157F-DK22 CPU800 MHz14.19NANA100v6.1.0TensorFlowLite 2.18.0
FdMobileNet 0.25 tfsInt8224x224x3per-channelSTM32MP135F-DK21 CPU1000 MHz34.86NANA100v6.1.0TensorFlowLite 2.18.0
ST FdMobileNet v1 tfsInt8224x224x3per-channelSTM32MP135F-DK21 CPU1000 MHz63.78NANA100v6.1.0TensorFlowLite 2.18.0
FdMobileNet 0.25 tfsInt8128x128x3per-channelSTM32MP135F-DK21 CPU1000 MHz11.86NANA100v6.1.0TensorFlowLite 2.18.0
ST FdMobileNet v1 tfsInt8128x128x3per-channelSTM32MP135F-DK21 CPU1000 MHz20.34NANA100v6.1.0TensorFlowLite 2.18.0

To get the most out of MP25 NPU hardware acceleration, please use per-tensor quantization**

Note:** On STM32MP2 devices, per-channel quantized models are internally converted to per-tensor quantization by the compiler using an entropy-based method. This may introduce a slight loss in accuracy compared to the original per-channel models.

Accuracy with Flowers dataset

Dataset details: http://download.tensorflow.org/exampleimages/flowerphotos.tgz , License CC - BY 2.0 Number of classes: 5, 3670 files

ModelFormatResolutionTop 1 Accuracy (%)
FdMobileNet 0.25 tfsFloat224x224x386.92
FdMobileNet 0.25 tfsInt8224x224x387.06
ST FdMobileNet v1 tfsFloat224x224x389.51
ST FdMobileNet v1 tfsInt8224x224x388.83
FdMobileNet 0.25 tfsFloat128x128x384.6
FdMobileNet 0.25 tfsInt8128x128x384.2
ST FdMobileNet v1 tfsFloat128x128x387.87
ST FdMobileNet v1 tfsInt8128x128x387.6

Accuracy with Plant dataset

Dataset details: https://data.mendeley.com/datasets/tywbtsjrjv/1 , License CC0 1.0 Number of classes: 39, number of files: 55448

ModelFormatResolutionTop 1 Accuracy (%)
FdMobileNet 0.25 tfsFloat224x224x399.9
FdMobileNet 0.25 tfsInt8224x224x399.8
ST FdMobileNet v1 tfsFloat224x224x399.59
ST FdMobileNet v1 tfsInt8224x224x399.4
FdMobileNet 0.25 tfsFloat128x128x399.05
FdMobileNet 0.25 tfsInt8128x128x398.55
ST FdMobileNet v1 tfsFloat128x128x399.58
ST FdMobileNet v1 tfsInt8128x128x399.8

Accuracy with Food-101 dataset

Dataset details: https://data.vision.ee.ethz.ch/cvl/datasets_extra/food-101/, Number of classes: 101, number of files: 101000

ModelFormatResolutionTop 1 Accuracy (%)
FdMobileNet 0.25 tfsFloat224x224x363.03
FdMobileNet 0.25 tfsInt8224x224x362.11
ST FdMobileNet v1 tfsFloat224x224x369.31
ST FdMobileNet v1 tfsInt8224x224x368.73
FdMobileNet 0.25 tfsFloat128x128x351.12
FdMobileNet 0.25 tfsInt8128x128x350.26
ST FdMobileNet v1 tfsFloat128x128x359.07
ST FdMobileNet v1 tfsInt8128x128x358.15

Retraining and Integration in a simple example:

Please refer to the stm32ai-modelzoo-services GitHub here

References

<a id="1">[1]</a> "Tfflowers : tensorflow datasets," TensorFlow. [Online]. Available: https://www.tensorflow.org/datasets/catalog/tfflowers.

<a id="2">[2]</a> J, ARUN PANDIAN; GOPAL, GEETHARAMANI (2019), "Data for: Identification of Plant Leaf Diseases Using a 9-layer Deep Convolutional Neural Network", Mendeley Data, V1, doi: 10.17632/tywbtsjrjv.1

<a id="3">[3]</a> L. Bossard, M. Guillaumin, and L. Van Gool, "Food-101 -- Mining Discriminative Components with Random Forests." European Conference on Computer Vision, 2014.