stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Feature Request]: Add "Restore faces" as option to the X/Y/Z plot
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What would your feature do ?
I looked through all the issues and discussion with the search prompt "restore faces" and "plot" and have not found nothing related, so seems like this is a new idea. Correct me if I'm wrong.
The idea is simple: I want to have an ability to compare the generation results without and with "Restore faces" option turned on. Moreover, I would like it to be like in the "Samplers" option, having an options to choose: what face restorers to use (GFPGAN, CodeFormer, etc.). Also, if using the last idea, we have to be able to define model's params, like in CodeFormer.
TLDR: add axis for "Restore faces".
Proposed workflow
- Go to "txt2img"
- Press "Script" > "X/Y/Z plot"
- Press on "X type" (or "Y type" or "Z type")
- Choose "Restore faces" from all the available options
- Press on the book pic next to "X values"
- After that, the possible options will be displayed in "X values", say:
GFPGAN, CodeFormer=0.5
- Edit the "X values" field as you like (you may change the
CodeFormer=0.5
toCodeFormer=0.85
or any other float 0 < x < 1) - Press "Generate"
Additional information
No response
edit: okay I opened my first PR here: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/8435
until then you patch the code manually:
add this to scripts/xyz_grid.py
:
first add the option to axis_options
:
AxisOption("Face restore", str, apply_face_restore, format_value=format_value),
then add apply_face_restore
:
def apply_face_restore(p, opt, x):
opt = opt.lower()
if opt == 'codeformer':
is_active = True
p.face_restoration_model = 'CodeFormer'
elif opt == 'gfpgan':
is_active = True
p.face_restoration_model = 'GFPGAN'
else:
is_active = opt in ('true', 'yes', 'y', '1')
p.restore_faces = is_active
here I rendered something with low sampling steps intentionally:
notice the options are either: one of yes, y, true, 1
to use the model specified in settings
or specifically either codeformer
or gfpgan
anything else is interpreted as false.