def preprocess(cfg, ori_img, pad_value: float = 0.0, dtype="float16"):
    """
    Image preprocess: resize the image (see `apply_transform`), normalize the pixels,
    and add padding.
    """
    # HH, WW = self.im_shape
    ori_shape = ori_img.shape
    if ori_shape[0] > ori_shape[1]:
        img = np.rot90(ori_img, k=1)
    else:
        img = ori_img
    inputs = apply_transform(cfg, img)
    resize_scale = img.shape[0] / inputs.shape[0]
    pixel_mean = np.array(cfg.MODEL.PIXEL_MEAN).reshape(1, 1, -1)
    pixel_std = np.array(cfg.MODEL.PIXEL_STD).reshape(1, 1, -1)
    inputs = (inputs - pixel_mean) / pixel_std
    padding_size = (
        (0, cfg.INPUT.MIN_SIZE_TEST - inputs.shape[0]),
        (0, cfg.INPUT.MAX_SIZE_TEST - inputs.shape[1]),
        (0, 0),
    )
    inputs = np.pad(inputs, padding_size, constant_values=pad_value)
    inputs = inputs[np.newaxis, :]
    return inputs.astype(dtype), ori_img, ori_shape, resize_scale

    Image preprocess: resize the image (see `apply_transform`), normalize the pixels,
    and add padding.
    
examples/02_detectron2/test_correctness.py