Skip to content

Commit 59327db

Browse files
committed
Initial commit v1.0.0
0 parents  commit 59327db

File tree

7,557 files changed

+2256779
-0
lines changed

Some content is hidden

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

7,557 files changed

+2256779
-0
lines changed

Binary/STM32N6_GettingStarted_InstanceSegmentation.hex

Lines changed: 38070 additions & 0 deletions
Large diffs are not rendered by default.

Binary/ai_fsbl.hex

Lines changed: 3817 additions & 0 deletions
Large diffs are not rendered by default.

Binary/network_data.hex

Lines changed: 219282 additions & 0 deletions
Large diffs are not rendered by default.

Doc/Application-Overview.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
# Application overview
3+
4+
![Overview app](../_htmresc/BasicAppOverview.png)
5+
6+
## DCMIPP and ISP
7+
8+
### DCMIPP overview
9+
10+
![DCMIPP overview}](../_htmresc/DCMIPP.JPG)
11+
12+
- Pipe 1 is enabled using `CMW_CAMERA_Start(0, DCMIPP_PIPE1, *ptr_dst, CAMERA_MODE_CONTINUOUS);` to continuously transmit images from imx335 to the LTDC frame buffer (`lcd_bg_framebuffer`).
13+
- Pipe 2 is enabled using `CMW_CAMERA_Start(0, DCMIPP_PIPE2, *ptr_dst, CAMERA_MODE_SNAPSHOT);` to capture one frame (in the `nn_in` buffer) before launching the inference in the NPU.
14+
- For each capture the ISP configuration is updated to enhance the image quality depending on the illumination conditions. It is initialized through `ISP_Init` and then executed with `ISP_BackgroundProcess`.
15+
16+
For more details of DCMIPP see Digital camera interface pixel pipeline (DCMIPP) in STM32N6 Reference manual.

Doc/Boot-Overview.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Boot Overview
2+
3+
## Dev mode
4+
5+
![Dev mode](../_htmresc/Dev_mode.png)
6+
7+
## Boot from flash with First Stage Boot Loader
8+
9+
![FSBL](../_htmresc/FSBL.png)
10+
11+
Note:
12+
By default 1MB of SRAM1 is reserved for the User App (see [STM32N657xx.ld](../STM32CubeIDE/STM32N657xx.ld)) and 1MB of SRAM2 is reserved for the network activations (see [stm32n6-app2.mpool](../Model/my_mpools/stm32n6-app2.mpool)).

Doc/Build-Options.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Build Options
2+
3+
Some features are enabled using build options or using `app_config.h`:
4+
5+
- [Cameras module](#cameras-module)
6+
- [Camera Orientation](#camera-orientation)
7+
- [Aspect Ratio Mode](#aspect-ratio-mode)
8+
- [Image preprocessing](#image-preprocessing)
9+
10+
This documentation explains those feature and how to modify them.
11+
12+
## Cameras module
13+
14+
The Application is compatible with 4 Cameras:
15+
16+
- MB1854B IMX335 (Default Camera provided with the MB1939 STM32N6570-DK board)
17+
- ST VD66GY
18+
- ST VD55G1
19+
20+
### Makefile
21+
22+
```bash
23+
make -j8
24+
```
25+
26+
### STM32CubeIDE
27+
28+
1. Right Click on the project -> Properties
29+
2. Click on C/C++ General
30+
3. Click on Path and Symbols
31+
4. Click Symbols
32+
5. Delete `USE_IMX335_SENSOR`
33+
6. Add a Symbol following the pattern `USE_<CAMERA>_SENSOR`; Replace \<CAMERA\> by one of these IMX335; VD66GY; VD55G1
34+
7. Click on Apply and Close
35+
36+
![Select Camera With CubeIDE](../_htmresc/Modify_Camera_built_CubeIde.JPG)
37+
38+
## Camera Orientation
39+
40+
Cameras allows to flip the image along 2 axis.
41+
42+
- CAMERA_FLIP_HFLIP: Selfie mode
43+
- CAMERA_FLIP_VFLIP: Flip upside down.
44+
- CAMERA_FLIP_HVFLIP: Flip Both axis
45+
- CAMERA_FLIP_NONE: Default
46+
47+
1. Open [app_config.h](../Inc/app_config.h)
48+
49+
2. Change CAMERA_FLIP define:
50+
```C
51+
/*Defines: CMW_MIRRORFLIP_NONE; CMW_MIRRORFLIP_FLIP; CMW_MIRRORFLIP_MIRROR; CMW_MIRRORFLIP_FLIP_MIRROR;*/
52+
#define CAMERA_FLIP CMW_MIRRORFLIP_FLIP
53+
```
54+
55+
## Aspect Ratio Mode
56+
57+
### Image preprocessing
58+
59+
To fit the camera image to the NN input and to the display 3 options are provided.
60+
61+
- `ASPECT_RATIO_CROP`:
62+
- NN_Pipe: The frame is cropped to fit into a square with a side equal to the NN dimensions. The aspect ratio is kept but some pixels are lost on each side of the image.
63+
- Display_Pipe: The displayed frame is cropped identically to the nn pipe. We see what the nn sees but with an upscale format of 480x480 (Max height of the lcd display)
64+
65+
![ASPECT_RATIO_CROP](../_htmresc/ASPECT_RATIO_MODE1.png)
66+
67+
- `ASPECT_RATIO_FIT`:
68+
- NN_Pipe: The frame is resized to fit into a square with a side equal to the NN dimensions. The aspect ratio is modified.
69+
- Display_Pipe: The frame is resized as the NN. The frame is resized to fit into a square with a side equal to the height of the lcd display.
70+
71+
![ASPECT_RATIO_FIT](../_htmresc/ASPECT_RATIO_MODE2.png)
72+
73+
- `ASPECT_RATIO_FULLSCREEN`:
74+
- NN_Pipe: The frame is resized to fit into a square with a side equal to the NN dimensions. The aspect ratio is modified.
75+
- Display_Pipe: The frame is displayed full screen; We maximize the size of the display. The frame is not deformed. Aspect ratios of nn input and display are different.
76+
77+
![ASPECT_RATIO_FIT](../_htmresc/ASPECT_RATIO_MODE3.png)
78+
79+
1. Open [app_config.h](../Inc/app_config.h)
80+
2. Change ASPECT_RATIO_MODE:
81+
82+
```C
83+
#define ASPECT_RATIO_CROP (1)
84+
#define ASPECT_RATIO_FIT (2)
85+
#define ASPECT_RATIO_FULLSCREEN (3)
86+
#define ASPECT_RATIO_MODE ASPECT_RATIO_FULLSCREEN
87+
```

Doc/Deploy-your-tflite-Model.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Deploy your tflite Model
2+
3+
This documentation is an example to show you how to deploy your own Tiny YOLO v2 object detection tflite model. The model of this example is a Tiny YOLO v2 224x224 people detection. Please adapt it to your own model/use case.
4+
In order to run your own model you need to follow these steps:
5+
6+
- [1. Generate c-model from tflite model](#1-generate-c-model-from-tflite-model)
7+
- [2. Program your network data](#2-program-your-network-data)
8+
- [3. Provide NN Information](#3-provide-nn-information)
9+
- [Post process type](#post-process-type)
10+
- [NN Size info](#nn-size-info)
11+
- [Class labels](#class-labels)
12+
- [Configure post process parameters](#configure-post-process-parameters)
13+
- [4. Build Application](#4-build-application)
14+
- [5. Run Application](#5-run-application)
15+
- [Dev mode](#dev-mode)
16+
- [Boot from flash](#boot-from-flash)
17+
18+
## 1. Generate c-model from tflite model
19+
20+
In order to generate the `Model/network.c` and the file containing the network parameters you must install STM32Cube.AI v10.0.0 or later as well as STM32CubeIDE v1.17 or later.
21+
22+
1. Add `/c/\<InstallFolder>/Utilities/windows/` in your path to have stedgeai known by your bash.
23+
24+
2. Add `/c/\<InstallFolder>/STM32CubeIDE_<X.X.X>/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.<X.X.X>/bin/` in your path to have arm-none-eabi-objcopy known by your bash.
25+
26+
3. Put you Tiny YOLO v2 tflite model in the `Model` folder.
27+
28+
```bash
29+
cd Model
30+
stedgeai generate --model Model_File.tflite --target stm32n6 --st-neural-art default@user_neuralart.json
31+
cp st_ai_output/network.c .
32+
cp st_ai_output/network_atonbuf.xSPI2.raw network_data.xSPI2.bin
33+
arm-none-eabi-objcopy -I binary network_data.xSPI2.bin --change-addresses 0x70380000 -O ihex network_data.hex
34+
```
35+
36+
You can find the following script at [Model/generate-n6-model.sh](../Model/generate-n6-model.sh)
37+
38+
## 2. Program your network data
39+
40+
Now You can program your network data in external flash.
41+
42+
See [Program app in external flash](../README.md#program-app-in-external-flash) for detailed info on how to program network data.
43+
44+
```bash
45+
export DKEL="<STM32CubeProgrammer_N6 Install Folder>/bin/ExternalLoader/MX66UW1G45G_STM32N6570-DK.stldr"
46+
47+
# weights and params
48+
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w Model/network_data.hex
49+
```
50+
51+
## 3. Provide NN Information
52+
53+
You need to edit the last lines of [Inc/app_config.h](../Inc/app_config.h) to make the app compatible with your network.
54+
55+
### Post process type
56+
57+
Set the postprocess type to YOLO v2:
58+
59+
```C
60+
#define POSTPROCESS_TYPE POSTPROCESS_OD_YOLO_V2_UF
61+
62+
```
63+
64+
### NN Size info
65+
66+
Edit your NN_WIDTH, NN_HEIGHT to match your network input size:
67+
68+
```C
69+
#define NN_WIDTH 224
70+
#define NN_HEIGHT 224
71+
```
72+
73+
__WARNING__: Only UINT8 format is supported.
74+
__WARNING__: Only RGB888 format has been tested.
75+
76+
### Class labels
77+
78+
Modify the NB_CLASSES and classes_table to fit your own class labels:
79+
80+
```C
81+
#define NB_CLASSES 2
82+
static const char* classes_table[NB_CLASSES] = {
83+
"person",
84+
"not_person",
85+
};
86+
```
87+
88+
### Configure post process parameters
89+
90+
A documentation of the post processing library is available at [Postprocess lib](../Lib/lib_vision_models_pp/lib_objdetect_pp/README.md).
91+
92+
You can edit IOU thresholds, anchors values and other parameters.
93+
94+
```C
95+
/* I/O configuration */
96+
#define AI_OBJDETECT_YOLOV2_PP_NB_CLASSES (1)
97+
#define AI_OBJDETECT_YOLOV2_PP_NB_ANCHORS (5)
98+
#define AI_OBJDETECT_YOLOV2_PP_GRID_WIDTH (7)
99+
#define AI_OBJDETECT_YOLOV2_PP_GRID_HEIGHT (7)
100+
#define AI_OBJDETECT_YOLOV2_PP_NB_INPUT_BOXES (AI_OBJDETECT_YOLOV2_PP_GRID_WIDTH * AI_OBJDETECT_YOLOV2_PP_GRID_HEIGHT)
101+
102+
/* Anchor boxes */
103+
static const float32_t AI_OBJDETECT_YOLOV2_PP_ANCHORS[2*AI_OBJDETECT_YOLOV2_PP_NB_ANCHORS] = {
104+
0.9883000000f, 3.3606000000f,
105+
2.1194000000f, 5.3759000000f,
106+
3.0520000000f, 9.1336000000f,
107+
5.5517000000f, 9.3066000000f,
108+
9.7260000000f, 11.1422000000f,
109+
};
110+
111+
/* Postprocessing */
112+
#define AI_OBJDETECT_YOLOV2_PP_CONF_THRESHOLD (0.6f)
113+
#define AI_OBJDETECT_YOLOV2_PP_IOU_THRESHOLD (0.3f)
114+
#define AI_OBJDETECT_YOLOV2_PP_MAX_BOXES_LIMIT (10)
115+
```
116+
117+
The list of all the defines needed by each postprocessing type is available in the [Postprocess defines documentation](Postprocess-Defines.md).
118+
119+
## 4. Build Application
120+
121+
Once your network data has been programed (step 2) and network details configured (step 3) you can build your application following this guide:
122+
123+
[Application build and run](../README.md#application-build-and-run---dev-mode)
124+
125+
## 5. Run Application
126+
127+
### Dev mode
128+
129+
See [Application build and run](../README.md#application-build-and-run---dev-mode) section for more details.
130+
131+
### Boot from flash
132+
133+
See [Program app in external flash](../README.md#application-build-and-run---boot-from-flash) to program your firmware.

0 commit comments

Comments
 (0)