yolov5_onnx2caffe icon indicating copy to clipboard operation
yolov5_onnx2caffe copied to clipboard

An error on converting yolov5s-simple model

Open antran89 opened this issue 4 years ago • 17 comments

Hi @Wulingtian, I followed your tutorial https://mp.weixin.qq.com/s/DsqEfpyud8dYzCV0mB9CpA/ After compiling, and run the code, it has the following error: Do you have any idea?

Converting onnx model:  ../yolov5/yolov5s-simple.onnx
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128, '237': 128, '238': 128, '239': 128, '240': 128, '241': 128, '242': 128, '243': 128}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128, '237': 128, '238': 128, '239': 128, '240': 128, '241': 128, '242': 128, '243': 128}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128, '237': 128, '238': 128, '239': 128, '240': 128, '241': 128, '242': 128, '243': 128, '244': 128, '245': 128, '246': 128, '247': 128, '248': 128, '249': 128, '250': 128}
{'images': 3, '167': 3, '168': 32, '169': 32, '170': 32, '171': 64, '172': 64, '173': 64, '174': 32, '175': 32, '176': 32, '177': 32, '178': 32, '179': 32, '180': 32, '181': 32, '182': 32, '183': 32, '184': 32, '185': 32, '186': 32, '187': 64, '188': 64, '189': 64, '190': 64, '191': 128, '192': 128, '193': 128, '194': 64, '195': 64, '196': 64, '197': 64, '198': 64, '199': 64, '200': 64, '201': 64, '202': 64, '203': 64, '204': 64, '205': 64, '206': 64, '207': 64, '208': 64, '209': 64, '210': 64, '211': 64, '212': 64, '213': 64, '214': 64, '215': 64, '216': 64, '217': 64, '218': 64, '219': 64, '220': 64, '221': 128, '222': 128, '223': 128, '224': 128, '225': 256, '226': 256, '227': 256, '228': 128, '229': 128, '230': 128, '231': 128, '232': 128, '233': 128, '234': 128, '235': 128, '236': 128, '237': 128, '238': 128, '239': 128, '240': 128, '241': 128, '242': 128, '243': 128, '244': 128, '245': 128, '246': 128, '247': 128, '248': 128, '249': 128, '250': 128}
Traceback (most recent call last):
  File "convertCaffe.py", line 160, in <module>
    convertToCaffe(graph, prototxt_path, caffemodel_path, exis_focus=True, focus_concat_name="Concat_40", focus_conv_name="Conv_41")
  File "convertCaffe.py", line 83, in convertToCaffe
    layer = converter_fn(node, graph, err)
  File "/data/ot-workspace/yolov5_onnx2caffe/onnx2caffe/_operators.py", line 505, in _convert_resize
    height_scale = scales[2]
IndexError: index 2 is out of bounds for axis 0 with size 0

antran89 avatar Mar 09 '21 07:03 antran89

Hi @Wulingtian , Which version of onnx you are using? I still have the error, please help.

antran89 avatar Mar 10 '21 11:03 antran89

Hi @Wulingtian , Which version of onnx you are using? I still have the error, please help. onnx 1.8.0 op version设置为10

Wulingtian avatar Mar 10 '21 11:03 Wulingtian

@Wulingtian how to check the op version? Can you help me check if this configuration is good?

docker@f94033463fe8:/data/ot-workspace/yolov5_onnx2caffe$ pip freeze | grep onnx
onnx==1.8.1
onnx-simplifier==0.3.3
onnxoptimizer==0.2.4
onnxruntime==1.7.0

antran89 avatar Mar 10 '21 11:03 antran89

Thank @Wulingtian for your answer, I am able to make the code working.

antran89 avatar Mar 11 '21 04:03 antran89

@antran89 你好,我也遇到这个问题,请问大佬是如何解决

CasonTsai avatar Mar 26 '21 03:03 CasonTsai

@CasonTsai I am not able to understand Chinese much. 你好

antran89 avatar Mar 28 '21 04:03 antran89

@antran89 i am sorry,,now I've solved the problem ,,thank you

CasonTsai avatar Apr 01 '21 12:04 CasonTsai

@antran89 i am sorry,,now I've solved the problem ,,thank you

您好,怎么解决的

lccui avatar Apr 03 '21 19:04 lccui

@CasonTsai 您好,请问怎么解决的

lccui avatar Apr 03 '21 19:04 lccui

@lccui 跟作者版本保持一致,然后先把pt转onnx,然后设置转换参数中的opset_version =10 image

CasonTsai avatar Apr 07 '21 01:04 CasonTsai

@CasonTsai great! that is what I did.

antran89 avatar Apr 07 '21 03:04 antran89

@antran89 @CasonTsai Hi,did you encounter this problem?

Traceback (most recent call last): File "convertCaffe.py", line 160, in convertToCaffe(graph, prototxt_path, caffemodel_path, exis_focus=True, focus_concat_name="Concat_40", focus_conv_name="Conv_41") File "convertCaffe.py", line 98, in convertToCaffe layers[id] = layer._to_proto() # \u8f6c\u4e3a proto \u98ce\u683c\uff1f File "/workspace/yolov5_onnx2caffe-master/MyCaffe.py", line 100, in _to_proto assign_proto(layer, k, v) File "/workspace/yolov5_onnx2caffe-master/MyCaffe.py", line 29, in assign_proto is_repeated_field = hasattr(getattr(proto, name), 'extend') AttributeError: reorg_param

duan348733684 avatar Apr 13 '21 07:04 duan348733684

@antran89

duan348733684 avatar Apr 19 '21 06:04 duan348733684

@CasonTsai

duan348733684 avatar Apr 19 '21 06:04 duan348733684

@duan348733684 i am sorry about dalayed reply because of the busy work,did your caffe version match 1.0 and build the author's yolo_caffe,you should check the caffe version and find if reorg_param 和region_param are in caffe.pb.h file

CasonTsai avatar Apr 20 '21 06:04 CasonTsai

您好,请问这个可以在windows下跑吗,虚拟机不能装cuda,服务器又没有权限

Cuzny avatar Apr 27 '21 11:04 Cuzny

@antran89 @CasonTsai Hi,did you encounter this problem?

Traceback (most recent call last): File "convertCaffe.py", line 160, in convertToCaffe(graph, prototxt_path, caffemodel_path, exis_focus=True, focus_concat_name="Concat_40", focus_conv_name="Conv_41") File "convertCaffe.py", line 98, in convertToCaffe layers[id] = layer._to_proto() # \u8f6c\u4e3a proto \u98ce\u683c\uff1f File "/workspace/yolov5_onnx2caffe-master/MyCaffe.py", line 100, in _to_proto assign_proto(layer, k, v) File "/workspace/yolov5_onnx2caffe-master/MyCaffe.py", line 29, in assign_proto is_repeated_field = hasattr(getattr(proto, name), 'extend') AttributeError: reorg_param

@duan348733684 请问你解决这个问题了吗

heylary avatar Apr 10 '22 09:04 heylary