Fifo.read_elem()

Info Value
Package mvnc
Module mvncapi
Version 2.0
See also Fifo, Fifo.write_elem(), Graph.queue_inference_With_fifo_elem(), Graph.queue_inference()

Overview

This method returns an element from the Fifo, usually the result of an inference, along with the associated user-defined object that was passed to Fifo.write_elem() or Graph.queue_inference_with_fifo_elem().

This will also remove the element from the queue.

Syntax

output_tensor, user_obj = fifo.read_elem()

Parameters

None.

Return

tensor, user_obj

A numpy.ndarray with output tensor data of the type specified by the FifoDataType option, and the user-defined data that was passed to Fifo.write_elem() or Graph.queue_inference_with_fifo_elem().

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)

#
# Write elements to an input Fifo with Fifo.write_elem() and initiate inferences with Graph.queue_inference()
#

# Read the result to the output Fifo
result_tensor, user_obj = output_fifo.read_elem()

#
# Do something with the result...
#

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

#
# Perform other clean up...
#