Skip to content

Instantly share code, notes, and snippets.

@kerenskybr
Created September 16, 2020 01:21
Show Gist options
  • Save kerenskybr/2c26ecb549a8e2763241d6c00ae43887 to your computer and use it in GitHub Desktop.
Save kerenskybr/2c26ecb549a8e2763241d6c00ae43887 to your computer and use it in GitHub Desktop.
Function to convert the Grayscale data to RGB to match with an architecture
from keras import backend as K
def grayscale_to_rgb(images, channel_axis=-1):
'''Function to convert the Grayscale data
to RGB to match with an architecture
'''
images= K.expand_dims(images, axis=channel_axis)
tiling = [1] * 4 # 4 dimensions: B, H, W, C
tiling[channel_axis] *= 3
images= K.tile(images, tiling)
return images
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment