Fifo.write_elem()

Info Value
Package mvnc
Module mvncapi
Version 2.0
See also Fifo, Fifo.read_elem(), Graph.queue_inference_with_fifo_elem()

Overview

This method writes an element to the Fifo, usually the input tensor for an inference.

After the tensor data is written to the Fifo, an inference can be queued with Graph.queue_inference(). Alternatively, Graph.queue_inference_with_fifo_elem() can be used to write the tensor to the input Fifo and queue the inference in one call.

Syntax

fifo.write_elem(input_tensor, user_obj)

Parameters

Parameter Type Description
input_tensor numpy.ndarray Input tensor data of the type specified by the FifoDataType option. This data is typically a representation of each color channel in each pixel of an image.
user_obj any User-defined data that will be returned along with the inference result. This can be anything that you want associated with the inference result, such as the original inference input or a window handle, or can be None.

Return

None

Raises

Exception with a status code from Status if underlying function calls return a status other than Status.OK.

Notes

Example

from mvnc import mvncapi

#
# Open a Device, create a Graph, and load graph data from file...
#

# Allocate the Graph and create and allocate two associate Fifos for input and output
input_fifo, output_fifo = graph.allocate_with_fifos(device, graph_buffer)

#
# Get an input tensor and do pre-processing
#

# Write the input tensor to the Fifo
input_fifo.write_elem(input_tensor, 'input1')

#
# Queue an inference with Graph.queue_inference(), read the result and do something with it...
#

# Destroy the Fifos
input_fifo.destroy()
output_fifo.destroy()

#
# Perform other clean up...
#