Skip to main content

ONNC-bench is a Python wrapper of ONNC

Project description

ONNC-bench

ONNC-bench is a Python wrapper of ONNC

Installation

Using pip

pip install onnc-bench

Python API Example

Here is an example to show how to use ONNC python API

# Setup your ONNC API key
api_key = "Your API KEY"

# Instantiate a workspace for deploying model for device `M487`
workspace = launch(api_key, 'NUMAKER_IOT_M487')

# Quantize model to improve performance and reduce memory footprint.
# Here we need quantization dataset, using validation dataset
# is surfficent.
workspace.quantize(x_test)

# Compile the model and get the compilation results
report = workspace.compile(model, "input_1", "dense_1")["report"]

# Save the compiled model
workspace.save('./output')

# Release disk space in cloud
workspace.close()

print(report)
"""
{'ram': 2490, 'rom': 101970}

The report shows we need:
    2,490 bytes of SRAM
  101,970 bytes of ROM
to run this model on a CortexM device.
"""

CLI tools

onnc-bench comes with cli tools to help you deploy model faster. Follow below commands to scaffolding a bench.

  1. Create and enter your bench
onnc-create mybench
cd mybench
  1. Setup API key
onnc-login --key "Your-API-Key-Here"
  1. Create an infer myinfer1 base on template vww
./create-project -t vww -o myinfer1
  1. Compile the pretrained model
./build-project -t myinfer1 -d NUMAKER_IOT_M487
  1. Deoply the compiled model
./deploy-project -t myinfer1 -o ./output

More examples can be found in examples, currently we provide below examples:

  1. Keras MNIST: Contains a MNIST example in Keras from training to development.
  2. Simple Example: Compile a serialized model, and download loadable with demo code in c++.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onnc-bench-1.4.0.tar.gz (11.3 MB view hashes)

Uploaded Source

Built Distribution

onnc_bench-1.4.0-py3-none-any.whl (20.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page