Po-Hsun-Su / pytorch-ssim

pytorch structural similarity (SSIM) loss
Other
1.87k stars 364 forks source link

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

Open sunnyHelen opened 5 years ago

sunnyHelen commented 5 years ago

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 commented 5 years ago

I have the same error. The results are always 1

miikatoi commented 4 years ago

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 commented 3 years ago

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 commented 2 years ago

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!