Introducing LiteRT : Google's high-performance runtime for on-device AI, formerly known as TensorFlow Lite.
Learn more
Send feedback
tflite_support.task.vision.TensorImage
Stay organized with collections
Save and categorize content based on your preferences.
Wrapper class for the Image object.
tflite_support . task . vision . TensorImage (
image_data : image_utils . ImageData , is_from_numpy_array : bool = True
) -> None
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.
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.
Methods
create_from_array
View source
@classmethod
create_from_array (
array : np . ndarray
) -> 'TensorImage'
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_buffer
View source
@classmethod
create_from_buffer (
buffer : str
) -> 'TensorImage'
Creates TensorImage
object from the binary buffer.
Args
buffer
Binary memory buffer.
Returns
TensorImage
object.
Raises
RuntimeError if the binary buffer can't be decoded into TensorImage
object.
create_from_file
View source
@classmethod
create_from_file (
file_name : str
) -> 'TensorImage'
Creates TensorImage
object from the image file.
Args
file_name
Image file name.
Returns
TensorImage
object.
Raises
RuntimeError if the image file can't be decoded.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-05-08 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-05-08 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-05-08 UTC."],[],[]]