Skip to content

Commit 79cff53

Browse files
committed
Release AI-ModelZoo-2.1.0:
- Included additional models compatible with the STM32MP257F-DK2 board. - Added support for per-tensor quantization. - Integrated support for ONNX model quantization and evaluation. - Included support for STEdgeAI (STM32Cube.AI v9.1.0 and subsequent versions). - Expanded use case support to include Pose Estimation and Semantic Segmentation. - Standardized logging information for a unified experience. Signed-off-by: khaoula boutiche <[email protected]>
1 parent d95a31f commit 79cff53

File tree

668 files changed

+58761
-21867
lines changed

Some content is hidden

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

668 files changed

+58761
-21867
lines changed

LICENSE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Software BOM for stm32 use cases:
1212
* [human_activity_recognition](./human_activity_recognition/LICENSE.md)
1313
* [image_classification](./image_classification/LICENSE.md)
1414
* [object_detection](./object_detection/LICENSE.md)
15+
* [semantic_segmentation](./semantic_segmentation/LICENSE.md)
16+
* [pose_estimation](./pose_estimation/LICENSE.md)
1517

1618

1719
Software BOM for stm32 application codes:

README.md

Lines changed: 112 additions & 39 deletions
Large diffs are not rendered by default.

X-LINUX-AI_application_code/image_classification/Application/image_classification.py

Lines changed: 868 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
3+
DEPLOY_PATH=$1
4+
MODEL_NAME=$2
5+
LABELS=$3
6+
COMPATIBLE=$(cat /proc/device-tree/compatible)
7+
if [[ "$COMPATIBLE" == *"stm32mp2"* ]]; then
8+
cmd="python3 $DEPLOY_PATH/Application/image_classification.py -m $DEPLOY_PATH/$MODEL_NAME -l $DEPLOY_PATH/Resources/$LABELS --framerate 30 --frame_width 640 --frame_height 480"
9+
else
10+
cmd="python3 $DEPLOY_PATH/Application/image_classification.py -m $DEPLOY_PATH/$MODEL_NAME -l $DEPLOY_PATH/Resources/$LABELS --framerate 15 --frame_width 320 --frame_height 240"
11+
fi
12+
13+
if [ "$weston_user" != "root" ]; then
14+
echo "user : "$weston_user
15+
script -qc "su -l $weston_user -c '$cmd'"
16+
else
17+
$cmd
18+
fi
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/python3
2+
#
3+
# Copyright (c) 2024 STMicroelectronics.
4+
# All rights reserved.
5+
#
6+
# This software is licensed under terms that can be found in the LICENSE file
7+
# in the root directory of this software component.
8+
# If no LICENSE file comes with this software, it is provided AS-IS.
9+
10+
from stai_mpu import stai_mpu_network
11+
import numpy as np
12+
13+
class NeuralNetwork:
14+
"""
15+
Class that handles Neural Network inference
16+
"""
17+
def __init__(self, model_file, label_file, input_mean, input_std):
18+
"""
19+
:param model_path: model to be executed
20+
:param label_file: name of file containing labels
21+
:param input_mean: input_mean
22+
:param input_std: input standard deviation
23+
"""
24+
25+
def load_labels(filename):
26+
my_labels = []
27+
input_file = open(filename, 'r')
28+
for l in input_file:
29+
my_labels.append(l.strip())
30+
return my_labels
31+
32+
self._model_file = model_file
33+
print("NN model used : ", self._model_file)
34+
self._label_file = label_file
35+
self._input_mean = input_mean
36+
self._input_std = input_std
37+
self._floating_model = False
38+
39+
# Initialization of network class
40+
self.stai_mpu_model = stai_mpu_network(model_path=self._model_file)
41+
42+
# Read input tensor information
43+
self.num_inputs = self.stai_mpu_model.get_num_inputs()
44+
self.input_tensor_infos = self.stai_mpu_model.get_input_infos()
45+
46+
# Read output tensor information
47+
self.num_outputs = self.stai_mpu_model.get_num_outputs()
48+
self.output_tensor_infos = self.stai_mpu_model.get_output_infos()
49+
50+
self._labels = load_labels(self._label_file)
51+
52+
def get_labels(self):
53+
"""
54+
:return: list of NN model labels loaded
55+
"""
56+
return self._labels
57+
58+
def get_img_size(self):
59+
"""
60+
:return: size of NN input image size
61+
"""
62+
# NxHxWxC, H:1, W:2, C:3
63+
input_tensor_shape = self.input_tensor_infos[0].get_shape()
64+
input_width = input_tensor_shape[1]
65+
input_height = input_tensor_shape[2]
66+
input_channel = input_tensor_shape[0]
67+
print("input_width",input_width)
68+
print("input_height",input_height)
69+
print("input_channel",input_channel)
70+
return (input_width,input_height,input_channel)
71+
72+
def launch_inference(self, img):
73+
"""
74+
This method launches inference using the invoke call
75+
:param img: the image to be inferred
76+
"""
77+
# add N dim
78+
input_data = np.expand_dims(img, axis=0)
79+
80+
if self.input_tensor_infos[0].get_dtype() == np.float32:
81+
input_data = (np.float32(input_data) - self._input_mean) / self._input_std
82+
83+
self.stai_mpu_model.set_input(0, input_data)
84+
self.stai_mpu_model.run()
85+
86+
def get_results(self):
87+
"""
88+
This method can print and return the top_k results of the inference
89+
"""
90+
output_data = self.stai_mpu_model.get_output(index=0)
91+
results = np.squeeze(output_data)
92+
93+
top_k = results.argsort()[-5:][::-1]
94+
95+
if self.output_tensor_infos[0].get_dtype() == np.uint8 :
96+
return (results[top_k[0]]/255, top_k[0])
97+
else:
98+
return (results[top_k[0]], top_k[0])
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
SLA0044 Rev5/February 2018
2+
3+
Software license agreement
4+
5+
ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT
6+
7+
BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
8+
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
9+
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
10+
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
11+
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
12+
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.
13+
14+
Under STMicroelectronics’ intellectual property rights, the redistribution,
15+
reproduction and use in source and binary forms of the software or any part
16+
thereof, with or without modification, are permitted provided that the following
17+
conditions are met:
18+
19+
1. Redistribution of source code (modified or not) must retain any copyright
20+
notice, this list of conditions and the disclaimer set forth below as items 10
21+
and 11.
22+
23+
2. Redistributions in binary form, except as embedded into microcontroller or
24+
microprocessor device manufactured by or for STMicroelectronics or a software
25+
update for such device, must reproduce any copyright notice provided with the
26+
binary code, this list of conditions, and the disclaimer set forth below as
27+
items 10 and 11, in documentation and/or other materials provided with the
28+
distribution.
29+
30+
3. Neither the name of STMicroelectronics nor the names of other contributors to
31+
this software may be used to endorse or promote products derived from this
32+
software or part thereof without specific written permission.
33+
34+
4. This software or any part thereof, including modifications and/or derivative
35+
works of this software, must be used and execute solely and exclusively on or in
36+
combination with a microcontroller or microprocessor device manufactured by or
37+
for STMicroelectronics.
38+
39+
5. No use, reproduction or redistribution of this software partially or totally
40+
may be done in any manner that would subject this software to any Open Source
41+
Terms. “Open Source Terms” shall mean any open source license which requires as
42+
part of distribution of software that the source code of such software is
43+
distributed therewith or otherwise made available, or open source license that
44+
substantially complies with the Open Source definition specified at
45+
www.opensource.org and any other comparable open source license such as for
46+
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
47+
Software License, BSD license or MIT license.
48+
49+
6. STMicroelectronics has no obligation to provide any maintenance, support or
50+
updates for the software.
51+
52+
7. The software is and will remain the exclusive property of STMicroelectronics
53+
and its licensors. The recipient will not take any action that jeopardizes
54+
STMicroelectronics and its licensors' proprietary rights or acquire any rights
55+
in the software, except the limited rights specified hereunder.
56+
57+
8. The recipient shall comply with all applicable laws and regulations affecting
58+
the use of the software or any part thereof including any applicable export
59+
control law or regulation.
60+
61+
9. Redistribution and use of this software or any part thereof other than as
62+
permitted under this license is void and will automatically terminate your
63+
rights under this license.
64+
65+
10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
66+
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
67+
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
68+
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
69+
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
70+
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
71+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
72+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
73+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
74+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
75+
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
76+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
77+
78+
11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
79+
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
80+
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# __Image classification Getting Started package__
2+
3+
The respective README of each board can be found in the `<STM32_Serie_Name>` folder. The boards currently supported are the following ones:
4+
5+
- [STM32MP1X](./STM32MP1/README.md)
6+
- [STM32MP2X](./STM32MP2/README.md)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
window {
2+
background-color: #000000;
3+
}
4+
5+
window#overlay_window {
6+
background-color: transparent;
7+
}
8+
9+
widget {
10+
background-color: transparent;
11+
}
12+
13+
box#gui_main_stbox {
14+
background-color: #000000;
15+
color: #FFFFFF;
16+
}
17+
18+
box#gui_overlay_stbox {
19+
background-color: #000000;
20+
color: #FFFFFF;
21+
}
22+
23+
box#gui_main_video {
24+
background-color: #000000;
25+
}
26+
27+
box#gui_overlay_video {
28+
background-color: transparent;
29+
}
30+
31+
box#gui_main_exit {
32+
background-color: #000000;
33+
}
34+
35+
box#gui_overlay_exit {
36+
background-color: transparent;
37+
}
38+
39+
box#gui_main {
40+
background-color: #000000;
41+
}
42+
43+
drawing_area#overlay_draw {
44+
background-color: transparent;
45+
}
4.03 KB
Loading
5.46 KB
Loading

0 commit comments

Comments
 (0)