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

[Bug]: CodeFormer weight slider has no effect #636

Closed
4 of 6 tasks
mamei16 opened this issue Apr 3, 2024 · 1 comment
Closed
4 of 6 tasks

[Bug]: CodeFormer weight slider has no effect #636

mamei16 opened this issue Apr 3, 2024 · 1 comment

Comments

@mamei16
Copy link

mamei16 commented Apr 3, 2024

Checklist

  • The issue exists after disabling all extensions
  • The issue exists on a clean installation of webui
  • The issue is caused by an extension, but I believe it is caused by a bug in the webui
  • The issue exists in the current version of the webui
  • The issue has not been reported before recently
  • The issue has been reported before but has not been fixed yet

What happened?

I noticed that the "CodeFormer weight" slider on the Settings tab had no effect on the resulting restored faces. However, on the huggingface space of CodeFormer, the corresponding "Codeformer_Fidelity" slider clearly did have an effect on the output.
I found that the main difference between the code of that huggingface space and implementation of this web UI is how the codeformer model is loaded. The huggingspace implementation uses a local architecture registry to instantiate the model, while this webui relies on spandrel to determine the correct network architecture and load the model. This is where the bug originates:
The forward method of the huggingface codeformer archicture registry python file uses the keyword argument w to control the "Codeformer_Fidelity", while the corresponding spandrel codeformer architecture python file uses a keyword argument named weight instead.
However, in the modules/codeformer_model implementation, forward is called with the kwarg w, which is ignored and leads to the default value of 0.5 being used every time.

Steps to reproduce the problem

  1. Generate a picture of a person facing the camera
  2. Go to settings and check "Restore faces"
  3. Select "CodeFormer" as the Face restoration model
  4. Set the CodeFormer weight to 0
  5. Re-generate the first picture using the same seed
  6. Set the CodeFormer weight to 1
  7. Re-generate the first picture using the same seed
  8. Compare the pictures of step 5 and 7 and notice that they are identical

What should have happened?

In the forward call of the codeformer model in modules/codeformer_model , the keyword argument w should be changed toweight, so that the "CodeFormer weight" slider actually has an effect on the restored faces.
Here is the line after I changed it:

return self.net(cropped_face_t, weight=w, adain=True)[0]

What browsers do you use to access the UI ?

No response

Sysinfo

Console logs

-

Additional information

No response

@mamei16
Copy link
Author

mamei16 commented Apr 7, 2024

This has been fixed in Automatic1111: AUTOMATIC1111/stable-diffusion-webui#15414

@mamei16 mamei16 closed this as completed Apr 7, 2024
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

1 participant