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

How to apply this function to 1channel image? #127

Open
schliezer opened this issue Nov 6, 2023 · 6 comments
Open

How to apply this function to 1channel image? #127

schliezer opened this issue Nov 6, 2023 · 6 comments

Comments

@schliezer
Copy link

Thank you so much for your contribution! I came across a problem when comparing two 1channel images. The traceback threw out a 'non-singleton dimension dismatch' at line 154 'return (inp - self.shift) / self.scale'. Later I learned that this function works for 3channel images, but I am not sure if that is the reason in my case (input/target shape(B,C,H,W): (4,1,256,256)), if it is, then how can I convert to 3channel? Thanks!

@richzhang
Copy link
Owner

Repeat the channel 3x to make it an RGB image

@iris0329
Copy link

Hi @richzhang
Thanks for your contribution, Could you give me some ideas on how to change shift and scale if I want to apply it to my own data, which is a 5-channel image?

@richzhang
Copy link
Owner

The method is for RGB images. It somewhat makes sense for "1 channel" grayscale images, but doesn't make sense to run for a 5 channel image.

@iris0329
Copy link

I see now, thanks a lot

@Mally-cj
Copy link

Mally-cj commented Jul 1, 2024

I am courious about how to determine the value of self.shift and self.scale . And as I comparing two 1channel images,can I delet the ScalingLayer?What happen if I do?

@Mally-cj
Copy link

Mally-cj commented Jul 4, 2024

Thank you so much for your contribution! I came across a problem when comparing two 1channel images. The traceback threw out a 'non-singleton dimension dismatch' at line 154 'return (inp - self.shift) / self.scale'. Later I learned that this function works for 3channel images, but I am not sure if that is the reason in my case (input/target shape(B,C,H,W): (4,1,256,256)), if it is, then how can I convert to 3channel? Thanks!

I also meet this question and I have solve it.
As I use LPIPSWithDiscriminator to encounter this problem,I find that adding a line of code can solve it in this folling code can solve it. Because LPIPS only calculates a value of 1 * 1, the input can be a tensor of batch size * 1 * size * size. Therefore, the reason for the error is that it affects the code of other parts.
image
image

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

4 participants