I’m doing image prepressing during training as below:
im_transform = transforms.Compose(
  [
      transforms.ToTensor(),
      transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
  ]
)

im = Image.open('/content/image.jpg')

# unify image channel to 3 here

im = im_transform(im)

# add mini-batch dim here

im = F.interpolate(im, size=(im_rh, im_rw), mode='area')

Then I’m passing it to model. I checked how it looks like before passing to the model.
im_np = im.numpy()
im_np = im_np.reshape((im_rh, im_rw, 3))
im_np = (im_np * 255).astype(np.uint8)
check_im = Image.fromarray(im_np)
check_im

The input and processed image is looking like this,
Input Image 1
Processed Image 2
So my question is, how can I get the same result like this without using F.interpolate for inference. I’m reading image using opencv. And also normalize it to bound values between -1 to 1.