你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

【STM32N6570-DK评测】8.初试AI

[复制链接]
奇迹 发布时间:2025-3-1 17:52

目标:在纯本地的环境下完成一个人体识别AI模型的部署。

一、文件准备

STEdgeAI https://www.st.com/en/development-tools/stm32n6-ai.html

STM32N6 Getting Started V1.0.0 https://www.st.com/en/development-tools/stedgeai-core.html

stm32ai-modelzoo-services https://github.com/STMicroelectronics/stm32ai-modelzoo-services

stm32ai-modelzoo https://github.com/STMicroelectronics/stm32ai-modelzoo/

解压en.n6-ai-getstarted-v1.0.0并将application_code文件夹复制到stm32ai-modelzoo-services-3.0.0路径下。

image.png

二、环境配置

1.打开并修改stm32ai-modelzoo-services-3.0.0\object_detection\src\config_file_examples\deployment_n6_ssd_mobilenet_v2_fpnlite_config.yaml文件。

2.根据修改stm32ai-modelzoo-3.0.0解压路径配置模型路径。

model_path: ../../../stm32ai-modelzoo-3.0.0/object_detection/ssd_mobilenet_v2_fpnlite/ST_pretrainedmodel_public_dataset/coco_2017_person/ssd_mobilenet_v2_fpnlite_035_192/ssd_mobilenet_v2_fpnlite_035_192_int8.tflite

3.根据STEdgeAI软件安装路径,修改stedgea.exei路径。

path_to_stedgeai: STEdgeAI安装路径/2.0/Utilities/windows/stedgeai.exe

4.修改STM32CubeIDE安装路径

path_to_cubeIDE:STM32CubeIDE_1.17.0安装路径/STM32CubeIDE/stm32cubeide.exe

5.其他部分选项说明

preprocessing:预处理信息

  • aspect_ratio:
    • crop:将两个管道裁剪为 nn 输入纵横比;保持原始纵横比
    • full_screen将相机图像的大小调整为 NN 输入大小并显示全屏图像
    • fit:将两个管道的大小调整为 NN 输入纵横比;未保留原始纵横比

postprocessing:后处理信息

  • confidence_thresh- 介于 0.0 和 1.0 之间的浮点数,分数用于筛选检测。
  • NMS_thresh- 介于 0.0 和 1.0 之间的浮点数,NMS 阈值用于筛选和减少重叠的框。
  • max_detection_boxes- 一个 int 用于过滤边界框的数量。

tools部署参数

  • tools/stedgeai
    • version- 指定用于对模型进行基准测试的 STM32Cube.AI 版本,例如 10.0.0。
    • optimization - String,定义用于生成 C 模型的优化,选项: “balanced”, “time”, “ram”。
    • on_cloud - 布尔值 (Boolean) 为 False。不适用于 STM32N6
    • path_to_stedgeai - 要使用本地下载的 stedgeai 可执行文件的路径,否则为 False。
  • tools/path_to_cubeIDE - stm32cubeide 可执行文件的路径。

deployment

  • c_project_path - 应用程序 C 代码项目的路径。
  • IDE -GCC,仅支持 stm32ai 应用程序代码的选项。
  • verbosity - 0 或 1。模式 0 是静默的,在 STM32 目标上构建和刷写 C 应用程序时,模式 1 显示消息。

最终配置如下(仅供参考,具体需根据自己电脑软件安装位置配置)

general:
model_type: ssd_mobilenet_v2_fpnlite # 'st_ssd_mobilenet_v1', 'ssd_mobilenet_v2_fpnlite', 'tiny_yolo_v2', 'st_yolo_lc_v1', 'st_yolo_x', 'yolo_v8'
  # path to a `.tflite` or `.onnx` file.
  model_path: ../../../stm32ai-modelzoo-3.0.0/object_detection/ssd_mobilenet_v2_fpnlite/ST_pretrainedmodel_public_dataset/coco_2017_person/ssd_mobilenet_v2_fpnlite_035_192/ssd_mobilenet_v2_fpnlite_035_192_int8.tflite

operation_mode: deployment

dataset:
  name: coco_2017_person
  class_names: [person]

preprocessing:
  resizing:
    interpolation: bilinear
    aspect_ratio: crop
  color_mode: rgb # rgb, bgr

postprocessing:
  confidence_thresh: 0.6
  NMS_thresh: 0.5
  IoU_eval_thresh: 0.4
  yolo_anchors: # Only applicable for YoloV2
  max_detection_boxes: 10

tools:
  stedgeai:
    version: 10.0.0
    optimization: balanced
    on_cloud: False # Not Available For STM32N6
    path_to_stedgeai: C:/App/Develop/ST/STEdgeAI/2.0/Utilities/windows/stedgeai.exe
  path_to_cubeIDE: C:/App/Develop/ST/STM32CubeIDE_1.17.0/STM32CubeIDE/stm32cubeide.exe

deployment:
  c_project_path: ../../application_code/object_detection/STM32N6/
  IDE: GCC
  verbosity: 1
  hardware_setup:
    serie: STM32N6
    board: STM32N6570-DK

hydra:
  run:
    dir: ./experiments_outputs/${now:%Y_%m_%d_%H_%M_%S}

mlflow:
  uri: ./experiments_outputs/mlruns

6.连接好板卡

7.进入stm32ai-modelzoo-services-3.0.0\object_detection\src目录

8.启动终端,运行

python stm32ai_main.py --config-path ./config_file_examples/ --config-name deployment_n6_ssd_mobilenet_v2_fpnlite_config.yaml

image.png

理论上将完成自动编译和下载,这里我的可能是安装软件时修改了默认路径的原因,下载失败,不过生成和编译还是完成了。

image.png

接下来我们手动下载一下

三、固件下载

1.首先给固件加一下标头

打开stm32ai-modelzoo-services-3.0.0\application_code\object_detection\STM32N6\STM32CubeIDE\Debug目录,启动终端运行

STM32_SigningTool_CLI -bin STM32N6_GettingStarted_ObjectDetection.bin -nk -t ssbl -hv 2.3 -o STM32N6_GettingStarted_ObjectDetection_sign.bin

image.png

2.启动STM32CubeProgrammer

2.1 下载fsbl固件

文件路径:stm32ai-modelzoo-services-3.0.0\application_code\object_detection\STM32N6\Binary\ai_fsbl.hex

image.png

2.2 下载模型固件

文件路径:stm32ai-modelzoo-services-3.0.0\application_code\object_detection\STM32N6\Model\network_atonbuf.xSPI2.bin

下载地址:0X70380000

image.png

2.3 下载app固件

文件路径:stm32ai-modelzoo-services-3.0.0\application_code\object_detection\STM32N6\STM32CubeIDE\Debug\STM32N6_GettingStarted_ObjectDetection_sign.bin

下载地址:0X70100000

image.png

四、运行效果

将boot0和boot1同时拨到左边,复位设备。

image.png

image.png

收藏 评论0 发布时间:2025-3-1 17:52

举报

0个回答

所属标签

相似分享

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版