def load_img(path, grayscale=False, target_size=None):
"""Utility function to load an image from disk.
Args:
path: The image file path.
grayscale: True to convert to grayscale image (Default value = False)
target_size: (w, h) to resize. (Default value = None)
Returns:
The loaded numpy image.
"""
img = io.imread(path, grayscale)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
if target_size:
img = cv2.resize(img, (target_size[1], target_size[0]))
return img
评论列表
文章目录