Skip to content

Commit

Permalink
Release AI-ModelZoo-2.1.0:
Browse files Browse the repository at this point in the history
- 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 <khaoula.boutiche@st.com>
  • Loading branch information
KBOUSTM committed Jul 1, 2024
1 parent d95a31f commit 79cff53
Show file tree
Hide file tree
Showing 668 changed files with 58,761 additions and 21,867 deletions.
2 changes: 2 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Software BOM for stm32 use cases:
* [human_activity_recognition](./human_activity_recognition/LICENSE.md)
* [image_classification](./image_classification/LICENSE.md)
* [object_detection](./object_detection/LICENSE.md)
* [semantic_segmentation](./semantic_segmentation/LICENSE.md)
* [pose_estimation](./pose_estimation/LICENSE.md)


Software BOM for stm32 application codes:
Expand Down
151 changes: 112 additions & 39 deletions README.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh
weston_user=$(ps aux | grep '/usr/bin/weston '|grep -v 'grep'|awk '{print $1}')
DEPLOY_PATH=$1
MODEL_NAME=$2
LABELS=$3
COMPATIBLE=$(cat /proc/device-tree/compatible)
if [[ "$COMPATIBLE" == *"stm32mp2"* ]]; then
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"
else
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"
fi

if [ "$weston_user" != "root" ]; then
echo "user : "$weston_user
script -qc "su -l $weston_user -c '$cmd'"
else
$cmd
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/python3
#
# Copyright (c) 2024 STMicroelectronics.
# All rights reserved.
#
# This software is licensed under terms that can be found in the LICENSE file
# in the root directory of this software component.
# If no LICENSE file comes with this software, it is provided AS-IS.

from stai_mpu import stai_mpu_network
import numpy as np

class NeuralNetwork:
"""
Class that handles Neural Network inference
"""
def __init__(self, model_file, label_file, input_mean, input_std):
"""
:param model_path: model to be executed
:param label_file: name of file containing labels
:param input_mean: input_mean
:param input_std: input standard deviation
"""

def load_labels(filename):
my_labels = []
input_file = open(filename, 'r')
for l in input_file:
my_labels.append(l.strip())
return my_labels

self._model_file = model_file
print("NN model used : ", self._model_file)
self._label_file = label_file
self._input_mean = input_mean
self._input_std = input_std
self._floating_model = False

# Initialization of network class
self.stai_mpu_model = stai_mpu_network(model_path=self._model_file)

# Read input tensor information
self.num_inputs = self.stai_mpu_model.get_num_inputs()
self.input_tensor_infos = self.stai_mpu_model.get_input_infos()

# Read output tensor information
self.num_outputs = self.stai_mpu_model.get_num_outputs()
self.output_tensor_infos = self.stai_mpu_model.get_output_infos()

self._labels = load_labels(self._label_file)

def get_labels(self):
"""
:return: list of NN model labels loaded
"""
return self._labels

def get_img_size(self):
"""
:return: size of NN input image size
"""
# NxHxWxC, H:1, W:2, C:3
input_tensor_shape = self.input_tensor_infos[0].get_shape()
input_width = input_tensor_shape[1]
input_height = input_tensor_shape[2]
input_channel = input_tensor_shape[0]
print("input_width",input_width)
print("input_height",input_height)
print("input_channel",input_channel)
return (input_width,input_height,input_channel)

def launch_inference(self, img):
"""
This method launches inference using the invoke call
:param img: the image to be inferred
"""
# add N dim
input_data = np.expand_dims(img, axis=0)

if self.input_tensor_infos[0].get_dtype() == np.float32:
input_data = (np.float32(input_data) - self._input_mean) / self._input_std

self.stai_mpu_model.set_input(0, input_data)
self.stai_mpu_model.run()

def get_results(self):
"""
This method can print and return the top_k results of the inference
"""
output_data = self.stai_mpu_model.get_output(index=0)
results = np.squeeze(output_data)

top_k = results.argsort()[-5:][::-1]

if self.output_tensor_infos[0].get_dtype() == np.uint8 :
return (results[top_k[0]]/255, top_k[0])
else:
return (results[top_k[0]], top_k[0])
80 changes: 80 additions & 0 deletions X-LINUX-AI_application_code/image_classification/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
SLA0044 Rev5/February 2018

Software license agreement

ULTIMATE LIBERTY SOFTWARE LICENSE AGREEMENT

BY INSTALLING, COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE
OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS
INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES
(STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON
BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES
TO BE BOUND BY THIS SOFTWARE LICENSE AGREEMENT.

Under STMicroelectronics’ intellectual property rights, the redistribution,
reproduction and use in source and binary forms of the software or any part
thereof, with or without modification, are permitted provided that the following
conditions are met:

1. Redistribution of source code (modified or not) must retain any copyright
notice, this list of conditions and the disclaimer set forth below as items 10
and 11.

2. Redistributions in binary form, except as embedded into microcontroller or
microprocessor device manufactured by or for STMicroelectronics or a software
update for such device, must reproduce any copyright notice provided with the
binary code, this list of conditions, and the disclaimer set forth below as
items 10 and 11, in documentation and/or other materials provided with the
distribution.

3. Neither the name of STMicroelectronics nor the names of other contributors to
this software may be used to endorse or promote products derived from this
software or part thereof without specific written permission.

4. This software or any part thereof, including modifications and/or derivative
works of this software, must be used and execute solely and exclusively on or in
combination with a microcontroller or microprocessor device manufactured by or
for STMicroelectronics.

5. No use, reproduction or redistribution of this software partially or totally
may be done in any manner that would subject this software to any Open Source
Terms. “Open Source Terms” shall mean any open source license which requires as
part of distribution of software that the source code of such software is
distributed therewith or otherwise made available, or open source license that
substantially complies with the Open Source definition specified at
www.opensource.org and any other comparable open source license such as for
example GNU General Public License (GPL), Eclipse Public License (EPL), Apache
Software License, BSD license or MIT license.

6. STMicroelectronics has no obligation to provide any maintenance, support or
updates for the software.

7. The software is and will remain the exclusive property of STMicroelectronics
and its licensors. The recipient will not take any action that jeopardizes
STMicroelectronics and its licensors' proprietary rights or acquire any rights
in the software, except the limited rights specified hereunder.

8. The recipient shall comply with all applicable laws and regulations affecting
the use of the software or any part thereof including any applicable export
control law or regulation.

9. Redistribution and use of this software or any part thereof other than as
permitted under this license is void and will automatically terminate your
rights under this license.

10. THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS, WHICH ARE
DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL
STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

11. EXCEPT AS EXPRESSLY PERMITTED HEREUNDER, NO LICENSE OR OTHER RIGHTS, WHETHER
EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY
RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
6 changes: 6 additions & 0 deletions X-LINUX-AI_application_code/image_classification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# __Image classification Getting Started package__

The respective README of each board can be found in the `<STM32_Serie_Name>` folder. The boards currently supported are the following ones:

- [STM32MP1X](./STM32MP1/README.md)
- [STM32MP2X](./STM32MP2/README.md)
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
window {
background-color: #000000;
}

window#overlay_window {
background-color: transparent;
}

widget {
background-color: transparent;
}

box#gui_main_stbox {
background-color: #000000;
color: #FFFFFF;
}

box#gui_overlay_stbox {
background-color: #000000;
color: #FFFFFF;
}

box#gui_main_video {
background-color: #000000;
}

box#gui_overlay_video {
background-color: transparent;
}

box#gui_main_exit {
background-color: #000000;
}

box#gui_overlay_exit {
background-color: transparent;
}

box#gui_main {
background-color: #000000;
}

drawing_area#overlay_draw {
background-color: transparent;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 79cff53

Please sign in to comment.