<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/core/tensor_image.py#L22-L139) |

Wrapper class for the Image object.

    tflite_support.task.vision.TensorImage(
        image_data: image_utils.ImageData, is_from_numpy_array: bool = True
    ) -> None

<br />

<br />

<br />

| ## Args ||
|---|---|
| `image_data` | image_utils.ImageData, contains raw image data, width, height and channels info. |
| `is_from_numpy_array` | boolean, whether `image_data` is loaded from numpy array. if False, it means that `image_data` is loaded from stbi_load\*\* function in C++ and need to free the storage of ImageData in the destructor. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `buffer` | Gets the numpy array that represents `self.image_data`. |
| `color_space_type` | Gets the color space type of the image. |
| `height` | Gets the height of the image. |
| `width` | Gets the width of the image. |

<br />

## Methods

### `create_from_array`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/core/tensor_image.py#L59-L79)

    @classmethod
    create_from_array(
        array: np.ndarray
    ) -> 'TensorImage'

Creates `TensorImage` object from the numpy array.

<br />

<br />

<br />

| Args ||
|---|---|
| `array` | numpy array with dtype=uint8. Its shape should be either (h, w, 3) or (1, h, w, 3) for RGB images, either (h, w) or (1, h, w) for GRAYSCALE images and either (h, w, 4) or (1, h, w, 4) for RGBA images. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `TensorImage` object. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| ValueError if the dytype of the numpy array is not `uint8` or the dimention is not the valid dimention. ||

<br />

### `create_from_buffer`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/core/tensor_image.py#L81-L96)

    @classmethod
    create_from_buffer(
        buffer: str
    ) -> 'TensorImage'

Creates `TensorImage` object from the binary buffer.

<br />

<br />

<br />

| Args ||
|---|---|
| `buffer` | Binary memory buffer. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `TensorImage` object. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| RuntimeError if the binary buffer can't be decoded into `TensorImage` object. ||

<br />

### `create_from_file`

[View source](https://github.com/tensorflow/tflite-support/blob/v0.4.4/tensorflow_lite_support/python/task/vision/core/tensor_image.py#L43-L57)

    @classmethod
    create_from_file(
        file_name: str
    ) -> 'TensorImage'

Creates `TensorImage` object from the image file.

<br />

<br />

<br />

| Args ||
|---|---|
| `file_name` | Image file name. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| `TensorImage` object. ||

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| RuntimeError if the image file can't be decoded. ||

<br />