Created
March 7, 2020 18:09
-
-
Save novasush/cc3d4f33838ba71bed9e4ca8df88228a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def read_tfrecord(serialized_example): | |
# Create the feature description dictionary | |
feature_description = { | |
'image': tf.io.FixedLenFeature((), tf.string, ""), | |
'label': tf.io.FixedLenFeature((), tf.int64, -1), | |
} | |
# Parse the serialized_example and decode the image | |
example = tf.io.parse_single_example(serialized_example, feature_description) | |
image = tf.io.decode_jpeg(example['image'], channels=3) | |
image = tf.cast(image, tf.float32) | |
# Normalize the pixels in the image | |
image = image/255. | |
# Resize the image to (224, 224) using tf.image.resize | |
image = tf.image.resize(image, [224, 224]) | |
return image, example['label'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment