未验证 提交 53924aea 编写于 作者: A AUTOMATIC1111 提交者: GitHub

Merge pull request #11477 from hako-mikan/master

add `before_hr` script callback
......@@ -1078,6 +1078,9 @@ class StableDiffusionProcessingTxt2Img(StableDiffusionProcessing):
sd_models.apply_token_merging(self.sd_model, self.get_token_merging_ratio(for_hr=True))
if self.scripts is not None:
self.scripts.before_hr(self)
samples = self.sampler.sample_img2img(self, samples, noise, self.hr_c, self.hr_uc, steps=self.hr_second_pass_steps or self.steps, image_conditioning=image_conditioning)
sd_models.apply_token_merging(self.sd_model, self.get_token_merging_ratio())
......
......@@ -187,6 +187,11 @@ class Script:
return f'script_{tabname}{title}_{item_id}'
def before_hr(self, p ,*args):
"""
This function is called before hires fix start.
"""
pass
current_basedir = paths.script_path
......@@ -549,6 +554,15 @@ class ScriptRunner:
self.scripts[si].args_to = args_to
def before_hr(self, p):
for script in self.alwayson_scripts:
try:
script_args = p.script_args[script.args_from:script.args_to]
script.before_hr(p, *script_args)
except Exception:
errors.report(f"Error running before_hr: {script.filename}", exc_info=True)
scripts_txt2img: ScriptRunner = None
scripts_img2img: ScriptRunner = None
scripts_postproc: scripts_postprocessing.ScriptPostprocessingRunner = None
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册