yolo11n模型转换bin后部署X5失败
参考帖子YOLOv11,地瓜RDK X5开发板,TROS端到端140FPS! - RDK Model Zoo - 地瓜机器人论坛
1. 板卡型号 RDK X5
2. 系统软件版本:-
[RDK OS Version]:
3.1.1
[RDK Kernel Version]:
Linux ubuntu 6.1.83 #1 SMP PREEMPT Fri Jan 10 15:29:06 CST 2025 aarch64 aarch64 aarch64 GNU/Linux
[RDK Miniboot Version]:
U-Boot 2022.10-g505104e8-dirty (Sep 26 2024 - 15:01:37 +0800)
3.hrt_model_exec model_info --model_file yolov11n_nv12.bin
root@08495013b420:/data/horizon_x5/codes/model_outputyolov11# hrt_model_exec model_info --model_file yolov11n_nv12.bin
hrt_model_exec model_info --model_file yolov11n_nv12.bin
I0000 00:00:00.000000 401 vlog_is_on.cc:197] RAW: Set VLOG level for “*” to 3
core[0] open!
core[1] open!
[HBRT] set log level as 0. version = 3.15.54.0
[DNN] Runtime version = 1.23.10_(3.15.54 HBRT)
[A][DNN][packed_model.cpp:247][Model](2025-01-29,00:56:43.195.6) [HorizonRT] The model builder version = 1.23.8
Load model to DDR cost 118.099ms.
This model file has 1 model:
[yolov11n_nv12]
---------------------------------------------------------------------
[model name]: yolov11n_nv12
input[0]:
name: images
input source: HB_DNN_INPUT_FROM_PYRAMID
valid shape: (1,3,640,640,)
aligned shape: (1,3,640,640,)
aligned byte size: 614400
tensor type: HB_DNN_IMG_TYPE_NV12
tensor layout: HB_DNN_LAYOUT_NCHW
quanti type: NONE
stride: (0,0,0,0,)
output[0]:
name: output0
valid shape: (1,80,80,64,)
aligned shape: (1,80,80,64,)
aligned byte size: 1638400
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (1638400,20480,256,4,)
output[1]:
name: 469
valid shape: (1,40,40,64,)
aligned shape: (1,40,40,64,)
aligned byte size: 409600
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (409600,10240,256,4,)
output[2]:
name: 477
valid shape: (1,20,20,64,)
aligned shape: (1,20,20,64,)
aligned byte size: 102400
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (102400,5120,256,4,)
output[3]:
name: 491
valid shape: (1,80,80,80,)
aligned shape: (1,80,80,80,)
aligned byte size: 2048000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (2048000,25600,320,4,)
output[4]:
name: 505
valid shape: (1,40,40,80,)
aligned shape: (1,40,40,80,)
aligned byte size: 512000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (512000,12800,320,4,)
output[5]:
name: 519
valid shape: (1,20,20,80,)
aligned shape: (1,20,20,80,)
aligned byte size: 128000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (128000,6400,320,4,)-
5.yolov11nworkconfig.json 内容
{
“model_file”: “/home/sunrise/share/hobot_dnn-develop/dnn_node_example/config/yolov11n_nv12.bin”,
“dnn_Parser”: “yolov8”,
“model_output_count”: 6,
“reg_max”: 16,
“class_num”: 80,
“cls_names_list”: “config/coco.list”,
“strides”: [8, 16, 32],
“score_threshold”: 0.25,
“nms_threshold”: 0.7,
“nms_top_k”: 300
}-
6、hb_perf yolo11n_detect_bayese_640x640_nv12.bin
7、反向量移除后-
hb_model_modifier yolov11n_nv12.bin -r /model.23/cv2.0/cv2.0.2/Conv_output_0_HzDequantize -r /model.23/cv2.1/cv2.1.2/Conv_output_0_HzDequantize -r /model.23/cv2.2/cv2.2.2/Conv_output_0_HzDequantize-
hrt_model_exec model_info --model_file yolov11n_nv12_modified.bin
I0000 00:00:00.000000 1664 vlog_is_on.cc:197] RAW: Set VLOG level for “*” to 3
core[0] open!
core[1] open!
[HBRT] set log level as 0. version = 3.15.54.0
[DNN] Runtime version = 1.23.10_(3.15.54 HBRT)
[A][DNN][packed_model.cpp:247][Model](2025-02-05,19:51:40.267.242) [HorizonRT] The model builder version = 1.23.8
Load model to DDR cost 104.054ms.
This model file has 1 model:
[yolov11n_nv12]
---------------------------------------------------------------------
[model name]: yolov11n_nv12
input[0]:
name: images
input source: HB_DNN_INPUT_FROM_PYRAMID
valid shape: (1,3,640,640,)
aligned shape: (1,3,640,640,)
aligned byte size: 614400
tensor type: HB_DNN_IMG_TYPE_NV12
tensor layout: HB_DNN_LAYOUT_NCHW
quanti type: NONE
stride: (0,0,0,0,)
output[0]:
name: output0
valid shape: (1,80,80,80,)
aligned shape: (1,80,80,80,)
aligned byte size: 2048000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (2048000,25600,320,4,)
output[1]:
name: 475
valid shape: (1,80,80,64,)
aligned shape: (1,80,80,64,)
aligned byte size: 1638400
tensor type: HB_DNN_TENSOR_TYPE_S32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: SCALE
stride: (1638400,20480,256,4,)
scale data: 0.000423609,0.000424303,0.000391664,0.000369442,0.000296873,0.000307984,0.000205902,0.000243054,0.000218922,0.000169183,0.000138454,0.000190798,0.000184895,0.000160589,0.000139148,0.00017361,0.000321352,0.000353644,0.000314408,0.000330033,0.000294964,0.00026163,0.000226388,0.000197568,0.000148003,0.00017361,0.000182985,0.000172221,0.000154426,0.000135069,0.000115624,0.000128645,0.000381248,0.000395137,0.000380901,0.000256422,0.000232464,0.000304512,0.000236283,0.000270658,0.000221006,0.000177777,0.000191145,0.000171787,0.000149305,0.000131857,0.000118923,0.000158853,0.000414928,0.000393053,0.000386109,0.000285241,0.000345484,0.000240971,0.000252776,0.000225346,0.000267533,0.000224999,0.000152951,0.000140364,0.000122048,0.000104947,9.27078e-05,0.00015703,
quantizeAxis: 3
output[2]:
name: 489
valid shape: (1,40,40,80,)
aligned shape: (1,40,40,80,)
aligned byte size: 512000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (512000,12800,320,4,)
output[3]:
name: 497
valid shape: (1,40,40,64,)
aligned shape: (1,40,40,64,)
aligned byte size: 409600
tensor type: HB_DNN_TENSOR_TYPE_S32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: SCALE
stride: (409600,10240,256,4,)
scale data: 0.000216406,0.000217248,0.000204618,0.000152832,0.000119487,0.000116792,0.000106687,0.000133717,9.67513e-05,0.000110561,9.32147e-05,8.07103e-05,7.08583e-05,7.05215e-05,6.69007e-05,8.83308e-05,0.000198218,0.000192324,0.000164705,0.00016622,0.000177335,0.000139948,0.000131444,0.000112077,9.36357e-05,7.98682e-05,8.42469e-05,7.89841e-05,7.1532e-05,6.35746e-05,5.51962e-05,5.79329e-05,0.000222637,0.00022129,0.000184914,0.000160326,0.000156031,0.000132286,0.000123107,9.80144e-05,0.000115697,0.000101635,8.00788e-05,6.58482e-05,8.09629e-05,8.68151e-05,8.53416e-05,0.000108877,0.000183735,0.000186935,0.000162515,0.000156789,0.000138854,0.000172283,0.000131612,0.000101467,0.000128412,0.000103403,8.2647e-05,6.69007e-05,6.45009e-05,6.7827e-05,6.55955e-05,8.36154e-05,
quantizeAxis: 3
output[4]:
name: 511
valid shape: (1,20,20,80,)
aligned shape: (1,20,20,80,)
aligned byte size: 128000
tensor type: HB_DNN_TENSOR_TYPE_F32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: NONE
stride: (128000,6400,320,4,)
output[5]:
name: 519
valid shape: (1,20,20,64,)
aligned shape: (1,20,20,64,)
aligned byte size: 102400
tensor type: HB_DNN_TENSOR_TYPE_S32
tensor layout: HB_DNN_LAYOUT_NHWC
quanti type: SCALE
stride: (102400,5120,256,4,)
scale data: 0.000817041,0.000808105,0.000702783,0.00062459,0.000628101,0.000690655,0.000697677,0.000726401,0.000583099,0.000456075,0.000538737,0.000400223,0.000499161,0.000427032,0.000447777,0.000520864,0.000788956,0.000883426,0.000710443,0.00071172,0.000606079,0.000641824,0.000482565,0.000465331,0.000479693,0.000543524,0.00038235,0.000376924,0.000348838,0.000294741,0.000191654,9.05607e-05,0.000868106,0.000870021,0.000636399,0.000675336,0.000615653,0.000583099,0.000626186,0.000420968,0.000447139,0.000595866,0.000437883,0.00050714,0.00037086,0.000319316,0.000344689,0.000372456,0.000771083,0.000699592,0.000637356,0.000611185,0.000627781,0.00064342,0.000687464,0.00056395,0.000610866,0.000575759,0.000602249,0.000432138,0.000432457,0.000372456,0.000406606,0.000438521,
quantizeAxis: 3
---------------------------------------------------------------------
root@08495013b420:/data/horizon_x5/codes/model_outputyolov11#
使用 yolov11n_nv12_modified.bin 还是报同样的错-
8、ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/yolov11workconfig.json dnn_example_image:=config/target.jpg-
然后执行root@ubuntu:/home/sunrise/share/hobot_dnn-develop/dnn_node_example# ros2 launch dnn_node_example dnn_node_example_feedback.launch.py dnn_example_config_file:=config/yolov11workconfig.json dnn_example_image:=config/target.jpg
[INFO] [launch]: All log files can be found below /root/.ros/log/2025-02-05-19-49-27-527307-ubuntu-5525
[INFO] [launch]: Default logging verbosity is set to INFO
dnn_node_example_path is /opt/tros/humble/lib/dnn_node_example
cp_cmd is cp -r /opt/tros/humble/lib/dnn_node_example/config .
[INFO] [example-1]: process started with pid [5528]
[example-1] [WARN] [1738756168.143595718] [dnn_example_node]: Parameter:
[example-1] feed_type(0:local, 1:sub): 0
[example-1] image: config/target.jpg
[example-1] image_type: 0
[example-1] dump_render_img: 1
[example-1] is_shared_mem_sub: 0
[example-1] config_file: config/yolov11workconfig.json
[example-1] msg_pub_topic_name: hobot_dnn_detection
[example-1] info_msg_pub_topic_name: hobot_dnn_detection_info
[example-1] ros_img_topic_name: /image
[example-1] sharedmem_img_topic_name: /hbmem_img
[example-1] [WARN] [1738756168.144440794] [dnn_example_node]: Load [80] class types from file [config/coco.list]
[example-1] [WARN] [1738756168.144577876] [dnn_example_node]: Parameter:
[example-1] model_file_name: /home/sunrise/share/yolov11/yolov11n_nv12_modified.bin
[example-1] model_name:
[example-1] [INFO] [1738756168.144651251] [dnn]: Node init.
[example-1] [INFO] [1738756168.144678000] [dnn_example_node]: Set node para.
[example-1] [WARN] [1738756168.144720500] [dnn_example_node]: model_file_name_: /home/sunrise/share/yolov11/yolov11n_nv12_modified.bin, task_num: 4
[example-1] [INFO] [1738756168.144768875] [dnn]: Model init.
[example-1] [BPU_PLAT]BPU Platform Version(1.3.6)!
[example-1] [HBRT] set log level as 0. version = 3.15.55.0
[example-1] [DNN] Runtime version = 1.24.5_(3.15.55 HBRT)
[example-1] [A][DNN][packed_model.cpp:247][Model](2025-02-05,19:49:28.228.259) [HorizonRT] The model builder version = 1.23.8
[example-1] [INFO] [1738756168.312662474] [dnn]: The model input 0 width is 640 and height is 640
[example-1] [INFO] [1738756168.312831097] [dnn]:
[example-1] Model Info:
[example-1] name: yolov11n_nv12.
[example-1] [input]
[example-1] - (0) Layout: NCHW, Shape: [1, 3, 640, 640], Type: HB_DNN_IMG_TYPE_NV12.
[example-1] [output]
[example-1] - (0) Layout: NHWC, Shape: [1, 80, 80, 64], Type: HB_DNN_TENSOR_TYPE_S32.
[example-1] - (1) Layout: NHWC, Shape: [1, 40, 40, 64], Type: HB_DNN_TENSOR_TYPE_S32.
[example-1] - (2) Layout: NHWC, Shape: [1, 20, 20, 64], Type: HB_DNN_TENSOR_TYPE_S32.
[example-1] - (3) Layout: NHWC, Shape: [1, 80, 80, 80], Type: HB_DNN_TENSOR_TYPE_F32.
[example-1] - (4) Layout: NHWC, Shape: [1, 40, 40, 80], Type: HB_DNN_TENSOR_TYPE_F32.
[example-1] - (5) Layout: NHWC, Shape: [1, 20, 20, 80], Type: HB_DNN_TENSOR_TYPE_F32.
[example-1]
[example-1] [INFO] [1738756168.312877222] [dnn]: Task init.
[example-1] [INFO] [1738756168.314481374] [dnn]: Set task_num [4]
[example-1] [WARN] [1738756168.314562748] [dnn_example_node]: Get model name: yolov11n_nv12 from load model.
[example-1] [INFO] [1738756168.314682289] [dnn_example_node]: The model input width is 640 and height is 640
[example-1] [WARN] [1738756168.314733122] [dnn_example_node]: Create ai msg publisher with topic_name: hobot_dnn_detection
[example-1] [INFO] [1738756168.328336252] [dnn_example_node]: Dnn node feed with local image: config/target.jpg
[example-1] [INFO] [1738756168.387182856] [dnn_example_node]: Output from frame_id: feedback, stamp: 0.0
[ERROR] [example-1]: process has died [pid 5528, exit code -11, cmd ‘/opt/tros/humble/lib/dnn_node_example/example --ros-args --log-level info --ros-args --params-file /tmp/launch_params_lntzvdw_ --params-file /tmp/launch_params_1tbgy6b8 --params-file /tmp/launch_params_km52tfwe --params-file /tmp/launch_params_t2ozwn1v --params-file /tmp/launch_params_ej85ixnj’].
root@ubuntu:/home/sunrise/share/hobot_dnn-develop/dnn_node_example#
9、Python部署是可以的-
[RDK_YOLO] [20:15:30.401] [INFO] Namespace(model_path=‘yolov11n_nv12_modified.bin’, test_img=‘target.jpg’, img_save_path=‘jupyter_result.jpg’, classes_num=80, reg=16, iou_thres=0.45, conf_thres=0.25)
[BPU_PLAT]BPU Platform Version(1.3.6)!
[HBRT] set log level as 0. version = 3.15.55.0
[DNN] Runtime version = 1.24.5_(3.15.55 HBRT)
[A][DNN][packed_model.cpp:247][Model](2025-02-05,20:15:30.484.553) [HorizonRT] The model builder version = 1.23.8
[W][DNN]bpu_model_info.cpp:491][Version](2025-02-05,20:15:30.573.448) Model: yolov11n_nv12. Inconsistency between the hbrt library version 3.15.55.0 and the model build version 3.15.54.0 detected, in order to ensure correct model results, it is recommended to use compilation tools and the BPU SDK from the same OpenExplorer package.
[RDK_YOLO] [20:15:30.577] [DEBUG] Load D-Robotics Quantize model time = 175.82 ms
[RDK_YOLO] [20:15:30.578] [INFO] → input tensors
[RDK_YOLO] [20:15:30.578] [INFO] intput[0], name=images, type=uint8, shape=(1, 3, 640, 640)
[RDK_YOLO] [20:15:30.579] [INFO] → output tensors
[RDK_YOLO] [20:15:30.579] [INFO] output[0], name=output0, type=int32, shape=(1, 80, 80, 64)
[RDK_YOLO] [20:15:30.579] [INFO] output[1], name=469, type=int32, shape=(1, 40, 40, 64)
[RDK_YOLO] [20:15:30.579] [INFO] output[2], name=477, type=int32, shape=(1, 20, 20, 64)
[RDK_YOLO] [20:15:30.579] [INFO] output[3], name=491, type=float32, shape=(1, 80, 80, 80)
[RDK_YOLO] [20:15:30.580] [INFO] output[4], name=505, type=float32, shape=(1, 40, 40, 80)
[RDK_YOLO] [20:15:30.580] [INFO] output[5], name=519, type=float32, shape=(1, 20, 20, 80)
[RDK_YOLO] [20:15:30.580] [INFO] self.s_bboxes_scale.shape=(1, 64), self.m_bboxes_scale.shape=(1, 64), self.l_bboxes_scale.shape=(1, 64)
[RDK_YOLO] [20:15:30.580] [INFO] self.weights_static.shape = (1, 1, 16)
[RDK_YOLO] [20:15:30.582] [INFO] self.s_anchor.shape = (6400, 2), self.m_anchor.shape = (1600, 2), self.l_anchor.shape = (400, 2)
[RDK_YOLO] [20:15:30.583] [INFO] iou threshol = 0.45, conf threshol = 0.25
[RDK_YOLO] [20:15:30.583] [INFO] sigmoid_inverse threshol = -1.10
[RDK_YOLO] [20:15:30.618] [DEBUG] bgr8 to nv12 time = 10.66 ms
[RDK_YOLO] [20:15:30.631] [DEBUG] forward time = 12.02 ms
[RDK_YOLO] [20:15:30.638] [DEBUG] c to numpy time = 6.22 ms
[RDK_YOLO] [20:15:30.644] [DEBUG] Post Process time = 6.31 ms
[RDK_YOLO] [20:15:30.645] [INFO] Draw Results:
[RDK_YOLO] [20:15:30.645] [INFO] (112, 336, 560, 496) → couch: 0.64
[RDK_YOLO] [20:15:30.646] [INFO] (496, 208, 624, 464) → potted plant: 0.51
[RDK_YOLO] [20:15:30.647] [INFO] (68, 188, 100, 236) → potted plant: 0.25
[RDK_YOLO] [20:15:30.664] [INFO] saved in path: “./jupyter_result.jpg”
root@ubuntu:/home/sunrise/share/yolov11#-
就是tros部署不行-
从官网下载的bin文件
执行 YOLOv11_Detect_YUV420SP.py 是可以,但是使用tros还是报错
[ERROR] [websocket-4]: process has died [pid 5914, exit code -2, cmd ‘/opt/tros/humble/lib/websocket/websocket --ros-args --log-level warn --ros-args --params-file /tmp/launch_params_9t65onpw --params-file /tmp/launch_params_zj4vy6ch --params-file /tmp/launch_params_q8_2xngk --params-file /tmp/launch_params_3fmln45g --params-file /tmp/launch_params_5tnsuqrz --params-file /tmp/launch_params_eq1_a038’].
这里报的是-2,我生成的报的-11

