https://github.com/pinto0309/ssi4onnx
Simple Shape Inference tool for ONNX.
https://github.com/pinto0309/ssi4onnx
cli model-converter onnx python
Last synced: 7 months ago
JSON representation
Simple Shape Inference tool for ONNX.
- Host: GitHub
- URL: https://github.com/pinto0309/ssi4onnx
- Owner: PINTO0309
- License: mit
- Created: 2022-05-23T11:52:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-28T23:50:37.000Z (over 1 year ago)
- Last Synced: 2024-05-29T12:33:34.261Z (over 1 year ago)
- Topics: cli, model-converter, onnx, python
- Language: Python
- Homepage:
- Size: 3.31 MB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ssi4onnx
**S**imple **S**hape **I**nference tool for **ONNX**.https://github.com/PINTO0309/simple-onnx-processing-tools
[](https://pepy.tech/project/ssi4onnx)  [](https://pypi.org/project/ssi4onnx/) [](https://github.com/PINTO0309/ssi4onnx/actions?query=workflow%3ACodeQL)
![]()
## 1. Setup
### 1-1. HostPC
```bash
### option
$ echo export PATH="~/.local/bin:$PATH" >> ~/.bashrc \
&& source ~/.bashrc### run
$ pip install -U onnx \
&& python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com \
&& pip install -U ssi4onnx
```
### 1-2. Docker
https://github.com/PINTO0309/simple-onnx-processing-tools#docker## 2. CLI Usage
```
$ ssi4onnx -husage:
ssi4onnx [-h]
-if INPUT_ONNX_FILE_PATH
[-of OUTPUT_ONNX_FILE_PATH]
[-n]optional arguments:
-h, --help
show this help message and exit.-if INPUT_ONNX_FILE_PATH, --input_onnx_file_path INPUT_ONNX_FILE_PATH
Input onnx file path.-of OUTPUT_ONNX_FILE_PATH, --output_onnx_file_path OUTPUT_ONNX_FILE_PATH
Output onnx file path.-n, --non_verbose
Do not show all information logs. Only error logs are displayed.
```## 3. In-script Usage
```python
>>> from ssi4onnx import shape_inference
>>> help(shape_inference)Help on function shape_inference in module ssi4onnx.onnx_shape_inference:
shape_inference(
input_onnx_file_path: Union[str, NoneType] = '',
onnx_graph: Union[onnx.onnx_ml_pb2.ModelProto, NoneType] = None,
output_onnx_file_path: Union[str, NoneType] = '',
non_verbose: Union[bool, NoneType] = False
) -> onnx.onnx_ml_pb2.ModelProtoParameters
----------
input_onnx_file_path: Optional[str]
Input onnx file path.
Either input_onnx_file_path or onnx_graph must be specified.
Default: ''onnx_graph: Optional[onnx.ModelProto]
onnx.ModelProto.
Either input_onnx_file_path or onnx_graph must be specified.
onnx_graph If specified, ignore input_onnx_file_path and process onnx_graph.output_onnx_file_path: Optional[str]
Output onnx file path. If not specified, no ONNX file is output.
Default: ''non_verbose: Optional[bool]
Do not show all information logs. Only error logs are displayed.
Default: FalseReturns
-------
estimated_graph: onnx.ModelProto
Shape estimated onnx ModelProto.
```## 4. CLI Execution
```bash
$ ssi4onnx --input_onnx_file_path nanodet_320x320.onnx
```## 5. In-script Execution
```python
from ssi4onnx import shape_inferenceestimated_graph = shape_inference(
input_onnx_file_path="crestereo_init_iter2_120x160.onnx",
)
```## 6. Sample
### Before
### After
## 7. Reference
1. https://github.com/onnx/onnx/blob/main/docs/Operators.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/PINTO0309/simple-onnx-processing-tools
5. https://github.com/PINTO0309/PINTO_model_zoo## 8. Issues
https://github.com/PINTO0309/simple-onnx-processing-tools/issues