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')
| 159 | |
| 160 | |
| 161 | def preprocess_for_eval(image_bytes, use_bfloat16, image_size=IMAGE_SIZE, interpolation='bicubic'): |
| 162 | """Preprocesses the given image for evaluation. |
| 163 | |
| 164 | Args: |
| 165 | image_bytes: `Tensor` representing an image binary of arbitrary size. |
| 166 | use_bfloat16: `bool` for whether to use bfloat16. |
| 167 | image_size: image size. |
| 168 | interpolation: image interpolation method |
| 169 | |
| 170 | Returns: |
| 171 | A preprocessed image `Tensor`. |
| 172 | """ |
| 173 | resize_method = tf.image.ResizeMethod.BICUBIC if interpolation == 'bicubic' else tf.image.ResizeMethod.BILINEAR |
| 174 | image = _decode_and_center_crop(image_bytes, image_size, resize_method) |
| 175 | image = tf.reshape(image, [image_size, image_size, 3]) |
| 176 | image = tf.image.convert_image_dtype( |
| 177 | image, dtype=tf.bfloat16 if use_bfloat16 else tf.float32) |
| 178 | return image |
| 179 | |
| 180 | |
| 181 | def preprocess_image(image_bytes, |
no test coverage detected