refactor: remove face restoration from processing pipeline

- Remove CodeFormer/GFPGAN import and setup from webui.py initialize()
- Remove face_restorers list, codeformer/gfpgan model path settings,
  and face restore UI settings section from shared.py
- Remove restore_faces parameter from StableDiffusionProcessing
- Remove face_restoration import and restore_faces processing block
  from processing.py
pull/4637/head
CalamitousFelicitousness 2026-02-08 22:59:00 +00:00
parent 1e23495039
commit d01f45519f
4 changed files with 1 additions and 25 deletions

View File

@ -3,7 +3,7 @@ import json
import time
import numpy as np
from PIL import Image, ImageOps
from modules import shared, devices, errors, images, scripts_manager, memstats, script_callbacks, extra_networks, detailer, sd_models, sd_checkpoint, sd_vae, processing_helpers, timer, face_restoration
from modules import shared, devices, errors, images, scripts_manager, memstats, script_callbacks, extra_networks, detailer, sd_models, sd_checkpoint, sd_vae, processing_helpers, timer
from modules.sd_hijack_hypertile import context_hypertile_vae, context_hypertile_unet
from modules.processing_class import StableDiffusionProcessing, StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, StableDiffusionProcessingControl, StableDiffusionProcessingVideo # pylint: disable=unused-import
from modules.processing_info import create_infotext
@ -55,8 +55,6 @@ class Processed:
self.audio = audio
self.restore_faces = p.restore_faces or False
self.face_restoration_model = shared.opts.face_restoration_model if p.restore_faces else None
self.detailer = p.detailer_enabled or False
self.detailer_model = shared.opts.detailer_model if p.detailer_enabled else None
self.seed_resize_from_w = p.seed_resize_from_w
@ -297,15 +295,6 @@ def process_samples(p: StableDiffusionProcessing, samples):
if not shared.state.interrupted and not shared.state.skipped:
if p.restore_faces:
p.ops.append('restore')
if not p.do_not_save_samples and shared.opts.save_images_before_detailer:
info = create_infotext(p, p.prompts, p.seeds, p.subseeds, index=i)
images.save_image(Image.fromarray(sample), path=p.outpath_samples, basename="", seed=p.seeds[i], prompt=p.prompts[i], extension=shared.opts.samples_format, info=info, p=p, suffix="-before-restore")
sample = face_restoration.restore_faces(sample, p)
if sample is not None:
image = Image.fromarray(sample)
if p.detailer_enabled:
p.ops.append('detailer')
if not p.do_not_save_samples and shared.opts.save_images_before_detailer:

View File

@ -57,7 +57,6 @@ class StableDiffusionProcessing:
# other
hidiffusion: bool = False,
do_not_reload_embeddings: bool = False,
restore_faces: bool = False,
# detailer
detailer_enabled: bool = False,
detailer_prompt: str = '',
@ -214,7 +213,6 @@ class StableDiffusionProcessing:
self.detailer_steps = detailer_steps
self.detailer_strength = detailer_strength
self.detailer_resolution = detailer_resolution
self.restore_faces = restore_faces
self.init_images = init_images
self.init_control = init_control
self.resize_mode = resize_mode

View File

@ -80,7 +80,6 @@ xformers_available = False
compiled_model_state = None
sd_upscalers = []
detailers = []
face_restorers = []
yolo = None
tab_names = []
extra_networks: list[ExtraNetworksPage] = []
@ -524,8 +523,6 @@ options_templates.update(options_section(('system-paths', "System Paths"), {
"embeddings_dir": OptionInfo(os.path.join(paths.models_path, 'embeddings'), "Folder with textual inversion embeddings", folder=True),
"control_dir": OptionInfo(os.path.join(paths.models_path, 'control'), "Folder with Control models", folder=True),
"yolo_dir": OptionInfo(os.path.join(paths.models_path, 'yolo'), "Folder with Yolo models", folder=True),
"codeformer_models_path": OptionInfo(os.path.join(paths.models_path, 'Codeformer'), "Folder with codeformer models", folder=True),
"gfpgan_models_path": OptionInfo(os.path.join(paths.models_path, 'GFPGAN'), "Folder with GFPGAN models", folder=True),
"esrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'ESRGAN'), "Folder with ESRGAN models", folder=True),
"bsrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'BSRGAN'), "Folder with BSRGAN models", folder=True),
"realesrgan_models_path": OptionInfo(os.path.join(paths.models_path, 'RealESRGAN'), "Folder with RealESRGAN models", folder=True),
@ -693,9 +690,6 @@ options_templates.update(options_section(('postprocessing', "Postprocessing"), {
"postprocessing_sep_seedvt": OptionInfo("<h2>SeedVT</h2>", "", gr.HTML),
"seedvt_cfg_scale": OptionInfo(3.5, "SeedVR CFG Scale", gr.Slider, {"minimum": 1, "maximum": 15, "step": 1}),
"postprocessing_sep_face_restore": OptionInfo("<h2>Face Restore</h2>", "", gr.HTML),
"face_restoration_model": OptionInfo("None", "Face restoration", gr.Radio, lambda: {"choices": ['None'] + [x.name() for x in face_restorers]}),
"code_former_weight": OptionInfo(0.2, "CodeFormer weight parameter", gr.Slider, {"minimum": 0, "maximum": 1, "step": 0.01}),
"postprocessing_sep_upscalers": OptionInfo("<h2>Upscaling</h2>", "", gr.HTML),
"upscaler_unload": OptionInfo(False, "Unload upscaler after processing"),

View File

@ -100,11 +100,6 @@ def initialize():
shared.prompt_styles.reload()
timer.startup.record("styles")
import modules.postprocess.codeformer_model as codeformer
codeformer.setup_model(shared.opts.codeformer_models_path)
sys.modules["modules.codeformer_model"] = codeformer
import modules.postprocess.gfpgan_model as gfpgan
gfpgan.setup_model(shared.opts.gfpgan_models_path)
import modules.postprocess.yolo as yolo
yolo.initialize()
timer.startup.record("detailer")