Stay organized with collections
Save and categorize content based on your preferences.
The ML.CONVERT_IMAGE_TYPE function
This document describes the ML.CONVERT_IMAGE_TYPE scalar function, which lets
you convert the data type of pixel values in an image to INT64 with a range
of [0, 255). You can use ML.CONVERT_IMAGE_TYPE with the
ML.PREDICT function
or chain it with other functions or subqueries.
Syntax
ML.CONVERT_IMAGE_TYPE(image)
Arguments
ML.CONVERT_IMAGE_TYPE takes the following argument:
image: a STRUCT<ARRAY<INT64>, ARRAY<FLOAT64>> value that
represents an image.
The first array in the struct must contain the dimensions of the image.
It must contain three INT64 values, which represent the image height (H),
width (W), and number of channels (C).
The second array in the struct must contain the image data. The
length of the array must be equivalent to H x W x C from the preceding
array. Each value in the array must be between [0, 1).
The struct value must be <= 60 MB.
Output
ML.CONVERT_IMAGE_TYPE returns a STRUCT<ARRAY<INT64>, ARRAY<INT64>> value
that represents the image.
The first array in the struct represents the dimensions of the image, and
the second array in the struct contains the image data, similar
to the image input argument. Each value in the second array is between
[0, 255).
Example
The SSD Mobilenet V2 Object detection model
model requires input to be in tf.uint8. The following example changes the
pixel values for the input images from floating point numbers to integers
so that they work with this model:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["\u003cp\u003e\u003ccode\u003eML.CONVERT_IMAGE_TYPE\u003c/code\u003e is a scalar function that converts the data type of pixel values in an image to \u003ccode\u003eINT64\u003c/code\u003e, within the range of \u003ccode\u003e[0, 255)\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe function takes a \u003ccode\u003eSTRUCT\u003c/code\u003e as input, representing an image with dimensions and pixel data as arrays.\u003c/p\u003e\n"],["\u003cp\u003eThe output of \u003ccode\u003eML.CONVERT_IMAGE_TYPE\u003c/code\u003e is also a \u003ccode\u003eSTRUCT\u003c/code\u003e, mirroring the input format, with pixel values converted to \u003ccode\u003eINT64\u003c/code\u003e and scaled to the \u003ccode\u003e[0, 255)\u003c/code\u003e range.\u003c/p\u003e\n"],["\u003cp\u003eThe function is often used with the \u003ccode\u003eML.PREDICT\u003c/code\u003e function or other functions/subqueries to preprocess image data, and it has a size limit of 60 MB for its input.\u003c/p\u003e\n"],["\u003cp\u003eThe provided example showcases how to use \u003ccode\u003eML.CONVERT_IMAGE_TYPE\u003c/code\u003e to change pixel values to work with a SSD Mobilenet V2 Object detection model.\u003c/p\u003e\n"]]],[],null,[]]