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

Number of channels in the ViTMAE model #17473

Open
kacwin opened this issue May 30, 2022 · 3 comments · May be fixed by #17491
Open

Number of channels in the ViTMAE model #17473

kacwin opened this issue May 30, 2022 · 3 comments · May be fixed by #17491

Comments

@kacwin
Copy link

@kacwin kacwin commented May 30, 2022

Feature request

Dear huggingface community,
I am experimenting with the ViTMAE model from the transformers library. The ViTMAEConfig class has the option "num_channels" to specify the number of input (color) channels belonging to an image. If I modify this, say, to 1 (for processing grayscale images), the model throws an error, due to the number "3" being hard-coded into the functions "patchify" and "unpatchify" in the file "modeling_vit_mae.py".

Motivation

I would like to request to change this such that any number of input channels is possible.

Your contribution

As noted above, one only has to change the functions "patchify" and "depatchify" to either scan for the input color channels, or provide the input color channels as a class variable such that both functions can use it (instead of the hard-coded value "3"). I checked this and on my system it worked out just fine.

@NielsRogge
Copy link
Contributor

@NielsRogge NielsRogge commented May 30, 2022

Hi,

Yes the "patchify" and "unpatchify" methods would need to be updated to supported 1 channel.

Are you interested in opening a PR to add support for this?

@kacwin
Copy link
Author

@kacwin kacwin commented May 30, 2022

Hey,
thanks for the fast reply. I am a complete beginner to github (I only used it to manage my personal projects so far) and I will not be getting into the PR-procedure anytime soon. I did not know how to reach out to someone managing the vitmae project and tried out this issue just to point things out. If noone else is having the same problem or noone has time to care for this then this is just how it is I guess.

@johnnv1
Copy link
Contributor

@johnnv1 johnnv1 commented May 31, 2022

@NielsRogge updating the hard-coded part to the config value will work?

I can open a PR to help on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants