(img, size)
return y_slice, x_slice
Get slices needed for padding.

    Args:
        img (~numpy.ndarray): This image is in format CHW.
        size (tuple of two ints): (max_H, max_W).
Get slices needed for padding.
Get slices needed for padding .
def _get_pad_slice(img, size):
    """Get slices needed for padding.

    Args:
        img (~numpy.ndarray): This image is in format CHW.
        size (tuple of two ints): (max_H, max_W).
    """
    _, H, W = img.shape

    if H < size[0]:
        margin_y = (size[0] - H) // 2
    else:
        margin_y = 0
    y_slice = slice(margin_y, margin_y + H)

    if W < size[1]:
        margin_x = (size[1] - W) // 2
    else:
        margin_x = 0
    x_slice = slice(margin_x, margin_x + W)

    return y_slice, x_slice
def _get_pad_slice ( img , size ) : _ , H , W = img . shape if H < size [ 0 ] : margin_y = ( size [ 0 ] - H ) // 2 else : margin_y = 0 y_slice = slice ( margin_y , margin_y + H ) if W < size [ 1 ] : margin_x = ( size [ 1 ] - W ) // 2 else : margin_x = 0 x_slice = slice ( margin_x , margin_x + W ) return y_slice , x_slice