RuntimeError: Only support opset 11, but got 9

edited November 2021 in AI Model migration

進行onnx2onnx指令:python /workspace/libs/ONNX_Convertor/optimizer_scripts/onnx2onnx.py yolov3-tiny.onnx -o yolov3-tiny_opt.onnx --add-bn -t時跳出下圖錯誤

在討論區找到指令更新:python /workspace/libs/ONNX_Convertor/optimizer_scripts/onnx1_4to1_6.py yolov3-tiny.onnx yolov3-tiny_up.onnx跳出下圖錯誤,是否為filters數值,該如何去更改呢?



Tagged:

Comments

  • @Fred


    Hi Fred,


     您給的 "yolov3-tiny.onnx" model output shape 不正確,您可以修改 model output shape 修改方式如下,修改後您就可以繼續完成指令 python /workspace/libs/ONNX_Convertor/optimizer_scripts/onnx1_4to1_6.py yolov3-tiny_modified_output.onnx yolov3-tiny_up.onnx,並成功 optimize。


    import onnx
    import onnx.utils
    
    
    m = onnx.load('./yolov3-tiny.onnx')#您的model
    
    
    # modify output shape mannually
    m.graph.output[0].type.tensor_type.shape.dim[0].dim_value = 1
    m.graph.output[0].type.tensor_type.shape.dim[1].dim_value = 255
    m.graph.output[0].type.tensor_type.shape.dim[2].dim_value = 13
    m.graph.output[0].type.tensor_type.shape.dim[3].dim_value = 13
    
    
    m.graph.output[1].type.tensor_type.shape.dim[0].dim_value = 1
    m.graph.output[1].type.tensor_type.shape.dim[1].dim_value = 255
    m.graph.output[1].type.tensor_type.shape.dim[2].dim_value = 26
    m.graph.output[1].type.tensor_type.shape.dim[3].dim_value = 26
    
    
    m2 = onnx.utils.polish_model(m)
    
    onnx.save(m2,'./yolov3-tiny_modified_output.onnx')#修改後的model
    


    以下是成功的執行結果


    以下是您給的"yolov3-tiny.onnx" model structure

    圖中的紅線處應該是1x255x13x131x255x26x26才對。

    想請問您,不知道您是怎麼取得這個model的,方便的話是否可以反饋給我們。

The discussion has been closed due to inactivity. To continue with the topic, please feel free to post a new discussion.