def trim_image(img):
y,x,c = img.shape
if c != 3:
raise Exception('Expected 3 channels in the image')
resized_img = cv2.resize( img, (TARGET_IMG_SIZE, TARGET_IMG_SIZE))
transposed_img = np.transpose(resized_img,(2,0,1)).astype(np.float32)
ivec = transposed_img - resnet_mean
return ivec
评论列表
文章目录