Coder Social home page Coder Social logo

json2onnx's Introduction

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

json2onnx's People

Contributors

pinto0309 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

oosyoo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.