Skip to main content

json2onnx

Converts a JSON file to an ONNX file. Click here for onnx2json.

https://github.com/PINTO0309/simple-onnx-processing-tools

PyPI - Downloads GitHub PyPI

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 json2onnx

1-2. Docker

https://github.com/PINTO0309/simple-onnx-processing-tools#docker

2. CLI Usage

usage:
  json2onnx [-h]
  --ij INPUT_JSON_PATH
  -of OUTPUT_ONNX_FILE_PATH

optional arguments:
  -h, --help
      show this help message and exit

  -ij INPUT_JSON_PATH, --input_json_path INPUT_JSON_PATH
      Input JSON file path (*.json)

  -of OUTPUT_ONNX_FILE_PATH, --output_onnx_file_path OUTPUT_ONNX_FILE_PATH
      Output ONNX model path (*.onnx)

3. In-script Usage

>>> from json2onnx import convert
>>> help(convert)

Help on function convert in module json2onnx.json2onnx:

convert(
  input_json_path: Union[str, NoneType] = '',
  json_dict: Union[dict, NoneType] = None,
  output_onnx_file_path: Union[str, NoneType] = ''
)

    Parameters
    ----------
    input_json_path: Optional[str]
        Input onnx file path.
        Either input_json_path or json_dict must be specified.
        Default: ''

    json_dict: Optional[dict]
        onnx.ModelProto.
        Either input_onnx_file_path or json_dict must be specified.
        json_dict If specified, ignore input_json_path and process json_dict.

    output_onnx_file_path: Optional[str]
        Output onnx file path. If not specified, no ONNX file is output.
        Default: ''

    Returns
    -------
    onnx_graph: onnx.ModelProto
        Converted ONNX.

4. CLI Execution

$ json2onnx \
--input_json_path NonMaxSuppression.json \
--output_onnx_file_path NonMaxSuppression.onnx

5. In-script Execution

from json2onnx import convert

onnx_graph = convert(
  input_json_path="NonMaxSuppression.json",
  output_onnx_file_path="NonMaxSuppression.onnx",
)

# or

onnx_graph = convert(
  input_json_path="NonMaxSuppression.json",
)

# or

onnx_graph = convert(
  json_dict=json_data,
  output_onnx_file_path="NonMaxSuppression.onnx",
)

# or

onnx_graph = convert(
  json_dict=json_data,
)

6. Issues

https://github.com/PINTO0309/simple-onnx-processing-tools/issues

Release files for json2onnx 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for json2onnx 2.0.3
File Size Uploaded
json2onnx-2.0.3.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for json2onnx 2.0.3
File Interpreter ABI Platform
json2onnx-2.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / json2onnx-2.0.3.tar.gz

Download URL json2onnx-2.0.3.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
69a0a25ae80b843dbfabc4d288a1e4265a1e79ee3d61ba65c1c7d455ee110170
BLAKE2b-256 checksum
How to use checksums
9b599584dfd06ac0a1f552e25ab9d2d5354346b7a3da1897c09239d27ba46bda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / json2onnx-2.0.3-py3-none-any.whl

Download URL json2onnx-2.0.3-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f43a8982d3611c6884b6a035e58e31f4f50c60d0b3ea00dc9a510ffa2328982
BLAKE2b-256 checksum
How to use checksums
310a60e7581ffe96b5739858797f0c635b27c289465c3467c7930d2182369dd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

2.0.3 This release

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page