Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ace19-dev committed Aug 8, 2019
1 parent 165e8f3 commit ae5b213
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions retrieval/retrieval_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def decode(self, serialized_example):
# Convert from a scalar string tensor to a float32 tensor with shape
image_decoded = tf.image.decode_png(features['image/encoded'], channels=3)
image = tf.image.convert_image_dtype(image_decoded, dtype=tf.float32)
image = tf.image.resize(image, [self.resize_h, self.resize_w])

# Convert label from a scalar uint8 tensor to an int32 scalar.
label = tf.cast(features['image/class/label'], tf.int64)
Expand All @@ -83,8 +82,12 @@ def eval(self, filename, image, label):
def tencrop(self, filename, image, label):
"""Prepare one image for TenCrop
"""
flip_mode = random.randint(0, 1)
# Resize the image to the height and width.
image = tf.expand_dims(image, 0)
image = tf.image.resize(image, [self.resize_h, self.resize_w])
image = tf.squeeze(image, [0])

flip_mode = random.randint(0, 1)
images = []
for i in range(5):
image = tf.random_crop(image, [RANDOM_CROP_SIZE, RANDOM_CROP_SIZE, 3])
Expand Down
7 changes: 5 additions & 2 deletions val_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def decode(self, serialized_example):
# Convert from a scalar string tensor to a float32 tensor with shape
image_decoded = tf.image.decode_png(features['image/encoded'], channels=3)
image = tf.image.convert_image_dtype(image_decoded, dtype=tf.float32)
image = tf.image.resize(image, [self.resize_h, self.resize_w])

# Convert label from a scalar uint8 tensor to an int32 scalar.
label = tf.cast(features['image/class/label'], tf.int64)
Expand All @@ -83,8 +82,12 @@ def eval(self, filename, image, label):
def tencrop(self, filename, image, label):
"""Prepare one image for TenCrop
"""
flip_mode = random.randint(0, 1)
# Resize the image to the height and width.
image = tf.expand_dims(image, 0)
image = tf.image.resize(image, [self.resize_h, self.resize_w])
image = tf.squeeze(image, [0])

flip_mode = random.randint(0, 1)
images = []
for i in range(5):
image = tf.random_crop(image, [RANDOM_CROP_SIZE, RANDOM_CROP_SIZE, 3])
Expand Down

0 comments on commit ae5b213

Please sign in to comment.