def read_image(path):
img = imread(path,mode="RGB")
h, w, c = np.shape(img)
scale_size = 256
crop_size = 224
assert c == 3
img = zoom(img, (scale_size/h, scale_size/w,1))
img = img.astype(np.float32)
img -= np.array([104., 117., 124.])
h, w, c = img.shape
ho, wo = ((h - crop_size) / 2, (w - crop_size) / 2)
img = img[ho:ho + crop_size, wo:wo + crop_size, :]
#print(np.shape(img))
img = img[None, ...]
return img
评论列表
文章目录