interface pública
InterpreterApi
Subclasses indiretas conhecidas |
Interface para o interpretador de modelos do TensorFlow Lite, exceto métodos experimentais.
Uma instância InterpreterApi
encapsula um modelo pré-treinado do TensorFlow Lite, em que
operações são executadas para inferência de modelos.
Por exemplo, se um modelo usa apenas uma entrada e retorna apenas uma saída:
try (InterpreterApi interpreter =
new InterpreterApi.create(file_of_a_tensorflowlite_model)) {
interpreter.run(input, output);
}
Se um modelo usa várias entradas ou saídas:
Object[] inputs = {input0, input1, ...};
Map<Integer, Object> map_of_indices_to_outputs = new HashMap<>();
FloatBuffer ith_output = FloatBuffer.allocateDirect(3 * 2 * 4); // Float tensor, shape 3x2x4.
ith_output.order(ByteOrder.nativeOrder());
map_of_indices_to_outputs.put(i, ith_output);
try (InterpreterApi interpreter =
new InterpreterApi.create(file_of_a_tensorflowlite_model)) {
interpreter.runForMultipleInputsOutputs(inputs, map_of_indices_to_outputs);
}
Se um modelo usa ou produz tensores de string:
String[] input = {"foo", "bar"}; // Input tensor shape is [2].
String[][] output = new String[3][2];