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 ignore some pixels when calculating the loss? #111

Open
MargauxMasson opened this issue Sep 6, 2022 · 1 comment
Open

How to ignore some pixels when calculating the loss? #111

MargauxMasson opened this issue Sep 6, 2022 · 1 comment

Comments

@MargauxMasson
Copy link

Hi,

I would like to ignore some pixels in the pairs of images I am comparing, how can I do this? I have the masks of the pixels I don't want to be used when calculating the loss.

Thank you!

@richzhang
Copy link
Owner

You can turn spatial=True https://github.com/richzhang/PerceptualSimilarity/blob/master/lpips/lpips.py#L23 and then multiply by the mask. Keep in mind that this won't mask the pixels out exactly, since the deep features have a receptive field. To truly mask out the pixels, you need to trace through the receptive fields of the deep activations like in https://openaccess.thecvf.com/content_cvpr_2017/papers/Gatys_Controlling_Perceptual_Factors_CVPR_2017_paper.pdf

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