(img, min_size, max_size)
return img, scale
Process image.
Process image.
Process image .
def scale_img(img, min_size, max_size):
    """Process image."""
    _, H, W = img.shape
    scale = min_size / min(H, W)
    if scale * max(H, W) > max_size:
        scale = max_size / max(H, W)
    H, W = int(H * scale), int(W * scale)
    img = transforms.resize(img, (H, W))
    return img, scale
def scale_img ( img , min_size , max_size ) : _ , H , W = img . shape scale = min_size / min ( H , W ) if scale * max ( H , W ) > max_size : scale = max_size / max ( H , W ) H , W = int ( H * scale ) , int ( W * scale ) img = transforms . resize ( img , ( H , W ) ) return img , scale