Skip to content

Instantly share code, notes, and snippets.

@MohanaRC
Created June 5, 2023 13:57
Show Gist options
  • Save MohanaRC/e7fe07706710a249c447aded100c04cf to your computer and use it in GitHub Desktop.
Save MohanaRC/e7fe07706710a249c447aded100c04cf to your computer and use it in GitHub Desktop.
def format_image(data):
"""
Function to reshape, format and normalize input images to make it compatible with the deep learning model
Inputs:
data: Input image
Outputs:
image: Formatted image
data["label"]: Training label associated with the image
"""
image = data["image"]
image = tf.reshape(image, [-1])
image = tf.cast(image, 'float32')
image = image / 255.0
return image, data["label"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment