|See also||GraphOption, Device, Fifo, Graph.allocate(), Graph.allocate_with_fifos()|
The Graph class represents a neural network graph and provides methods to perform inferences.
Create a Graph instance:
graph = mvncapi.Graph(name)
|name||str||A name for the graph; this can be anything you like up to mvncapi.MAX_NAME_SIZE characters, or just an empty string.
The name can be retrieved later with Graph.get_option().
When the Graph has been successfully created, the GraphState will be CREATED.
|allocate||Allocate a Graph to a device.|
|allocate_with_fifos||Allocate a graph to a device and create and allocate associated Fifos.|
|destroy||Deallocate a graph that was allocated with Graph.allocate().|
|get_option||Get the value of a graph option.
|queue_inference||Queue an inference to be processed by the graph.|
|queue_inference_with_fifo_elem||Write input tensor data to an input Fifo buffer and then trigger graph execution.|
|set_option||Set the value of a graph option.
- Create a Graph instance.
- Create input and output Fifo queues and allocate the graph for a neural compute device with Graph.allocate_with_fifos().
- Write an image to the input Fifo and queue an inference with Graph.queue_inference_with_fifo_elem().
- When finished, destroy the Graph and free associated resources with Graph.destroy().
See the Python API Overview for more information about typical API usage.
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... # # Write the tensor to the input Fifo and queue an inference graph.queue_inference_with_fifo_elem(input_fifo, output_fifo, input_tensor, None, 'object1') # # Read the output from the output_fifo and use it as needed... # # Clean up input_fifo.destroy() output_fifo.destroy() graph.destroy() device.close() device.destroy()