Skip to content

Latest commit

 

History

History
50 lines (34 loc) · 1.19 KB

how-to-use-nnfw-python-api.md

File metadata and controls

50 lines (34 loc) · 1.19 KB

How to Use NNFW PYTHON API

CAUTION

This Python API is experimental yet. It can be changed later.

Prepare nnpackage

Use nnpackage examples

Use the nnpackage examples to run tutorial code.

Install nnfw python API

Please see nnfw python api for installing nnfw python api.

  1. Initialize nnfw_session
# Create session and load nnpackage
# operations is optional to assign a specific backends to each operation.
# The default value of backends is "cpu".
if operations:
    session = nnfw_session(nnpackage_path, backends, operations)
else:
    session = nnfw_session(nnpackage_path, backends)
  1. Prepare Input
# Prepare input. Here we just allocate dummy input arrays.
input_size = session.input_size()
session.set_inputs(input_size)
  1. Inference
# Do inference
outputs = session.inference()

Run Inference with app on the target devices

reference app : minimal-python app

$ python3 minimal.py path_to_nnpackage_directory