专栏算法工具链使用api进行nv12 to rgb 的转换,没有起效

使用api进行nv12 to rgb 的转换,没有起效

已解决
2025-06-25
60
3

可以把多batch的输入[6*3*640*640]分成六个[1*3*640*640],但是

insert_image_convert转化没有起效,依然是rgb的输入

import os
import onnx
from hbdk4.compiler.onnx import export
from hbdk4.compiler import convert, compile, visualize, save
script_dir = os.path.dirname(os.path.realpath(__file__))


model_path = os.path.join(script_dir, "bev_fushion/hbm/bev_occ_lane_int16_100", "bev_occ_lane_int16_100_ptq_model.onnx")
onnx_model = onnx.load(model_path)
model = export(onnx_model)
func = model.functions[0]

# 将BATCH拆分开

func.inputs[0].insert_split(dim=0)


for input in func.inputs[::-1]:
if input.name != "img":
print(f"Skip non-image input: {input.name}")

continue



input = input.insert_transpose(permutes=[0, 2, 3, 1])


input = input.insert_image_preprocess(
mode="yuvbt601full2rgb",
divisor=255,
mean=[123.675, 116.28, 103.53],
std=[0.01712475, 0.017507, 0.01742919]

)

y, uv = input.insert_image_convert("nv12")


save(model, os.path.join(script_dir, "model_output_v2", "sample_addpre.bc"))
quantized_model = convert(model, march="nash-e")
save(quantized_model, os.path.join(script_dir, "model_output_v2", "sample_quantized_split.bc"))
hbm = compile(quantized_model, march="nash-e",path=os.path.join(script_dir, "model_output_v2", "sample.hbm"), debug=True,
opt=0, jobs=40, progress_bar=True)
算法工具链
征程6
评论1
0/1000
  • momo(社区版)
    Lv.4

    代码有点问题,参考这个

    2025-06-25
    0
    2
    • 回复momo(社区版):
      你好,已经通过模型修改实现了nv12输入转换rgb,但是新模型量化后,后面的卷积层突然增加了160ms的耗时,这个是什么原因呢
      2025-06-26
      0
    • 回复momo(社区版):

      j6-e 对于6路的nv12转rgb 是不是会影响性能,最高可以允许多大的数据量输入呢

      2025-06-26
      0