×

签到

分享到微信

打开微信,使用扫一扫进入页面后,点击右上角菜单,

点击“发送给朋友”或“分享到朋友圈”完成分享

YOLOV5 离线模型生成出错 已完结 shilei2022-12-21 14:38:19 回复 13 查看 使用求助
YOLOV5 离线模型生成出错
分享到:

python detect.py --cfg mlu --weights mlu.pt --jit True

自己训练的模型,不调用下面这段代码识别结果是正常的

if opt.jit:

            ct.save_as_cambricon('yolov5s')

            torch.set_grad_enabled(False)

            ct.set_core_number(4)

            trace_input = torch.randn(13640640dtype=torch.float)

            input_mlu_data = trace_input.type(torch.HalfTensor).to(ct.mlu_device())

            quantized_net = torch.jit.trace(quantized_net, input_mlu_data, check_trace = False)


出错的部分如下:

[ERROR][/pytorch/catch/torch_mlu/csrc/jit/fuser/fused_kernel.cpp][line:44][CheckMFUSInputShape][thread:140702296545088][process:9529]: 


The 0th input shape in fusion op is not equal to real input!

Please check the python code where the 'mfus forward' is called.


For example:

traced_model = torch.jit.trace(net, example_input, ...)

output1 = traced_model(real_input1)

output2 = traced_model(real_input2)

output3 = traced_model(real_input3)

...

The input shape of fusion op has been detetermined after traced_model.forward has been called at the first time.

Please note that real_input2.shape, real_input3.shape, ... should be equal to real_input1.shape!

If the real_input2, real_input3, ... are tuples of tensors, shape of each tensor in these tuples should be equal to the shape of corresponding tensor in real_input1.


image 3/5 /home/yolov5/yolov5-4.0/data/images/bus.jpg: num_boxes_final:  0.0

im0s.shape: (1080, 810, 3)

[array([], shape=(0, 6), dtype=float64)]

run mlu

[ERROR][/pytorch/catch/torch_mlu/csrc/jit/fuser/fused_kernel.cpp][line:44][CheckMFUSInputShape][thread:140702296545088][process:9529]: 


The 0th input shape in fusion op is not equal to real input!

Please check the python code where the 'mfus forward' is called.


For example:

traced_model = torch.jit.trace(net, example_input, ...)

output1 = traced_model(real_input1)

output2 = traced_model(real_input2)

output3 = traced_model(real_input3)

...

The input shape of fusion op has been detetermined after traced_model.forward has been called at the first time.

Please note that real_input2.shape, real_input3.shape, ... should be equal to real_input1.shape!

If the real_input2, real_input3, ... are tuples of tensors, shape of each tensor in these tuples should be equal to the shape of corresponding tensor in real_input1.


image 4/5 /home/yolov5/yolov5-4.0/data/images/x.png: num_boxes_final:  24.0

im0s.shape: (641, 641, 3)

[array([[    -143.38,     -129.88,      35.781,     -68.438,    -0.26392,   -0.094543],

       [     -177.5,     -4.3984,         337,    0.097351,    -0.25708,  0.00029802],

       [       -165,     -150.38,     -74.625,     0.16113,     0.21375,  0.00035262],

       [    -177.62,     -4.0273,     -121.62,    0.087646,    -0.20947,  0.00013697],

       [    -173.38,     -172.88,      -151.5,     0.38599,    -0.23706,     0.26367],

       [    -167.12,        -170,        -140,     0.12585,  -0.0075111,  0.00021529]])]

run mlu

image 5/5 /home/yolov5/yolov5-4.0/data/images/zidane.jpg: num_boxes_final:  4.0

im0s.shape: (720, 1280, 3)

[array([[        200,      84.875,      202.88,      199.12,      0.2771,     0.68555],

       [    -31.406,     -48.156,     -11.336,        72.5,    -0.01619,    -0.11102]])]

run mlu

Results saved to runs/detect/exp31

Done. (25.564s)



版权所有 © 2024 寒武纪 Cambricon.com 备案/许可证号:京ICP备17003415号-1
关闭