fix: params.txt

This commit is contained in:
Dowon
2023-12-30 17:07:41 +09:00
parent 1d40c6ad22
commit f1dfb34ed1
2 changed files with 8 additions and 37 deletions

View File

@@ -6,6 +6,7 @@
- 파일을 인자로 추가하는 몇몇 스크립트에 대해 deepcopy의 에러를 피하기 위해 script_args 복사 방법을 변경함
- skip img2img 기능을 사용할 때 너비, 높이를 128로 고정하여 스킵 과정이 조금 더 나아짐
- img2img inpainting 모드에서 adetailer 자동 비활성화
- 처음 생성된 params.txt 파일을 항상 유지하도록 변경함
## 2023-11-19

View File

@@ -41,9 +41,8 @@ from controlnet_ext.restore import (
CNHijackRestore,
cn_allow_script_control,
)
from modules import images, safe, script_callbacks, scripts, shared
from modules import images, paths, safe, script_callbacks, scripts, shared
from modules.devices import NansException
from modules.paths import data_path, models_path
from modules.processing import (
Processed,
StableDiffusionProcessingImg2Img,
@@ -54,7 +53,7 @@ from modules.sd_samplers import all_samplers
from modules.shared import cmd_opts, opts, state
no_huggingface = getattr(cmd_opts, "ad_no_huggingface", False)
adetailer_dir = Path(models_path, "adetailer")
adetailer_dir = Path(paths.models_path, "adetailer")
extra_models_dir = shared.opts.data.get("ad_extra_models_dir", "")
model_mapping = get_models(
adetailer_dir, extra_dir=extra_models_dir, huggingface=not no_huggingface
@@ -105,28 +104,6 @@ def preseve_prompts(p):
p.all_negative_prompts = all_ng
@contextmanager
def change_skip_img2img_args(p):
if hasattr(p, "_ad_orig"):
steps = p.steps
sampler_name = p.sampler_name
width = p.width
height = p.height
try:
p.steps = p._ad_orig.steps
p.sampler_name = p._ad_orig.sampler_name
p.width = p._ad_orig.width
p.height = p._ad_orig.height
yield
finally:
p.steps = steps
p.sampler_name = sampler_name
p.width = width
p.height = height
else:
yield
class AfterDetailerScript(scripts.Script):
def __init__(self):
super().__init__()
@@ -427,18 +404,10 @@ class AfterDetailerScript(scripts.Script):
p, p.all_prompts, p.all_seeds, p.all_subseeds, None, 0, 0
)
def write_params_txt(self, p) -> None:
i = self.get_i(p)
lenp = len(p.all_prompts)
if i % lenp != lenp - 1:
return
with change_skip_img2img_args(p):
infotext = self.infotext(p)
params_txt = Path(data_path, "params.txt")
def write_params_txt(self, content: str) -> None:
params_txt = Path(paths.data_path, "params.txt")
with suppress(Exception):
params_txt.write_text(infotext, encoding="utf-8")
params_txt.write_text(content, encoding="utf-8")
@staticmethod
def script_args_copy(script_args):
@@ -775,6 +744,7 @@ class AfterDetailerScript(scripts.Script):
pp.image = self.ensure_rgb_image(pp.image)
init_image = copy(pp.image)
arg_list = self.get_args(p, *args_)
params_txt_content = Path(paths.data_path, "params.txt").read_text("utf-8")
if self.need_call_postprocess(p):
dummy = Processed(p, [], p.seed, "")
@@ -800,7 +770,7 @@ class AfterDetailerScript(scripts.Script):
p.scripts.before_process(copy_p)
p.scripts.process(copy_p)
self.write_params_txt(p)
self.write_params_txt(params_txt_content)
def on_after_component(component, **_kwargs):