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')
| 179 | |
| 180 | |
| 181 | def 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 | |
| 204 | class TfPreprocessTransform: |
no test coverage detected