Translation procedure for YOLOX: Difference between revisions

From Renesas.info
(Created DRp-AI Translator procedure YoloX)
 
(Updared YoloX Procedure)
 
Line 6: Line 6:
* Cut the post-processing part of the ONNX and use it
* Cut the post-processing part of the ONNX and use it
* Run DRP-AI Translator v1.80 or later on Ubuntu 20.04
* Run DRP-AI Translator v1.80 or later on Ubuntu 20.04
==1. Download ONNX==
Please run the following command to download the ONNX in Megvii-BaseDetection
<pre>
$ wget <nowiki>https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx</nowiki>
</pre>
==2. Cut post-processing part of ONNX==
Please edit the following in an editor such as vim, and save it as yolox_s_cut.py.
<pre>
$ vim yolox_s_cut.py
</pre>
<pre>
# yolox_s_cut.py
import onnx
input_path = 'yolox_s.onnx'
output_path = 'yolox_s_wo_post.onnx'
input_names = ['images']
output_names = ['798', '824', '850']
onnx.utils.extract_model(input_path, output_path, input_names, output_names)
</pre>
[[File:image 2023-01-30 211718717.png|thumb|As shown in the figure below, please find and specify the output name of Concat before Reshape]]
Please run yolox_s_cut.py with the following command. If executed successfully, yolox_s_wo_post.onnx will be generated.
<pre>
$ python3 yolox_s_cut.py
</pre>
The above output names, 798, 824, and 850, are for YOLOX-s. Please note that different names must be specified for other
YOLOX (e.g. YOLOX-m). As shown in the figure below, please find and specify the output name of Concat before Reshape
of the three outputs of YOLOX.
==3. Translate ONNX==
Please run DRP-AI Translator using the generated yolox_s_wo_post.onnx. DRP-AI Translator must be v1.80 or later. For
information on how to run DRP-AI Translator, please refer to the User's Manual.
==4. Post-processing==
The post-processing (Reshape > Concat > Transpose) that is cut this time is the processing that concatinates the data of
three CHW shapes and converts them to HWC shapes.
DRP-AI outputs data in HWC shape by default, so if the three output data are stored in consecutive memory areas, the
same sequence of data as after post-processing is obtained in terms of memory layout.
[[File:image 2023-01-30 211827731.png|frameless|1200x1200px]]

Latest revision as of 05:20, 31 January 2023

This document describes the procedure for translating YOLOX with DRP-AI Translator v1.80 or later.

Please note the following:

  • Use ONNX in Megvii-BaseDetection/YOLOX (OSS GitHub repository)
  • Cut the post-processing part of the ONNX and use it
  • Run DRP-AI Translator v1.80 or later on Ubuntu 20.04

1. Download ONNX

Please run the following command to download the ONNX in Megvii-BaseDetection

$ wget https://github.com/Megvii-BaseDetection/YOLOX/releases/download/0.1.1rc0/yolox_s.onnx

2. Cut post-processing part of ONNX

Please edit the following in an editor such as vim, and save it as yolox_s_cut.py.

$ vim yolox_s_cut.py
# yolox_s_cut.py
import onnx
input_path = 'yolox_s.onnx'
output_path = 'yolox_s_wo_post.onnx'
input_names = ['images']
output_names = ['798', '824', '850']
onnx.utils.extract_model(input_path, output_path, input_names, output_names)
As shown in the figure below, please find and specify the output name of Concat before Reshape

Please run yolox_s_cut.py with the following command. If executed successfully, yolox_s_wo_post.onnx will be generated.

$ python3 yolox_s_cut.py

The above output names, 798, 824, and 850, are for YOLOX-s. Please note that different names must be specified for other

YOLOX (e.g. YOLOX-m). As shown in the figure below, please find and specify the output name of Concat before Reshape

of the three outputs of YOLOX.

3. Translate ONNX

Please run DRP-AI Translator using the generated yolox_s_wo_post.onnx. DRP-AI Translator must be v1.80 or later. For

information on how to run DRP-AI Translator, please refer to the User's Manual.

4. Post-processing

The post-processing (Reshape > Concat > Transpose) that is cut this time is the processing that concatinates the data of

three CHW shapes and converts them to HWC shapes.

DRP-AI outputs data in HWC shape by default, so if the three output data are stored in consecutive memory areas, the

same sequence of data as after post-processing is obtained in terms of memory layout.

image 2023-01-30 211827731.png