def load_image(path):
# load image
img = skimage.io.imread(path)
img = img / 255.0
assert (0 <= img).all() and (img <= 1.0).all()
print( "Original Image Shape: ", img.shape)
# we crop image from center
short_edge = min(img.shape[:2])
yy = int((img.shape[0] - short_edge) / 2)
xx = int((img.shape[1] - short_edge) / 2)
crop_img = img[yy: yy + short_edge, xx: xx + short_edge]
# resize to 224, 224
resized_img = skimage.transform.resize(crop_img, (256, 256))
print( "Resize Image Shape: ", resized_img.shape)
return resized_img
utils.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录