(img, cfg)
return img, ratio
formats the image size based on config
formats the image size based on config
formats the image size based on config
def format_img_size(img, cfg):
    """ formats the image size based on config """
    img_min_side = float(cfg.im_size)
    (height, width, _) = img.shape

    if width <= height:
        ratio = img_min_side / width
        new_height = int(ratio * height)
        new_width = int(img_min_side)
    else:
        ratio = img_min_side / height
        new_width = int(ratio * width)
        new_height = int(img_min_side)
    img = cv2.resize(img, (new_width, new_height), interpolation=cv2.INTER_CUBIC)
    return img, ratio
def format_img_size ( img , cfg ) : img_min_side = float ( cfg . im_size ) ( height , width , _ ) = img . shape if width <= height : ratio = img_min_side / width new_height = int ( ratio * height ) new_width = int ( img_min_side ) else : ratio = img_min_side / height new_width = int ( ratio * width ) new_height = int ( img_min_side ) img = cv2 . resize ( img , ( new_width , new_height ) , interpolation = cv2 . INTER_CUBIC ) return img , ratio