Skip to content

Commit 291581a

Browse files
committed
Release AI-ModelZoo-2.1.1:
- Fixed some bugs. - Added more detailed information in README files. - Updated development cloud benchmark notebook to include MPU boards. Signed-off-by: khaoula boutiche <[email protected]>
1 parent 2c47810 commit 291581a

File tree

60 files changed

+1740
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1740
-275
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ to train and deploy the models.
3131
</details>
3232
<details open><summary><b>2.1:</b></summary>
3333

34-
* Included additional models compatible with the `STM32MP257F-DK2` board.
34+
* Included additional models compatible with the [STM32MP257F-EV1](https://www.st.com/en/evaluation-tools/stm32mp257f-ev1) board.
3535
* Added support for per-tensor quantization.
3636
* Integrated support for `ONNX model` quantization and evaluation.
3737
* Included support for `STEdgeAI` (STM32Cube.AI v9.1.0 and subsequent versions).
@@ -59,7 +59,7 @@ to train and deploy the models.
5959
| [MobileNet v1 0.25](image_classification/pretrained_models/mobilenetv1/README.md) | 96x96x1<br> 96x96x3<br> 224x224x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
6060
| [MobileNet v1 0.5](image_classification/pretrained_models/mobilenetv1/README.md) | 224x224x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
6161
| [MobileNet v2 0.35](image_classification/pretrained_models/mobilenetv2/README.md) | 128x128x3<br> 224x224x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
62-
| [MobileNet v2 1.0](image_classification/pretrained_models/mobilenetv2/README.md) | 224x224x3 | Full IC Services | STM32MP257F-DK2<br> |
62+
| [MobileNet v2 1.0](image_classification/pretrained_models/mobilenetv2/README.md) | 224x224x3 | Full IC Services | [STM32MP257F-EV1](./X-LINUX-AI_application_code/image_classification/STM32MP2/README.md)<br> |
6363
| [ResNet8 v1](image_classification/pretrained_models/resnetv1/README.md) | 32x32x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
6464
| [ST ResNet8](image_classification/pretrained_models/resnetv1/README.md) | 32x32x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
6565
| [ResNet32 v1](image_classification/pretrained_models/resnetv1/README.md) | 32x32x3 | Full IC Services | [STM32H747I-DISCO](stm32ai_application_code/image_classification/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> [NUCLEO-H743ZI2](stm32ai_application_code/image_classification/Application/NUCLEO-H743ZI2) with B-CAMS-OMV camera daughter board<br> |
@@ -79,8 +79,8 @@ to train and deploy the models.
7979
| Models | Input Resolutions | Supported Services | Targets for deployment |
8080
|--------------------|------------------|-----------------------|-------------------|
8181
| [ST SSD MobileNet v1 0.25](object_detection/pretrained_models/st_ssd_mobilenet_v1/README.md) | 192x192x3<br> 224x224x3<br> 256x256x3<br> | Full OD Services | [STM32H747I-DISCO](stm32ai_application_code/object_detection/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> |
82-
| [SSD MobileNet v2 fpn lite 0.35](object_detection/pretrained_models/ssd_mobilenet_v2_fpnlite/README.md) | 192x192x3<br> 224x224x3<br> 256x256x3<br> 416x416x3 | Full OD Services | [STM32H747I-DISCO](stm32ai_application_code/object_detection/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> STM32MP257F-DK2 <br> |
83-
| [SSD MobileNet v2 fpn lite 1.0](object_detection/pretrained_models/ssd_mobilenet_v2_fpnlite/README.md) | 256x256x3<br> 416x416x3 | Full OD Services | STM32MP257F-DK2 |
82+
| [SSD MobileNet v2 fpn lite 0.35](object_detection/pretrained_models/ssd_mobilenet_v2_fpnlite/README.md) | 192x192x3<br> 224x224x3<br> 256x256x3<br> 416x416x3 | Full OD Services | [STM32H747I-DISCO](stm32ai_application_code/object_detection/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> or <br>[STM32MP257F-EV1](./X-LINUX-AI_application_code/object_detection/STM32MP2/README.md) <br> |
83+
| [SSD MobileNet v2 fpn lite 1.0](object_detection/pretrained_models/ssd_mobilenet_v2_fpnlite/README.md) | 256x256x3<br> 416x416x3 | Full OD Services | [STM32MP257F-EV1](./X-LINUX-AI_application_code/object_detection/STM32MP2/README.md) |
8484
| [ST Yolo LC v1](object_detection/pretrained_models/st_yolo_lc_v1/README.md) | 192x192x3<br> 224x224x3<br> 256x256x3<br> | Full OD Services | [STM32H747I-DISCO](stm32ai_application_code/object_detection/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> |
8585
| [Tiny Yolo v2](object_detection/pretrained_models/tiny_yolo_v2/README.md) | 224x224x3<br> 416x416x3<br> | Full OD Services | [STM32H747I-DISCO](stm32ai_application_code/object_detection/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br> |
8686

@@ -93,20 +93,20 @@ to train and deploy the models.
9393
[Pose Estimation use case](pose_estimation)
9494
| Models | Input Resolutions | Supported Services | Targets for deployment |
9595
|--------------------|------------------|-----------------------|-------------------|
96-
| [Yolo v8 pose](pose_estimation/pretrained_models/yolov8_pose/README.md) | 256x256x3<br> | Evaluation / Benchmarking / Prediction / Deployment | STM32MP257F-DK2 <br> |
97-
| [MoveNet 17 kps](pose_estimation/pretrained_models/movenet/README.md) | 192x192x3<br> 256x256x3<br> | Evaluation / Quantization / Benchmarking / Prediction | [STM32H747I-DISCO](stm32ai_application_code/pose_estimation/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br>|
98-
| [ST MoveNet 13 kps](pose_estimation/pretrained_models/movenet/README.md) | 192x192x3<br> | Evaluation / Quantization / Benchmarking / Prediction | [STM32H747I-DISCO](stm32ai_application_code/pose_estimation/Application/STM32H747I-DISCO) with B-CAMS-OMV camera daughter board<br>|
96+
| [Yolo v8 n pose](pose_estimation/pretrained_models/yolov8n_pose/README.md) | 256x256x3<br> | Evaluation / Benchmarking / Prediction / Deployment | [STM32MP257F-EV1](./X-LINUX-AI_application_code/pose_estimation/STM32MP2/README.md) <br> |
97+
| [MoveNet 17 kps](pose_estimation/pretrained_models/movenet/README.md) | 192x192x3<br> 224x224x3<br> 256x256x3<br> | Evaluation / Quantization / Benchmarking / Prediction | N/A <br>|
98+
| [ST MoveNet 13 kps](pose_estimation/pretrained_models/movenet/README.md) | 192x192x3<br> | Evaluation / Quantization / Benchmarking / Prediction | N/A <br>|
9999

100100
</details>
101101

102102
<details open><summary><b>Segmentation (Seg)</b></summary>
103103

104-
[Segmentation use case](segmentation)
104+
[Segmentation use case](./semantic_segmentation/)
105105
| Models | Input Resolutions | Supported Services | Targets for deployment |
106106
|--------------------|------------------|-----------------------|-------------------|
107-
| [DeepLab v3](segmentation/pretrained_models/deeplab_v3/README.md) | 512x512x3<br> | Full Seg Services | STM32MP257F-DK2 <br> |
107+
| [DeepLab v3](./semantic_segmentation/pretrained_models/deeplab_v3/README.md) | 512x512x3<br> | Full Seg Services | [STM32MP257F-EV1](./X-LINUX-AI_application_code/semantic_segmentation/STM32MP2/README.md) <br> |
108108

109-
[Full Seg Services](segmentation/README.md) : training, evaluation, quantization, benchmarking, prediction, deployment
109+
[Full Seg Services](./semantic_segmentation/README.md) : training, evaluation, quantization, benchmarking, prediction, deployment
110110

111111
</details>
112112

X-LINUX-AI_application_code/pose_estimation/STM32MP2/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For STM32MPU, application code example is provided as python script to facilitat
4545

4646
You should use the deploy.py script to automatically deploy the program on the target (if the hardware is connected to the network).
4747

48-
The [deployment script](../../../pose_estimation/deployment/README.md) of the model zoo is used to directly populate the target with all the needed files, resources and NN model. The script use
48+
The [deployment script](../../../pose_estimation/deployment/README_MPU.md) of the model zoo is used to directly populate the target with all the needed files, resources and NN model. The script use
4949
the IP address provided in the configuration yaml file. The application source code is available `Application\` directory and can be modified easily.
5050

5151
### __Deploy NN model__

audio_event_detection/src/user_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ general:
1010

1111
operation_mode: chain_tbqeb #chain_tbqeb
1212
#choices=['training' , 'evaluation', 'prediction', 'deployment', 'quantization', 'benchmarking',
13-
# 'chain_tbqeb','chain_tqe',' chain_eqe','chain_qb','chain_eqeb','chain_qd ']
13+
# 'chain_tbqeb','chain_tqe','chain_eqe','chain_qb','chain_eqeb','chain_qd ']
1414

1515
dataset:
1616
name: esc10

common/benchmarking/common_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ def analyze_footprints(offline: bool = True, results: dict = None, stm32ai_outpu
178178
log_file.write(f'Model Name : {model_name} \n' + f'Tool version : {version_strings} \n'+ f'Model Size : {model_size} KiB \n' + f'Peak Ram usage : {peak_ram} KiB\n')
179179
if inference_res:
180180
inference_time = round(results["duration_ms"], 2)
181-
npu_percent = 100*results["npu_percent"]
182-
gpu_percent = 100*results["gpu_percent"]
183-
cpu_percent = 100*results["cpu_percent"]
181+
npu_percent = round(100*results["npu_percent"],2)
182+
gpu_percent = round(100*results["gpu_percent"],2)
183+
cpu_percent = round(100*results["cpu_percent"],2)
184184
print("[INFO] : Inference Time : {} (ms)".format(inference_time))
185185
print("[INFO] : Execution engine repartition : ")
186186
print("[INFO] : NPU usage : {}".format(npu_percent))

common/evaluation/onnx_evaluation.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,10 @@
55
# * the root directory of this software component.
66
# * If no LICENSE file comes with this software, it is provided AS-IS.
77
# *--------------------------------------------------------------------------------------------*/
8-
import onnxruntime
98
import numpy as np
109
import os
11-
from typing import Tuple, Optional, List, Dict
1210
import onnx
13-
import sys
1411

15-
from visualize_utils import plot_confusion_matrix
16-
from sklearn.metrics import accuracy_score, confusion_matrix
17-
import mlflow
1812

1913
def predict_onnx(sess: onnx.ModelProto, data: np.ndarray) -> np.ndarray:
2014
"""
@@ -29,7 +23,15 @@ def predict_onnx(sess: onnx.ModelProto, data: np.ndarray) -> np.ndarray:
2923
"""
3024
input_name = sess.get_inputs()[0].name
3125
label_name = sess.get_outputs()[0].name
32-
onx_pred = sess.run([label_name], {input_name: data.astype(np.float32)})[0]
26+
# Process each image individually
27+
predictions = []
28+
for i in range(data.shape[0]):
29+
single_data = data[i:i + 1] # Set batch size to 1
30+
single_predictions = sess.run([label_name], {input_name: single_data.astype(np.float32)})[0]
31+
predictions.append(single_predictions)
32+
33+
# Concatenate all predictions
34+
onx_pred = np.concatenate(predictions, axis=0)
3335
return onx_pred
3436

3537

image_classification/src/evaluation/evaluate.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020

2121
warnings.filterwarnings("ignore")
2222
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
23+
import onnxruntime
2324
import tensorflow as tf
2425
import tqdm
25-
from typing import Optional
26+
from sklearn.metrics import accuracy_score, confusion_matrix
2627

2728
from preprocess import apply_rescaling, postprocess_output, preprocess_input
2829
from visualize_utils import plot_confusion_matrix
@@ -157,8 +158,6 @@ def evaluate_onnx_model(input_samples:np.ndarray,
157158
prd_labels = predict_onnx(sess, input_samples).argmax(axis=1)
158159
val_acc = round(accuracy_score(input_labels, prd_labels) * 100, 2)
159160
print(f'[INFO] : Evaluation accuracy: {val_acc} %')
160-
if not os.path.exists("outputs"):
161-
os.makedirs("outputs")
162161
log_file_name = f"{output_dir}/stm32ai_main.log"
163162
with open(log_file_name, 'a', encoding='utf-8') as f:
164163
f.write(f'{model_type} onnx model\nEvaluation accuracy: {val_acc} %\n')

image_classification/src/user_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ general:
99

1010
operation_mode: chain_tbqeb
1111
#choices=['training' , 'evaluation', 'prediction', 'deployment', 'quantization', 'benchmarking',
12-
# 'chain_tbqeb','chain_tqe',' chain_eqe','chain_qb','chain_eqeb','chain_qd ']
12+
# 'chain_tbqeb','chain_tqe','chain_eqe','chain_qb','chain_eqeb','chain_qd ']
1313

1414
dataset:
1515
name: flowers

image_classification/src/utils/parse_config.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,17 @@ def parse_data_augmentation_section(cfg: DictConfig, config_dict: Dict) -> None:
210210
cfg.data_augmentation.config = config_dict['custom_data_augmentation']['config'].copy()
211211
del cfg.custom_data_augmentation
212212

213-
def get_class_names_from_file(cfg: DictConfig) -> List:
213+
def get_class_names_from_file(cfg: DictConfig) -> List[str]:
214+
"""
215+
Reads class names from a file specified in the configuration and returns them as a list.
216+
Args:
217+
cfg (DictConfig): Configuration object containing the path to the label file.
218+
Returns:
219+
List[str]: A list of class names read from the file.
220+
Raises:
221+
FileNotFoundError: If the file specified in the configuration does not exist.
222+
IOError: If there is an error reading the file.
223+
"""
214224
if cfg.deployment.label_file_path :
215225
with open(cfg.deployment.label_file_path, 'r') as file:
216226
class_names = [line.strip() for line in file]
@@ -396,21 +406,13 @@ def get_config(config_data: DictConfig) -> DefaultMunch:
396406

397407
# Check that all datasets have the required directory structure
398408
cds = cfg.dataset
399-
if not cds.class_names and cfg.operation_mode not in ("quantization", "benchmarking", "chain_qb"):
409+
if not cds.class_names and cfg.operation_mode not in ("benchmarking"):
400410
# Infer the class names from a dataset
401411
for path in [cds.training_path, cds.validation_path, cds.test_path, cds.quantization_path]:
402412
if path:
403413
cds.class_names = get_class_names(dataset_root_dir=path)
404414
print("[INFO] : Found {} classes in dataset {}".format(len(cds.class_names), path))
405-
break
406-
407415
if not cds.class_names and cfg.operation_mode in ("deployment","chain_qd") and cfg.hardware_type == "MPU":
408416
cds.class_names = get_class_names_from_file(cfg)
409417
print("[INFO] : Found {} classes in label file {}".format(len(cds.class_names), cfg.deployment.label_file_path))
410-
411-
# This should not happen. Just in case.
412-
if not cds.class_names:
413-
raise ValueError("\nMissing `class_names` attribute\nPlease check the 'dataset' section of your "
414-
"configuration file.")
415-
416418
return cfg

object_detection/pretrained_models/ssd_mobilenet_v2_fpnlite/ST_pretrainedmodel_public_dataset/coco_2017_80_classes/ssd_mobilenet_v2_fpnlite_100_256/ssd_mobilenet_v2_fpnlite_100_256_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ general:
99
operation_mode: chain_tqeb
1010
dataset:
1111
name: coco_80_classes
12-
class_names:['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
12+
class_names: ['person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush']
1313
training_path: DATASETS/train_set
1414
validation_path: DATASETS/val_set
1515
test_path:

0 commit comments

Comments
 (0)