facehires set steps, sampler

This commit is contained in:
Vladimir Mandic
2024-03-10 16:19:57 -04:00
parent f45c335dab
commit 70ede51166
3 changed files with 10 additions and 3 deletions
+1 -1
View File
@@ -69,7 +69,7 @@
- new *face restore* option, works similar to well-known *adetailer* by running an inpaint on detected faces but with just a checkbox to enable/disable
- set as default face restorer in settings -> postprocessing
- disabled by default, to enable simply check *face restore* in your generate advanced settings
- strength is controlled by refine strength setting
- strength, steps and sampler are set using by hires section in refine menu
- will use secondary prompt and secondary negative prompt if present in refine
- **Watermarking**
- SD.Next disables all known watermarks in models, but does allow user to set custom watermark
+3
View File
@@ -521,6 +521,9 @@ def switch_class(p: StableDiffusionProcessing, new_class: type, dct: dict = None
shared.log.debug(f"Switching class: {p.__class__} -> {new_class}")
p.__class__ = new_class
p.__init__(**kwargs)
for k, v in p.__dict__.items():
if hasattr(p, k):
setattr(p, k, v)
if dct is not None: # post init set additional values
for k, v in dct.items():
if hasattr(p, k):
+6 -2
View File
@@ -90,7 +90,9 @@ class FaceRestorerYolo(FaceRestoration):
def restore(self, np_image, p: processing.StableDiffusionProcessing = None):
from modules import devices, processing_class
if np_image is None or hasattr(p, 'facehires'):
if not hasattr(p, 'facehires'):
p.facehires = 0
if np_image is None or getattr(p, 'facehires', 0) >= p.batch_size:
return np_image
self.load()
if self.model is None:
@@ -107,7 +109,7 @@ class FaceRestorerYolo(FaceRestoration):
orig_cls = p.__class__
pp = None
p.facehires = True # set flag to avoid recursion
p.facehires += 1 # set flag to avoid recursion
shared.opts.data['mask_apply_overlay'] = True
p = processing_class.switch_class(p, processing.StableDiffusionProcessingImg2Img)
@@ -122,6 +124,8 @@ class FaceRestorerYolo(FaceRestoration):
p.inpaint_full_res = True
p.inpainting_mask_invert = 0
p.inpainting_fill = 1 # no fill
p.sampler_name = orig_p.get('hr_sampler_name', 'default')
p.steps = orig_p.get('hr_second_pass_steps', p.steps)
p.denoising_strength = orig_p.get('denoising_strength', 0.3)
p.styles = []
p.prompt = orig_p.get('refiner_prompt', '')