Graph.queue_inference()
Info | Value |
---|---|
Package | mvnc |
Module | mvncapi |
Version | 2.0 |
See also | Graph, Fifo, Graph.queue_inference_with_fifo_elem() |
Overview
This method queues an inference with specified input and output Fifos.
Syntax
graph.queue_inference(input_fifo, output_fifo)
Parameters
Parameter | Type | Description |
---|---|---|
input_fifo | Fifo | A FIFO queue for graph inputs. The FifoState must be ALLOCATED. |
output_fifo | Fifo | A FIFO queue for graph outputs. The FifoState must be ALLOCATED. |
Return
None
Raises
Exception with a status code from Status if underlying function calls return a status other than Status.OK.
Notes
- The GraphState must be ALLOCATED.
- The input_fifo FifoType must allow write access for the API and the output_fifo must allow read access for the API.
- This is a blocking call if FifoOption.RW_DONT_BLOCK is false. If the input Fifo is empty this function will not return until there is an element to queue for inference.
- The Fifo’s capacity is set when the Fifo is allocated with Graph.allocate_with_fifos() or Fifo.allocate().
- You can check the capacity and the current fill level of the Fifo with Fifo.get_option() for FifoOption.RO_CAPACITY and FifoOption.RO_WRITE_FILL_LEVEL.
Example
from mvnc import mvncapi
#
# Create and open a Device...
#
# Create a Graph
graph = mvncapi.Graph('graph1')
# Read a compiled network graph from file (set the graph_filepath correctly for your graph file)
graph_filepath = './graph'
with open(graph_filepath, 'rb') as f:
graph_buffer = f.read()
# Allocate the graph on the device and create input and output Fifos
input_fifo, output_fifo = graph.allocate_with_fifos(device, graph_buffer)
#
# Pre-procces your input tensor and write to the input Fifo...
#
# Queue an inference
graph.queue_inference(input_fifo, output_fifo)
#
# Read the output from the output_fifo and use it as needed...
#
# Deallocate and destroy the fifo and graph handles, close the device, and destroy the device handle
input_fifo.destroy()
output_fifo.destroy()
graph.destroy()
device.close()
device.destroy()