zrl4836 / simple-onnx-processing-tools

任意修改编辑onnx文件,个人推荐onnx2json和json2onnx 使用最方便,快捷。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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

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 \
pinto0309/simple-onnx-processing-tools:1.0.31
No. Tool Name Tags Summary
1 snc4onnx
snc
PyPIsnc Simple tool to combine(merge) onnx models. Simple Network Combine Tool for ONNX.
2 sne4onnx
image
PyPIsne A 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.
3 snd4onnx
snd
PyPIsnd Simple node deletion tool for onnx. Simple Node Deletion for ONNX.
4 scs4onnx
scs
PyPIscs A 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.
5 sog4onnx
sog
PyPIsog Simple ONNX operation generator. Simple Operation Generator for ONNX.
6 sam4onnx
sam
PyPIsam A very simple tool to rewrite parameters such as attributes and constants for OPs in ONNX models. Simple Attribute and Constant Modifier for ONNX.
7 soc4onnx
soc
PyPIsam A very simple tool that forces a change in the opset of an ONNX graph. Simple Opset Changer for ONNX.
8 scc4onnx
scc
PyPIsam Very 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.
9 sna4onnx
sna
PyPIsog Simple node addition tool for onnx. Simple Node Addition for ONNX.
10 sbi4onnx
sbi
PyPIsbi4onnx A very simple script that only initializes the batch size of ONNX. Simple Batchsize Initialization for ONNX.
11 sor4onnx
sor
PyPIsor4onnx Simple OP Renamer for ONNX.
12 soa4onnx
soa
PyPIsoa4onnx Simple model Output OP Additional tools for ONNX.
13 ssi4onnx
ssi
PyPIssi4onnx Simple Shape Inference tool for ONNX.
14 sit4onnx
sit
PyPIsit4onnx Tools for simple inference testing using TensorRT, CUDA and OpenVINO CPU/GPU and CPU providers. Simple Inference Test for ONNX.
15 onnx2json
onnx2json
PyPIonnx2json Exports the ONNX file to a JSON file.
16 json2onnx
json2onnx
PyPIsog Converts a JSON file to an ONNX file.
17 sed4onnx
sed
PyPIsog Simple 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.
18 ssc4onnx
ssc
PyPIsog Checker 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.
19 components_of_onnx
components_of_onnx
[WIP]PyPIsog ONNX 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 Name Author Tags Summary
1 OnnxGraphQt
onnx_graph_qt
fateshelled [WIP] ONNX model visualizer. Model structure can be edited on the visualization tool.imageimage
2 onnx-simplifier daquexian PyPIonnxsim ONNX Simplifier is presented to simplify the ONNX model. It infers the whole computation graph and then replaces the redundant operators with their constant outputs.

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

$ xhost +local: && \
docker run -it --rm \
-v `pwd`:/home/user/workdir \
-v /tmp/.X11-unix/:/tmp/.X11-unix:rw \
--net=host \
-e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
-e DISPLAY=$DISPLAY \
--privileged \
ghcr.io/pinto0309/openvino2tensorflow:latest

$ git clone https://github.com/fateshelled/OnnxGraphQt \
&& cd OnnxGraphQt \
&& sudo python3 -m pip install -r requirements.txt -U \
&& cd ..

$ python3 OnnxGraphQt/onnxgraphqt/main.py

2-2. win10 安装建议

  1. pip install -U pydot PyQt5 --user

  2. 设置系统环境变量

    image

  3. NodeGraphQt 包安装 和 OnnxGraphQt(GitHub超时)

$ git clone https://github.com/jchanvfx/NodeGraphQt.git
$ cd NodeGraphQt
$ python setup.py install 
$ git clone https://github.com/fateshelled/OnnxGraphQt \
$ cd OnnxGraphQt \
$ ## 先屏蔽 requirements.txt 中 git+https://github.com/jchanvfx/NodeGraphQt.git@v0.2.2#egg=NodeGraphQt
$ sudo python3 -m pip install -r requirements.txt -U \
$ cd ..
$ python3 OnnxGraphQt/onnxgraphqt/main.py

3. Acknowledgments

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

4. References

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

About

任意修改编辑onnx文件,个人推荐onnx2json和json2onnx 使用最方便,快捷。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.

License:MIT License


Languages

Language:Python 65.5%Language:Dockerfile 34.5%