richzhang / PerceptualSimilarity

LPIPS metric. pip install lpips
https://richzhang.github.io/PerceptualSimilarity
BSD 2-Clause "Simplified" License
3.62k stars 500 forks source link

normalization in BGR #116

Closed 98mxr closed 1 year ago

98mxr commented 1 year ago

I want to use LPIPS on BGR img instead of RGB img, can I just swap the order of mean/std in ScalingLayer?

richzhang commented 1 year ago

That alone won't fix it, since the network is expecting RGB. Simply reverse the channels in your image and you're good to go

98mxr commented 1 year ago

I use LPIPS as a loss for backward. Reverse img channels after forward will cause my model to fail to converge. I tried many times and located the problem on reverse img channels. It is estimated that this operation caused the gradient On the problem, I can't even clamping img to (-1, 1).

98mxr commented 1 year ago

I modified my model so that reverse can work well, thank you for your reply.