LabelUtil

public class LabelUtil

Label operation utils.

Public Methods

static List<String>
mapValueToLabels(TensorBuffer tensorBuffer, List<String> labels, int offset)
Maps an int value tensor to a list of string labels.

Inherited Methods

Public Methods

public static List<String> mapValueToLabels (TensorBuffer tensorBuffer, List<String> labels, int offset)

Maps an int value tensor to a list of string labels. It takes an array of strings as the dictionary. Example: if the given tensor is [3, 1, 0], and given labels is ["background", "apple", "banana", "cherry", "date"], the result will be ["date", "banana", "apple"].

Parameters
tensorBuffer A tensor with index values. The values should be non-negative integers, and each value x will be converted to labels[x + offset]. If the tensor is given as a float TensorBuffer, values will be cast to integers. All values that are out of bound will map to empty string.
labels A list of strings, used as a dictionary to look up. The index of the array element will be used as the key. To get better performance, use an object that implements RandomAccess, such as ArrayList.
offset The offset value when look up int values in the labels.
Returns
Throws
IllegalArgumentException if tensorBuffer or labels is null.