yaml文件配置

我来帮你分析这个 YAML 配置错误。从日志看,input_parameters 中的 input_layout 和 input_type 是无效的配置项。

让我先搜索一下社区中正确的 hb_mapper 配置格式:

问题定位

你的 YAML 配置格式过时了。错误信息很明确:

Wrong keys 'input_layout', 'input_type'

这两个键名在新版 hb_mapper 工具链中已废弃,需要改用新格式。

解决方案

正确的 YAML 配置格式(X5 平台)

model_parameters:
  onnx_model: /workspace/yolo11n-seg.onnx
  march: x5
  output_model_file_prefix: /workspace/yolo11n_seg

input_parameters:
  input_name: images
  input_type_rt: nv12          # 板端推理输入类型
  input_type_train: rgb        # 训练时输入类型
  input_layout_train: NCHW     # 训练时布局
  norm_type: data_scale
  scale_value: 0.003921568627451  # 1/255

calibration_parameters:
  cal_data_dir: /workspace/calibration_images
  cal_data_type: float32

compiler_parameters:
  compile_mode: latency
  optimize_level: O3
  debug: false

关键修改点

旧格式(错误) 新格式(正确)
input_type: rgb input_type_rt: nv12 + input_type_train: rgb
input_layout: NCHW input_layout_train: NCHW
input_shape: [1,3,640,640] 删除(工具链自动从 ONNX 读取)
calibration_type: default cal_data_type: float32
compile_parameters.optimize_method: bpu compiler_parameters.optimize_level: O3
compile_parameters.target: x5 删除(march 已指定)

执行步骤

# 1. 创建正确的配置文件
cat > /workspace/yolo11n_seg_config.yaml <<'EOF'
model_parameters:
  onnx_model: /workspace/yolo11n-seg.onnx
  march: x5
  output_model_file_prefix: /workspace/yolo11n_seg

input_parameters:
  input_name: images
  input_type_rt: nv12
  input_type_train: rgb
  input_layout_train: NCHW
  norm_type: data_scale
  scale_value: 0.003921568627451

calibration_parameters:
  cal_data_dir: /workspace/calibration_images
  cal_data_type: float32

compiler_parameters:
  compile_mode: latency
  optimize_level: O3
  debug: false
EOF

# 2. 执行转换
hb_mapper makertbin --config /workspace/yolo11n_seg_config.yaml

参考资源

社区已有完整教程,建议查看:

注意事项

  1. 工具链版本:你用的是 hb_mapper version 1.24.3,配置格式已更新
  2. 分割模型:YOLO11-seg 有 6 个输出头,转换后可用 hb_perf 验证
  3. 校准数据:确保 /workspace/calibration_images 目录存在且有足够图片(建议 100+ 张)

转换成功后,可以用以下命令验证模型:

hb_perf /workspace/yolo11n_seg.bin