Reputation: 1
I have png image. I want to upsample it using bicubic interpolation. I found this function in pytorch:
nn.functional.upsample(mode = "bicubic)
https://pytorch.org/docs/stable/generated/torch.nn.Upsample.html
But how to apply to my png image? Should I turn my image into some torch tesnor? I just haven't found any example of using this function exactly on png image
Upvotes: 0
Views: 1110
Reputation: 515
You can do this
import torch
import torchvision.transforms as transforms
from PIL import Image
t = transforms.ToTensor()
img = Image.open("Table.png")
b = torch.nn.functional.upsample(t(img).unsqueeze(0),(500,400),mode = "bicubic")
you can also apply Bicubic using Image
img = Image.open("Table.png")
re = img.resize((400, 400),Image.BICUBIC)
Upvotes: 1