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

always get ssim loss = tensor(1., device='cuda:0') #20

Open
sunnyHelen opened this issue Apr 12, 2019 · 4 comments
Open

always get ssim loss = tensor(1., device='cuda:0') #20

sunnyHelen opened this issue Apr 12, 2019 · 4 comments

Comments

@sunnyHelen
Copy link

I use SSIM as a loss, but it seems always = 1. I try to print ssim_map. It's all one. I make sure my two img is not the same. Their L1 distance isn't zero. I don't know where the error is. Could you please help me?
image

@YvetteLaw
Copy link

I have the same error. The results are always 1

@miikatoi
Copy link

Hi,

I had the same problem, but managed to fix it by forcing data type as float. The problem occurred when the input was Byte.

So in my case the fix was simply: tensor = torch.from_numpy(np.array(img, dtype="float32"))
instead of: tensor = torch.from_numpy(np.array(img))

@tlwzzy
Copy link

tlwzzy commented Oct 13, 2020

Hi,

I had the same problem, but managed to fix it by forcing data type as float. The problem occurred when the input was Byte.

So in my case the fix was simply: tensor = torch.from_numpy(np.array(img, dtype="float32"))
instead of: tensor = torch.from_numpy(np.array(img))

perfectly solved my problem. THANKS a lot !

@Nonmy
Copy link

Nonmy commented May 11, 2022

Hi,

I had the same problem, but managed to fix it by forcing data type as float. The problem occurred when the input was Byte.

So in my case the fix was simply: tensor = torch.from_numpy(np.array(img, dtype="float32")) instead of: tensor = torch.from_numpy(np.array(img))

Thanks!

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

5 participants