pytorch-msssim
pytorch-msssim copied to clipboard
When I wanna deal with grayscale image,it report this problem
When I input 2D grayscale image ,i report this. ValueError: Input images should be 4-d or 5-d tensors, but got torch.Size([256, 256])
Therefore,I change the input dimension to 4D(1,1,256,256),but i got this problem. RuntimeError: Given groups=1, weight of size [3, 1, 1, 11], expected input[1, 3, 246, 256] to have 1 channels, but got 3 channels instead
Hi @WYCAS , it seems that the input tensor was a RGB image. Could you provide more detials, such as a minimal example to produce this error?
Input :a = torch.randint(0, 255, size=( 256, 256), dtype=torch.float32).cuda() / 255. b = a * 0.5 ValueError: Input images should be 4-d or 5-d tensors, but got torch.Size([256, 256])
Input:a = torch.randint(0, 255, size=(1,1,256, 256), dtype=torch.float32).cuda() / 255. b = a * 0.5 RuntimeError: Given groups=1, weight of size [3, 1, 1, 11], expected input[1, 3, 246, 256] to have 1 channels, but got 3 channels instead
Do I have to change the grayscale image to RGB image? By the way ,when I use pytorch-msssim=0.1,it can work on grayscale image
The ssim metric worked well on my laptop. Maybe the parameter channel
was missing in your code?
ssim = SSIM(data_range=1., channel=1)
thanks , It works!