AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
135.17k stars 25.82k forks source link

[Feature Request]: select face restoration model through image generation API #7352

Open MaikoTan opened 1 year ago

MaikoTan commented 1 year ago

Is there an existing issue for this?

What would your feature do ?

Currently we have CodeFormer and GFPGAN as face restoration models, but you could only select them in the Settings page. When we are using txt2img or img2img with face restoration through API, it is painful and insecure to change config through API before requesting the image generation. I think we could make the existing restore_face property in API as a string field that has 2 valid value: CodeFormer and GFPGAN.

Proposed workflow

  1. Remove the existing Face Restoration Model in Settings page
  2. Change the existing Restore Face checkbox to a dropdown contains None, CodeFormer and GFPGAN
  3. Change the restore_face in txt2img function and img2img function from bool to str | None
  4. Change the modules/face_restoration.py to receive the model name instead of reading from shared.opts
  5. Change the modules/processing.py to pass face restoration models into the restore_face function described in 4)

Additional information

No response

MaikoTan commented 1 year ago

This feature we need for our plugin that supports webui and stable horde, both support GFPGAN and CodeFormer, but with different parameters.