运行后在当前目录下得到生成 best\_line\_follower\_model\_xy.onnx 模型
thomas@J-35:~/dev_ws/src/originbot_desktop/originbot_deeplearning/line_follower_model$ ls -l
total 98556
-rw-rw-r-- 1 thomas thomas 44700647 Apr 2 21:02 best_line_follower_model_xy.onnx
-rw-rw-r-- 1 thomas thomas 44789846 Apr 2 19:37 best_line_follower_model_xy.pth
##### **启动AI工具链docker**
解压缩之前下载好的AI工具链的docker镜像和OE包,OE包目录结构如下:
.
├── bsp
│ └── X3J3-Img-PL2.2-V1.1.0-20220324.tgz
├── ddk
│ ├── package
│ ├── samples
│ └── tools
├── doc
│ ├── cn
│ ├── ddk_doc
│ └── en
├── release_note-CN.txt
├── release_note-EN.txt
├── run_docker.sh
└── tools
├── 0A_CP210x_USB2UART_Driver.zip
├── 0A_PL2302-USB-to-Serial-Comm-Port.zip
├── 0A_PL2303-M_LogoDriver_Setup_v202_20200527.zip
├── 0B_hbupdate_burn_secure-key1.zip
├── 0B_hbupdate_linux_cli_v1.1.tgz
├── 0B_hbupdate_linux_gui_v1.1.tgz
├── 0B_hbupdate_mac_v1.0.5.app.tar.gz
└── 0B_hbupdate_win64_v1.1.zip
将 originbot\_desktop 代码仓库中的 10\_model\_convert 包拷贝到至OE开发包 ddk/samples/ai\_toolchain/horizon\_model\_convert\_sample/03\_classification/ 目录下。
[![image](https://img-blog.csdnimg.cn/img_convert/58cc45b38e7f8d8133ccefacad0a2c78.png)](https://www.originbot.org/application/image/deeplearning_line_follower/2022-09-15_17-23.png)
再把 line\_follower\_model 功能包下标注好的数据集文件夹 image\_dataset 和生成的 best\_line\_follower\_model\_xy.onnx 模型拷贝到以上 ddk/samples/ai\_toolchain/horizon\_model\_convert\_sample/03\_classification/10\_model\_convert/mapper/ 目录下,数据集文件夹 image\_dataset 保留100张左右的数据用于校准:
[![image](https://img-blog.csdnimg.cn/img_convert/09c03db8cd37ff98f89f240777a278e1.png)](https://www.originbot.org/application/image/deeplearning_line_follower/2022-09-16_17-20.png)
然后回到OE包的根目录下,加载AI工具链的docker镜像:
cd /home/thomas/Me/deeplearning/horizon_xj3_open_explorer_v2.3.3_20220727/
sh run_docker.sh /data/
**生成校准数据**
在启动的Docker镜像中,完成如下操作:
cd ddk/samples/ai_toolchain/horizon_model_convert_sample/03_classification/10_model_convert/mapper
sh 02_preprocess.sh
命令执行过程如下:
thomas@J-35:~/Me/deeplearning/horizon_xj3_open_explorer_v2.3.3_20220727$ sudo sh run_docker.sh /data/
[sudo] password for thomas:
run_docker.sh: 14: [: unexpected operator
run_docker.sh: 23: [: openexplorer/ai_toolchain_centos_7_xj3: unexpected operator
docker version is v2.3.3
dataset path is /data
open_explorer folder path is /home/thomas/Me/deeplearning/horizon_xj3_open_explorer_v2.3.3_20220727
[root@1e1a1a7e24f4 open_explorer]# cd ddk/samples/ai_toolchain/horizon_model_convert_sample/03_classification/10_model_convert/mapper
[root@1e1a1a7e24f4 mapper]# sh 02_preprocess.sh
cd $(dirname $0) || exit
python3 …/…/…/data_preprocess.py
–src_dir ./image_dataset
–dst_dir ./calibration_data_bgr_f32
–pic_ext .rgb
–read_mode opencv
Warning please note that the data type is now determined by the name of the folder suffix
Warning if you need to set it explicitly, please configure the value of saved_data_type in the preprocess shell script
regular preprocess
write:./calibration_data_bgr_f32/xy_008_160_31a8e30a-eca6-11ee-bb07-dfd665df7b81.rgb
write:./calibration_data_bgr_f32/xy_009_160_39c18c40-eca6-11ee-bb07-dfd665df7b81.rgb
write:./calibration_data_bgr_f32/xy_028_092_3327df66-ec9b-11ee-bb07-dfd665df7b81.rgb
#####
##### **模型编译生成定点模型**
接下来执行以下命令生成定点模型文件,稍后会在机器人上部署:
cd ddk/samples/ai_toolchain/horizon_model_convert_sample/03_classification/10_model_convert/mapper
sh 03_build.sh
命令执行过程如下: