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

When I wanna deal with grayscale image,it report this problem #32

Open
WYCAS opened this issue Oct 18, 2021 · 4 comments
Open

When I wanna deal with grayscale image,it report this problem #32

WYCAS opened this issue Oct 18, 2021 · 4 comments

Comments

@WYCAS
Copy link

WYCAS commented Oct 18, 2021

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

@VainF
Copy link
Owner

VainF commented Oct 19, 2021

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?

@WYCAS
Copy link
Author

WYCAS commented Oct 20, 2021

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

@VainF
Copy link
Owner

VainF commented Oct 20, 2021

The ssim metric worked well on my laptop. Maybe the parameter channel was missing in your code?

ssim = SSIM(data_range=1., channel=1)

@WYCAS
Copy link
Author

WYCAS commented Oct 21, 2021

thanks , It works!

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

2 participants