Home

Awesome

simple-onnx-processing-tools

A set of simple tools for splitting, merging, OP deletion, size compression, rewriting attributes and constants, OP generation, change opset, change to the specified input order, addition of OP, RGB to BGR conversion, change batch size, batch rename of OP, and JSON convertion for ONNX models.

Downloads GitHub PyPI

<p align="center"> <img src="https://user-images.githubusercontent.com/33194443/162783149-3b0d6e25-44da-4bc1-89fb-beae8aeae31d.png" /> </p>

1. Tools

HostPC

# (1) Minimum configuration installation with no dependent packages installed
$ pip install -U simple-onnx-processing-tools \
&& pip install -U onnx \
&& python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com

or

# (2) When installing all dependent packages such as onnx-simplifier, onnxruntime, numpy, etc...
$ pip install -U simple-onnx-processing-tools[full] \
&& pip install -U onnx \
&& python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com

Docker

$ docker run --rm -it \
-v `pwd`:/workdir \
-w /workdir \
ghcr.io/pinto0309/simple-onnx-processing-tools:1.1.31
No.Tool NameTagsSummary
1snc4onnx<br>sncPyPIsncSimple tool to combine(merge) onnx models. Simple Network Combine Tool for ONNX.
2sne4onnx<br>imagePyPIsneA very simple tool for situations where optimization with onnx-simplifier would exceed the Protocol Buffers upper file size limit of 2GB, or simply to separate onnx files to any size you want. Simple Network Extraction for ONNX.
3snd4onnx<br>sndPyPIsndSimple node deletion tool for onnx. Simple Node Deletion for ONNX.
4scs4onnx<br>scsPyPIscsA very simple tool that compresses the overall size of the ONNX model by aggregating duplicate constant values as much as possible. Simple Constant value Shrink for ONNX.
5sog4onnx<br>sogPyPIsogSimple ONNX operation generator. Simple Operation Generator for ONNX.
6sam4onnx<br>samPyPIsamA very simple tool to rewrite parameters such as attributes and constants for OPs in ONNX models. Simple Attribute and Constant Modifier for ONNX.
7soc4onnx<br>socPyPIsamA very simple tool that forces a change in the opset of an ONNX graph. Simple Opset Changer for ONNX.
8scc4onnx<br>sccPyPIsamVery simple NCHW and NHWC conversion tool for ONNX. Change to the specified input order for each and every input OP. Also, change the channel order of RGB and BGR. Simple Channel Converter for ONNX.
9sna4onnx<br>snaPyPIsogSimple node addition tool for onnx. Simple Node Addition for ONNX.
10sbi4onnx<br>sbiPyPIsbi4onnxA very simple script that only initializes the batch size of ONNX. Simple Batchsize Initialization for ONNX.
11sor4onnx<br>sorPyPIsor4onnxSimple OP Renamer for ONNX.
12soa4onnx<br>soaPyPIsoa4onnxSimple model Output OP Additional tools for ONNX.
13sod4onnx<br>sodPyPIsod4onnxSimple model Output OP Deletion tools for ONNX.
14ssi4onnx<br>ssiPyPIssi4onnxSimple Shape Inference tool for ONNX.
15sit4onnx<br>sitPyPIsit4onnxTools for simple inference testing using TensorRT, CUDA and OpenVINO CPU/GPU and CPU providers. Simple Inference Test for ONNX.
16onnx2json<br>onnx2jsonPyPIonnx2jsonExports the ONNX file to a JSON file.
17json2onnx<br>json2onnxPyPIsogConverts a JSON file to an ONNX file.
18sed4onnx<br>sedPyPIsogSimple ONNX constant encoder/decoder. Since the constant values in the JSON files generated by onnx2json are Base64-encoded values, ASCII <-> Base64 conversion is required when rewriting JSON constant values.
19ssc4onnx<br>sscPyPIsogChecker with simple ONNX model structure. Simple Structure Checker for ONNX. Analyzes and displays the structure of huge size models that cannot be displayed by Netron.
20sio4onnx<br>imagePyPIsioSimple tool to change the INPUT and OUTPUT shape of ONNX.
21svs4onnx<br>imagePyPIsioA very simple tool to swap connections between output and input variables in an ONNX graph. Simple Variable Switch for ONNX.
22onnx2tf<br>imagePyPIonnx2tfSelf-Created Tools to convert ONNX files (NCHW) to TensorFlow format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf).
23sng4onnx<br>imagePyPIsng4onnxA simple tool that automatically generates and assigns an OP name to each OP in an old format ONNX file.
24sde4onnx<br>sde4onnx_iconPyPIsde4onnxSimple doc_string eraser for ONNX.
25spo4onnx<br>spo4onnx_iconPyPIspo4onnxSimple tool for partial optimization of ONNX. Further optimize some models that cannot be optimized with onnx-optimizer and onnxsim by several tens of percent. In particular, models containing Einsum and OneHot.
26components_of_onnx<br>components_of_onnx[WIP]PyPIsogONNX parts yard. The various operations described in Operator Schemas are converted in advance into OP stand-alone ONNX files.

2. Very useful tools

No.Tool NameAuthorTagsSummary
1OnnxGraphQt<br>onnx_graph_qtfateshelledOnnxGraphQtONNX model visualizer. Model structure can be edited on the visualization tool.imageimage
2onnx-modifier<br>imageZhangGe6onnx-modifierTo edit an ONNX model, One common way is to visualize the model graph, and edit it using ONNX Python API.image
3onnx-simplifierdaquexianPyPIonnxsimONNX Simplifier is presented to simplify the ONNX model. It infers the whole computation graph and then replaces the redundant operators with their constant outputs.
4Sparsify<br>imageneuralmagicPyPIsparsifyEasy-to-use UI for automatically sparsifying neural networks and creating sparsification recipes for better inference performance and a smaller footprint.image
5DeepSparse Engine<br>imageneuralmagicPyPIdeepsparseSparsity-aware neural network inference engine for GPU-class performance on CPUs.imageimage
6Sparsebitmegvii-researchPyPISparsebitSparsebit is a toolkit with pruning and quantization capabilities. It is designed to help researchers compress and accelerate neural network models by modifying only a few codes in existing pytorch project.
7onnionIdeinPyPIonniononnion project. compile onnx to python. runtime depends only numpy.

2-1. OnnxGraphQt - [WIP] Startup Method Sample

git clone https://github.com/fateshelled/OnnxGraphQt
cd OnnxGraphQt
# build docker image
./docker/build.bash
# run
./docker/run.bash

3. Acknowledgments

  1. https://github.com/onnx/onnx/blob/main/docs/PythonAPIOverview.md
  2. https://docs.nvidia.com/deeplearning/tensorrt/onnx-graphsurgeon/docs/index.html
  3. https://github.com/NVIDIA/TensorRT/tree/main/tools/onnx-graphsurgeon
  4. https://github.com/onnx/onnx/blob/main/docs/Operators.md

4. References

  1. https://github.com/PINTO0309/PINTO_model_zoo

  2. https://github.com/PINTO0309/PINTO_model_zoo/tree/main/115_MoveNet/PINTO_Special/barracuda_gathernd_split

    https://user-images.githubusercontent.com/33194443/192281791-cf469dfd-f29a-4301-bd39-e96dd868dad9.mp4