Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems when comparing PNG to JPG #88

Open
b4zz4 opened this issue Nov 22, 2021 · 2 comments
Open

Problems when comparing PNG to JPG #88

b4zz4 opened this issue Nov 22, 2021 · 2 comments

Comments

@b4zz4
Copy link

b4zz4 commented Nov 22, 2021

import lpips
import sys
loss_fn = lpips.LPIPS(net='alex') # vgg o squeeze
img0 = lpips.im2tensor(lpips.load_image(sys.argv[1]))
img1 = lpips.im2tensor(lpips.load_image(sys.argv[2]))
print ('Distances: %.3f'%(loss_fn.forward(img0,img1)))

RuntimeError: The size of tensor a (127) must match the size of tensor b (255) at non-singleton dimension

@b4zz4 b4zz4 changed the title Comparate PNG with JPG problem Problems when comparing PNG to JPG Nov 22, 2021
@ChameleonScales
Copy link

I can successfully compare a jpg against a png. However, I get this error when comparing 2 images that have different resolutions. I can solve this problem by a combination of resizing the image and the canvas to make them match as optimally as possible.

@richzhang
Copy link
Owner

Yes, the images need to be of the same size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants