ppyolo模型,用tros运行成功,但是直接在x3派上运行报错

我修改的步骤:

1. 替换掉app文件夹里面test_yolov3.py的模型与模型加载代码

我把官方ppyolo帖子里面的ppyolo_trashdet_416x416_nv12.bin文件放到/app/ai_inference/models中,

并修改/app/ai_inference/06_yolov3_sample/test_yolov3.py里面的模型加载,把它改成加载ppyolo_trashdet_416x416_nv12.bin

2. 修改分类文件里面的分类和后处理代码里面的分类数

修改了postpress.py里面的num_classes = 80改为num_classes = 1,以及coco_classes.names里面的类别也全删了,就写了一个trash

自己运行原本正常程序与修改后程序的对比结果:

原本程序执行推理返回的元组大小是3,修改后推理后返回的元组大小却为2

其他的尝试:

使用tros运行成功,而且配置文件后处理配置写的也是yolov3

运行使用的指令:ros2 launch dnn_node_example hobot_dnn_node_example.launch.py config_file:=config/ppyoloworkconfig.json msg_pub_topic_name:=ai_msg_mono2d_trash_detection image_width:=1920 image_height:=1080

未修改前正常程序运行信息

[C][5496][03-04][17:01:47:590][configuration.cpp:51][EasyDNN]EasyDNN version: 0.1.1

[BPU_PLAT]BPU Platform Version(1.3.3)!

[HBRT] set log level as 0. version = 3.14.5

[DNN] Runtime version = 1.9.7_(3.14.5 HBRT)

tensor type: NV12_SEPARATE

data type: uint8

layout: NCHW

shape: (1, 3, 416, 416)

3

tensor type: float32

data type: float32

layout: NHWC

shape: (1, 13, 13, 255)

tensor type: float32

data type: float32

layout: NHWC

shape: (1, 26, 26, 255)

tensor type: float32

data type: float32

layout: NHWC

shape: (1, 52, 52, 255)

==============================================

<class ‘tuple’>

3

(1, 52, 52, 255)

==============================================

detected item num: 16

person is in the picture with confidence:0.9898

person is in the picture with confidence:0.9867

person is in the picture with confidence:0.9297

person is in the picture with confidence:0.9114

person is in the picture with confidence:0.8958

person is in the picture with confidence:0.8801

person is in the picture with confidence:0.8213

person is in the picture with confidence:0.7038

person is in the picture with confidence:0.5001

person is in the picture with confidence:0.4798

kite is in the picture with confidence:0.9792

kite is in the picture with confidence:0.7745

kite is in the picture with confidence:0.6520

kite is in the picture with confidence:0.5453

kite is in the picture with confidence:0.5256

kite is in the picture with confidence:0.4490

[array([109.97397964, 609.3799464 , 165.59845765, 768.23997301,

0.98983681, 0. ]), array([212.993 , 697.4619933 , 273.82313922, 849.52617116,

0.98665556, 0. ]), array([ 78.63372576, 507.68010446, 108.26859891, 568.40274138,

0.92970676, 0. ]), array([176.88269225, 540.27909615, 197.19433603, 573.25273544,

0.91135648, 0. ]), array([345.48917175, 486.14568209, 357.63510727, 505.59590181,

0.89577639, 0. ]), array([520.85178416, 504.50164454, 535.68336446, 527.79051608,

0.88014819, 0. ]), array([ 26.21890852, 524.41786036, 45.83317021, 556.99691989,

0.82129945, 0. ]), array([541.99734285, 515.08086873, 556.98230192, 534.88092561,

0.70380589, 0. ]), array([5.24318668e+02, 5.17251076e+02, 5.42762714e+02, 5.30034187e+02,

5.00111708e-01, 0.00000000e+00]), array([3.02657943e+01, 5.14510368e+02, 5.16450562e+01, 5.50474636e+02,

4.79826691e-01, 0.00000000e+00]), array([593.15143204, 79.84221712, 674.67715836, 150.61631756,

0.97919091, 33. ]), array([279.39018098, 234.82780816, 307.23055419, 281.00842336,

0.77447677, 33. ]), array([306.41312492, 374.88221513, 325.55392754, 405.03702039,

0.65199802, 33. ]), array([5.79715805e+02, 3.45468275e+02, 5.98832008e+02, 3.66825490e+02,

5.45296997e-01, 3.30000000e+01]), array([1.08276234e+03, 3.93677806e+02, 1.10494449e+03, 4.24567473e+02,

5.25616331e-01, 3.30000000e+01]), array([4.68791874e+02, 3.37578726e+02, 4.86844799e+02, 3.60711761e+02,

4.48973435e-01, 3.30000000e+01])]

【INFO】: Offload model “yolov3_darknet53_416x416_nv12” Successfully.

修改后报错信息

[C][5349][03-04][16:43:16:619][configuration.cpp:51][EasyDNN]EasyDNN version: 0.1.1

[BPU_PLAT]BPU Platform Version(1.3.3)!

[HBRT] set log level as 0. version = 3.14.5

[DNN] Runtime version = 1.9.7_(3.14.5 HBRT)

tensor type: NV12_SEPARATE

data type: uint8

layout: NCHW

shape: (1, 3, 416, 416)

2

tensor type: float32

data type: float32

layout: NHWC

shape: (1, 13, 13, 18)

tensor type: float32

data type: float32

layout: NHWC

shape: (1, 26, 26, 18)

==============================================

<class ‘tuple’>

2

Traceback (most recent call last):

File “test_yolov3.py”, line 55, in

prediction_bbox = postprocess(outputs, model_hw_shape=(416, 416), origin_image=img_file)

File “/app/ai_inference/06_yolov3_sample/postprocess.py”, line 37, in postprocess

print(model_output[2].properties.shape)

IndexError: tuple index out of range

【INFO】: Offload model “ppyolo_trashdet_416x416_nv12” Successfully.

双横杠里面为我自己查看信息的代码输出的内容

config文件夹的百度链接

链接:百度网盘-链接不存在

提取码:1234

这个config里面有ppyolo_trashdet_416x416_nv12.bin文件

您好同学,如果模型可以在tros启动运行正常,那说明模型转换是成功的。

看你的问题可能出现在板端C++推理中,可以参考我这个c++示例,跑起这个模型。对照定位问题。

示例在下面项目链接中bpu_cdev压缩包中。、

可以参考python api接口手册,需要调整输入输出的数据接口,打印具体的数据进行对比

不想用c++运行,想用python运行,至于报错我早就发现快一个月了,但是我不明白为什么ppyolo的模型加载后,不进行任何处理,直接输出models[0].outsputs他是2,但是正常是3,这个过程就一行代码,就是model=dnn.load(path),没地方改啊,而模型我是直接用的你们官方案例的,而且tros运行也是成功的啊

你好,我也遇到同样的问题,请问你的解决了吗?

这个模型输出是2,yolo的输出分支对应不同的下采样倍率,这个ppyolo版本输出只有2,就按两个分支和stride去处理就好