-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Corrects color channels in face restoration; Fixes #1167 #1175
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
Corrects color channels in face restoration; Fixes #1167 #1175
Conversation
|
I guess there's no harm in using cv2 for this if it's already a project dependency, but does Pillow have any modes that work for this built-in? Maybe https://pillow.readthedocs.io/en/stable/handbook/concepts.html#modes |
|
Great find! |
hipsterusername
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm! Seems like a simple whoops😅
Good catch - I tried "BGR" first and it didn't work, shoulda checked the docs. I'll give this a whirl. |
lstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Congrats on finding and fixing the problem!
|
We already use cv2 so there's no particular advantage to doing this in Pillow, but if you want to, go ahead. |
|
I had blue tint on the final rendered image when using restore face on a M1 Mac. After research and messing around I found this solution. https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/codeformer.pth to /stable-diffusion-webui/models/Codeformer/codeformer-v0.1.0.pth https://github.com/xinntao/facexlib/releases/download/v0.1.0/detection_Resnet50_Final.pth to /stable-diffusion-webui/repositories/CodeFormer/weights/facelib/detection_Resnet50_Final.pth https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/parsing_parsenet.pth to /stable-diffusion-webui/repositories/CodeFormer/weights/facelib/parsing_parsenet.pt |
Our Codeformer and GFPGAN implementations are sending RGB image data to the restoration code, but they expect BGR image data (as used by OpenCV).
The fix is simple; use a cv2 method to convert the image from RGB to BGR before processing, and then back to RGB so we can continue using PIL.
This fixes an until-today unknown flaw in our GFPGAN implementation, which was recognized by user JoshuaKimsey on discord.