Google I/O is a wrap! Catch up on TensorFlow sessions View sessions

tflite_support.task.vision.TensorImage

Wrapper class for the Image object.

image_data image_utils.ImageData, contains raw image data, width, height and channels info.
is_from_file boolean, whether image_data is loaded from the image file, if True, need to free the storage of ImageData in the destructor.

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.

Methods

create_from_array

View source

Creates TensorImage object from the numpy array.

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.

Returns
TensorImage object.

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

create_from_file

View source

Creates TensorImage object from the image file.

Args
file_name Image file name.

Returns
TensorImage object.

Raises
status.StatusNotOk if the image file can't be decoded. Need to import the module to catch this error: from pybind11_abseil import status, see https://github.com/pybind/pybind11_abseil#abslstatusor