def resize_to_square(im):
    old_size = im.shape[:2]
    ratio = (float(img_size) / max(old_size))
    new_size = tuple([int((x * ratio)) for x in old_size])
    im = cv2.resize(im, (new_size[1], new_size[0]))
    delta_w = (img_size - new_size[1])
    delta_h = (img_size - new_size[0])
    (top, bottom) = ((delta_h // 2), (delta_h - (delta_h // 2)))
    (left, right) = ((delta_w // 2), (delta_w - (delta_w // 2)))
    color = [0, 0, 0]
    new_im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
    return new_im
def resize_to_square(im):
    old_size = im.shape[:2]
    ratio = (float(img_size) / max(old_size))
    new_size = tuple([int((x * ratio)) for x in old_size])
    im = cv2.resize(im, (new_size[1], new_size[0]))
    delta_w = (img_size - new_size[1])
    delta_h = (img_size - new_size[0])
    (top, bottom) = ((delta_h // 2), (delta_h - (delta_h // 2)))
    (left, right) = ((delta_w // 2), (delta_w - (delta_w // 2)))
    color = [0, 0, 0]
    new_im = cv2.copyMakeBorder(im, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color)
    return new_im