Closed sddai closed 1 year ago
Works for me.
>>> from compressai.zoo import mbt2018
... from PIL import Image
... from torchvision import transforms
...
... device = "cuda"
... net = mbt2018(quality=2, pretrained=True).eval().to(device)
... img = Image.open("datasets/kodak/test/kodim01.png").convert("RGB")
... x = transforms.ToTensor()(img).unsqueeze(0).to(device)
...
... with torch.no_grad():
... out_net = net(x) # usually the same as net.forward(x)
... x_hat = out_net['x_hat'].clamp_(0, 1)
... psnr = -10 * ((x_hat - x)**2).mean().log10()
>>> x.shape
torch.Size([1, 3, 512, 768])
>>> x.dtype
torch.float32
>>> x.device
device(type='cuda', index=0)
>>> psnr
tensor(27.0906, device='cuda:0')
Hi,
You may be using an image resolution that's not a multiple of 64, which is the case in @YodaEmbedding's example.
Please look at the padding performed in codec.py or in the evaluation tool in utils
@fracape @YodaEmbedding Thank you very much.
i gave the mbt2018 pre-trained model a jpeg file and expected the corresponding output. however, it says that "Sizes of tensors must match except in dimension 1."
how could i fix it?
here's the output error:
`