Network for downscaling followed by bicubic upscaling, can I use PIL or torch?

Hi all!

I am implementing a network for image downscaling, where a low resolution image (LR) is the output . However, for the loss function, I want to upscale the LR image back to its original resolution, using bicubic interpolation, and compare it with the original input.

#e.g. where input is a 400x400 image, from a mini-batch of 16
LR = model(input) #where LR will be a 200x200 image
HR = upscale(LR, scale_factor=2, mode=bicubic) #HR will be a 400x400 image
loss = criterion(input, HR)

My question is, for the upscale method can I use Pillow’s bicubic interpolation? If not, I am aware of torch’s interpolation, however I am afraid that the method might mess with the gradient propagation (due to the nondeterministic behaviour warning).

Thank you for the attention.