def resize(image, desired_size):
old_size = image.shape[:2] // old_size is in (height, width) format
ratio = float(desired_size)/max(old_size)
new_size = tuple([int(x*ratio) for x in old_size])
// new_size should be in (width, height) format
image = cv2.resize(image, (new_size[1], new_size[0]))
After Change
old_size = image.shape[:2] // old_size is in (height, width) format
ratio = min(np.divide(desired_size, old_size))
new_size = (int(old_size[0]*ratio), int(old_size[1]*ratio))
// new_size should be in (width, height) format
if image.shape[2] == 1:
image = cv2.resize(