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')
| 138 | |
| 139 | |
| 140 | def 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 | |
| 161 | def preprocess_for_eval(image_bytes, use_bfloat16, image_size=IMAGE_SIZE, interpolation='bicubic'): |
no test coverage detected