MCPcopy Create free account
hub / github.com/amazon-science/mm-cot / preprocess_image

Function preprocess_image

timm/data/tf_preprocessing.py:181–201  ·  view source on GitHub ↗

Preprocesses the given image. Args: image_bytes: `Tensor` representing an image binary of arbitrary size. is_training: `bool` for whether the preprocessing is for training. use_bfloat16: `bool` for whether to use bfloat16. image_size: image size. interpolation: ima

(image_bytes,
                     is_training=False,
                     use_bfloat16=False,
                     image_size=IMAGE_SIZE,
                     interpolation='bicubic')

Source from the content-addressed store, hash-verified

179
180
181def preprocess_image(image_bytes,
182 is_training=False,
183 use_bfloat16=False,
184 image_size=IMAGE_SIZE,
185 interpolation='bicubic'):
186 """Preprocesses the given image.
187
188 Args:
189 image_bytes: `Tensor` representing an image binary of arbitrary size.
190 is_training: `bool` for whether the preprocessing is for training.
191 use_bfloat16: `bool` for whether to use bfloat16.
192 image_size: image size.
193 interpolation: image interpolation method
194
195 Returns:
196 A preprocessed image `Tensor` with value range of [0, 255].
197 """
198 if is_training:
199 return preprocess_for_train(image_bytes, use_bfloat16, image_size, interpolation)
200 else:
201 return preprocess_for_eval(image_bytes, use_bfloat16, image_size, interpolation)
202
203
204class TfPreprocessTransform:

Callers 1

_build_tf_graphMethod · 0.85

Calls 2

preprocess_for_trainFunction · 0.85
preprocess_for_evalFunction · 0.85

Tested by

no test coverage detected