def load_image(path):
# load image
nImgs = len(path)
rImg = np.zeros([nImgs,224,224,3])
for i in range(nImgs):
img = cv2.imread(path[i])
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 = cv2.resize(img,(224,224),interpolation = cv2.INTER_CUBIC) #skimage.transform.resize(crop_img, (224, 224))
rImg[i] = resized_img
return rImg
# returns the top1 string
评论列表
文章目录