MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / preprocess_for_train

Function preprocess_for_train

timm/data/tf_preprocessing.py:140–158  ·  view source on GitHub ↗

Preprocesses the given image for evaluation. Args: image_bytes: `Tensor` representing an image binary of arbitrary size. use_bfloat16: `bool` for whether to use bfloat16. image_size: image size. interpolation: image interpolation method Returns: A preprocessed

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

Source from the content-addressed store, hash-verified

138
139
140def preprocess_for_train(image_bytes, use_bfloat16, image_size=IMAGE_SIZE, interpolation='bicubic'):
141 """Preprocesses the given image for evaluation.
142
143 Args:
144 image_bytes: `Tensor` representing an image binary of arbitrary size.
145 use_bfloat16: `bool` for whether to use bfloat16.
146 image_size: image size.
147 interpolation: image interpolation method
148
149 Returns:
150 A preprocessed image `Tensor`.
151 """
152 resize_method = tf.image.ResizeMethod.BICUBIC if interpolation == 'bicubic' else tf.image.ResizeMethod.BILINEAR
153 image = _decode_and_random_crop(image_bytes, image_size, resize_method)
154 image = _flip(image)
155 image = tf.reshape(image, [image_size, image_size, 3])
156 image = tf.image.convert_image_dtype(
157 image, dtype=tf.bfloat16 if use_bfloat16 else tf.float32)
158 return image
159
160
161def preprocess_for_eval(image_bytes, use_bfloat16, image_size=IMAGE_SIZE, interpolation='bicubic'):

Callers 1

preprocess_imageFunction · 0.85

Calls 2

_decode_and_random_cropFunction · 0.85
_flipFunction · 0.85

Tested by

no test coverage detected