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

RuntimeError: Given groups=1, weight of size [16, 3, 3, 3], expected input[1, 4, 345, 514] to have 3 channels, but got 4 channels instead #16

Closed
suitmyself opened this issue Dec 13, 2021 · 2 comments

Comments

@suitmyself
Copy link

RuntimeError: Given groups=1, weight of size [16, 3, 3, 3], expected input[1, 4, 345, 514] to have 3 channels, but got 4 channels instead

@sjmoran
Copy link
Owner

sjmoran commented Dec 13, 2021

Check your input image. It appears to have 4 channels rather than 3. The 4th is possibly an alpha channel. If that is the case just select the first 3 channels which should be the RGB channels.

@sjmoran sjmoran closed this as completed Dec 13, 2021
@suitmyself
Copy link
Author

I just run the inference with the image provided by this repo.
It seems that pillow.Image.open read image with 'RGBA' 4 channels, not 'RGB' 3 channels.
So I add 'convert('RGB')' as follows:
img = ImageProcessing.normalise_image(np.array(Image.open(img_filepath).convert('RGB')), normaliser)

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