public class TensorflowModel extends Object implements AutoCloseable
This class wraps the TensorFlow Lite interpreter so that it can be mocked for unit testing on non-android platforms. It also encapsulates the input/output byte buffers used for passing input tensors into a model and retrieving outputs.
Modifier and Type | Class and Description |
---|---|
static class |
TensorflowModel.Loader
loader (builder) class for the tensorflow model.
|
Constructor and Description |
---|
TensorflowModel(TensorflowModel.Loader loader)
constructs a new tensorflow model.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
releases the tensorflow interpreter.
|
int |
getInputSize() |
ByteBuffer |
inputs(int index)
Get the input buffer at the specified index.
|
ByteBuffer |
outputs(int index)
Get the output buffer at the specified index.
|
void |
run()
executes the model using the attached buffers.
|
ByteBuffer |
states() |
public TensorflowModel(TensorflowModel.Loader loader)
loader
- the loader (builder) for the modelpublic int getInputSize()
public void close()
close
in interface AutoCloseable
public ByteBuffer inputs(int index)
index
- The index of the desired input buffer.public ByteBuffer states()
public ByteBuffer outputs(int index)
index
- The index of the desired output buffer.public void run()
Copyright © 2020. All rights reserved.