public class **Model** The wrapper class for a TFLite model and a TFLite interpreter.

Note: A `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model` can only holds 1 TFLite model at a time, and always holds a TFLite
interpreter instance to run it.

<br />

### Nested Classes

|---|---|---|---|
| class | [Model.Builder](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Builder) || *This class is deprecated. Please use `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#createModel(Context,%20java.lang.String,%20org.tensorflow.lite.support.model.Model.Options)`.* |
| enum | [Model.Device](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Device) || The runtime device type used for executing classification. |
| class | [Model.Options](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Options) || Options for running the model. |

### Public Methods

|---|---|
| void | [close](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#close())() |
| static [Model](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model) | [createModel](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#createModel(Context,%20java.lang.String,%20org.tensorflow.lite.support.model.Model.Options))(Context context, [String](https://developer.android.com/reference/java/lang/String.html) modelPath, [Model.Options](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Options) options) Loads a model from assets and initialize TFLite interpreter with given options. |
| static [Model](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model) | [createModel](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#createModel(Context,%20java.lang.String))(Context context, [String](https://developer.android.com/reference/java/lang/String.html) modelPath) Loads a model from assets and initialize TFLite interpreter. |
| [MappedByteBuffer](https://developer.android.com/reference/java/nio/MappedByteBuffer.html) | [getData](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#getData())() Returns the memory-mapped model data. |
| [Tensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/Tensor) | [getInputTensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#getInputTensor(int))(int inputIndex) Gets the Tensor associated with the provided input index. |
| [Tensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/Tensor) | [getOutputTensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#getOutputTensor(int))(int outputIndex) Gets the Tensor associated with the provided output index. |
| int\[\] | [getOutputTensorShape](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#getOutputTensorShape(int))(int outputIndex) Returns the output shape. |
| [String](https://developer.android.com/reference/java/lang/String.html) | [getPath](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#getPath())() Returns the path of the model file stored in Assets. |
| void | [run](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model#run(java.lang.Object[],%20java.util.Map<java.lang.Integer,%20java.lang.Object>))([Object\[\]](https://developer.android.com/reference/java/lang/Object.html) inputs, [Map](https://developer.android.com/reference/java/util/Map.html)\<[Integer](https://developer.android.com/reference/java/lang/Integer.html), [Object](https://developer.android.com/reference/java/lang/Object.html)\> outputs) Runs model inference on multiple inputs, and returns multiple outputs. |

### Inherited Methods

From class java.lang.Object

|---|---|
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public void
**close**
()

<br />

#### public static [Model](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model)
**createModel**
(Context context, [String](https://developer.android.com/reference/java/lang/String.html) modelPath, [Model.Options](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Options) options)

Loads a model from assets and initialize TFLite interpreter with given options.

##### Parameters

| context | The App Context. |
| modelPath | The path of the model file. |
| options | The options for running the model. |
|---|---|

##### Throws

| [IOException](https://developer.android.com/reference/java/io/IOException.html) | if any exception occurs when open the model file. |
|---|---|

##### See Also

- `https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model.Options`

#### public static [Model](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/support/model/Model)
**createModel**
(Context context, [String](https://developer.android.com/reference/java/lang/String.html) modelPath)

Loads a model from assets and initialize TFLite interpreter.

The default options are: (1) CPU device; (2) one thread.

<br />

##### Parameters

| context | The App Context. |
| modelPath | The path of the model file. |
|---|---|

##### Throws

| [IOException](https://developer.android.com/reference/java/io/IOException.html) | if any exception occurs when open the model file. |
|---|---|

#### public [MappedByteBuffer](https://developer.android.com/reference/java/nio/MappedByteBuffer.html)
**getData**
()

Returns the memory-mapped model data.

#### public [Tensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/Tensor)
**getInputTensor**
(int inputIndex)

Gets the Tensor associated with the provided input index.

##### Parameters

| inputIndex |   |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if the interpreter is closed. |
|---|---|

#### public [Tensor](https://developers.google.com/edge/api/tflite/java/org/tensorflow/lite/Tensor)
**getOutputTensor**
(int outputIndex)

Gets the Tensor associated with the provided output index.

##### Parameters

| outputIndex |   |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if the interpreter is closed. |
|---|---|

#### public int\[\]
**getOutputTensorShape**
(int outputIndex)

Returns the output shape. Useful if output shape is only determined when graph is created.

##### Parameters

| outputIndex |   |
|---|---|

##### Throws

| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException.html) | if the interpreter is closed. |
|---|---|

#### public [String](https://developer.android.com/reference/java/lang/String.html)
**getPath**
()

Returns the path of the model file stored in Assets.

#### public void
**run**
([Object\[\]](https://developer.android.com/reference/java/lang/Object.html) inputs, [Map](https://developer.android.com/reference/java/util/Map.html)\<[Integer](https://developer.android.com/reference/java/lang/Integer.html), [Object](https://developer.android.com/reference/java/lang/Object.html)\> outputs)

Runs model inference on multiple inputs, and returns multiple outputs.

##### Parameters

| inputs | an array of input data. The inputs should be in the same order as inputs of the model. Each input can be an array or multidimensional array, or a `https://developer.android.com/reference/java/nio/ByteBuffer.html` of primitive types including int, float, long, and byte. `https://developer.android.com/reference/java/nio/ByteBuffer.html` is the preferred way to pass large input data, whereas string types require using the (multi-dimensional) array input path. When `https://developer.android.com/reference/java/nio/ByteBuffer.html` is used, its content should remain unchanged until model inference is done. |
| outputs | a map mapping output indices to multidimensional arrays of output data or `https://developer.android.com/reference/java/nio/ByteBuffer.html`s of primitive types including int, float, long, and byte. It only needs to keep entries for the outputs to be used. |
|---|---|