def rgb_preprocess(img):
if np.issubdtype(img.dtype, np.float):
# assuming 0., 1. range
return (img*255).clip(0, 255).astype(np.uint8)
if not img.dtype == np.uint8:
raise ValueError('only uint8 or float for 3-channel images')
return img
评论列表
文章目录