Skip to content
Snippets Groups Projects
Commit 69fd990e authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

add a function to load png images

parent aeaf5733
Branches
No related tags found
No related merge requests found
......@@ -197,3 +197,25 @@ def image_augmentation_parser(filename,
features['key'] = filename
return features, label
def load_pngs(img_path, img_shape):
"""Read png files using tensorflow API
You must know the shape of the image beforehand to use this function.
Parameters
----------
img_path : str
Path to the image
img_shape : list
A list or tuple that contains image's shape in channels_last format
Returns
-------
object
The loaded png file
"""
img_raw = tf.read_file(img_path)
img_tensor = tf.image.decode_png(img_raw, channels=img_shape[-1])
img_final = tf.reshape(img_tensor, img_shape)
return img_final
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment