裁剪 model 後無法使用 e2e_checke onnx 發生問題

https://www.kneron.com/forum/discussion/comment/1205#Comment_1205

在回覆說可以用 editor 去做去除 sigmoid ,先使用optimizer 把原始模型處理過後得到 yolo.opt.onnx 可推理可後處理 再使用 editor 去除 sigmoid 但得到的模型就無法進行推理後處理了, 是否是 sigmoid 導致輸出不一致,無法再進行後處理?

步驟:

yolov5s-noupsample-coco128.onnx => yolo.opt.onnx => yolo.opt.edited.onnx => yolo.opt.edited.opt.onnx

模型在回覆內

Tagged:

Comments

  • edited July 2022

    優化後模型

    使用 python editor.py yolo.opt.onnx yolo.opt.edited.onnx -d Sigmoid_129 Sigmoid_131 Sigmoid_133

    進行剪枝後得到的模型

    剪枝後再進行優化,推理可以,但無法後處理

    原始模型


  • @johnson luo

    Hi johnson,

    這裡可能有兩點問題,

    1. 您提供的 model 與 "e2e_check_float.py" 裡使用的 model 不一樣。

    兩個 model 屬於不同的 output shape (如附圖:您提供的 model output shape:[1, 24, x, x]、執行 "e2e_check_float.py" 的 model output shape:[1, 255, x, x]),所以 "e2e_check_float.py" 內的 Yolov5_postprocess_onnx_sig() 無法直接使用論壇上提供的 model。


    2. 如果是使用 "e2e_check_float.py" 的 model,去除 sigmoid 後 postprocess output node shape 會改變。

    除去前 (result80(1, 255, 80, 80)、result40(1, 255, 40, 40)、result20(1, 255, 20, 20)),除去後會變成 (result80(1, 255, 20, 20)、result40(1, 255, 80, 80)、result20(1, 255, 40, 40))。

    所以 output node shape 順序必須修改,修改後應該就可順利執行了但記得後面需要做一下 sigmoid 不然會導致 inference 出現不準的狀況。

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