onnx2json
Exports the ONNX file to a JSON file and JSON dict. Click here for json2onnx.
https://github.com/PINTO0309/simple-onnx-processing-tools
1. Setup
1-1. HostPC
### option
$ echo export PATH="~/.local/bin:$PATH" >> ~/.bashrc \
&& source ~/.bashrc
### run
$ pip install -U onnx protobuf \
&& python3 -m pip install -U onnx_graphsurgeon --index-url https://pypi.ngc.nvidia.com \
&& pip install -U onnx2json
1-2. Docker
https://github.com/PINTO0309/simple-onnx-processing-tools#docker
2. CLI Usage
usage:
onnx2json [-h]
-if INPUT_ONNX_FILE_PATH
-oj OUTPUT_JSON_PATH
[-i JSON_INDENT]
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 model path. (*.onnx)
-oj OUTPUT_JSON_PATH, --output_json_path OUTPUT_JSON_PATH
Output JSON file path (*.json) If not specified, no JSON file is output.
-i JSON_INDENT, --json_indent JSON_INDENT
Number of indentations in JSON. (default=2)
3. In-script Usage
>>> from onnx2json import convert
>>> help(convert)
Help on function convert in module onnx2json.onnx2json:
convert(
input_onnx_file_path: Union[str, NoneType] = '',
onnx_graph: Union[onnx.onnx_ml_pb2.ModelProto, NoneType] = None,
output_json_path: Union[str, NoneType] = '',
json_indent: Union[int, NoneType] = 2
)
Parameters
----------
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_json_path: Optional[str]
Output JSON file path (*.json) If not specified, no JSON file is output.
Default: ''
json_indent: Optional[int]
Number of indentations in JSON.
Default: 2
Returns
-------
onnx_json: dict
Converted JSON dict.
4. CLI Execution
$ onnx2json \
--input_onnx_file_path NonMaxSuppression.onnx \
--output_json_path NonMaxSuppression.json \
--json_indent 2
5. In-script Execution
from onnx2json import convert
onnx_json = convert(
input_onnx_file_path="NonMaxSuppression.onnx",
output_json_path="NonMaxSuppression.json",
json_indent=2,
)
# or
onnx_json = convert(
onnx_graph=graph,
)
6. Issues
https://github.com/PINTO0309/simple-onnx-processing-tools/issues
Metadata
Release files for onnx2json 2.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onnx2json-2.0.4.tar.gz | 4.2 kB | Without provenance | Details for onnx2json-2.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| onnx2json-2.0.4-py3-none-any.whl | Python 3 | none | any | Details for onnx2json-2.0.4-py3-none-any.whl |
Total release size: 9.2 kB
Release files / onnx2json-2.0.4.tar.gz
| Download URL | onnx2json-2.0.4.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
840d07b81bbe026644e76fb41edc4e280f5cdf8e24966342705eff479a19f2bd
|
|
BLAKE2b-256 checksum How to use checksums |
29994d8237cf994c1db087ad71819dc6acd421bb91a6b61e65c0fde20f0664aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / onnx2json-2.0.4-py3-none-any.whl
| Download URL | onnx2json-2.0.4-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
281d86a7b4e4b8e33c1972cfbde3a3d77ef7848074907ae5a8c8b901d0b50e82
|
|
BLAKE2b-256 checksum How to use checksums |
4d1e01d79c5317a48a1819ed7d9f4ff5d6fa1e23b97be464ff6862213671a71c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for onnx2json 2.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.