axinc-ai / ailia-models-tflite

Quantized version of model library
23 stars 1 forks source link

Optimize yolox model #9

Closed kyakuno closed 2 years ago

kyakuno commented 2 years ago

The current yolox model has many transpose layers inserted, so I would like to optimize it by following the steps below.

Why does onnx-tensorflow add Transpose layers for each Conv2D layer? https://github.com/onnx/onnx-tensorflow/issues/782

I found the solution, perform following to convert form pytorch ---> tflite (NCHW ---> NHWC):

pytorch official export to onnx [N,C,H,W] ---> [N,C,H,W]
onnx conversion to open-vino IR format [N,C,H,W] ---> [N,C,H,W] (using openvino docker image)
open-vino-IR format to tensorflow format [N,C,H,W] ---> [N,H,W,C] (using openvino2tensorflow ⚡ 💡 docker image, see https://github.com/PINTO0309/openvino2tensorflow.git)
tensorflow format to tflite [N,H,W,C] ---> [N,H,W,C] 😄

OpenVino2Tensorflow https://github.com/PINTO0309/openvino2tensorflow

Tutorial https://qiita.com/PINTO/items/ed06e03eb5c007c2e102