Skip to content

Commit

Permalink
resize_with_crop_or_pad gives better overall results
Browse files Browse the repository at this point in the history
  • Loading branch information
alexshepard committed Mar 19, 2024
1 parent 5af2e58 commit b5ab344
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/inat_inferrer.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,9 @@ def prepare_image_for_inference(file_path):
image = tf.io.read_file(file_path)
image = tf.image.decode_jpeg(image, channels=3)
image = tf.image.convert_image_dtype(image, tf.float32)
image = tf.image.central_crop(image, 0.875)
image = tf.image.resize(image, [299, 299], tf.image.ResizeMethod.NEAREST_NEIGHBOR)
image = tf.image.resize_with_crop_or_pad(
image, 299, 299
)
return tf.expand_dims(image, 0)

@staticmethod
Expand Down
5 changes: 3 additions & 2 deletions lib/vision_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ def prepare_image_for_inference(self, cache_path):
image = tf.io.read_file(cache_path)
image = tf.image.decode_jpeg(image, channels=3)
image = tf.image.convert_image_dtype(image, tf.float32)
image = tf.image.central_crop(image, 0.875)
image = tf.image.resize(image, [299, 299], tf.image.ResizeMethod.NEAREST_NEIGHBOR)
image = tf.image.resize_with_crop_or_pad(
image, 299, 299
)
return tf.expand_dims(image, 0)

def assess_top_results(self, observation, top_results):
Expand Down

0 comments on commit b5ab344

Please sign in to comment.