def modcrop_np(img, sf):
    '''
    Args:
        img: numpy image, WxH or WxHxC
        sf: scale factor
    Return:
        cropped image
    '''
    w, h = img.shape[:2]
    im = np.copy(img)
    return im[:w - w % sf, :h - h % sf, ...]

    Args:
        img: numpy image, WxH or WxHxC
        sf: scale factor
    Return:
        cropped image
    
ControlNet-v1-1-nightly/ldm/modules/image_degradation/bsrgan.py