mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
allow different lora in hires
Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- pipelines: add **ZImageInpaint**, thanks @CalamitousFelicitousness
|
||||
- add `--remote` command line flag that reduces client/server chatter and improves link stability
|
||||
for long-running generates, useful when running on remote servers
|
||||
- hires: allow using different lora in refiner prompt
|
||||
- **UI**
|
||||
- ui: **themes** add *CTD-NT64Light* and *CTD-NT64Dark*, thanks @resonantsky
|
||||
- ui: **gallery** add option to auto-refresh gallery, thanks @awsr
|
||||
|
||||
@@ -156,7 +156,6 @@ def parse_prompt(prompt: str | None) -> tuple[str, defaultdict[str, list[ExtraNe
|
||||
if prompt is None:
|
||||
return "", res
|
||||
if isinstance(prompt, list):
|
||||
shared.log.warning(f"parse_prompt was called with a list instead of a string: {prompt}")
|
||||
return parse_prompts(prompt)
|
||||
|
||||
def found(m: re.Match[str]):
|
||||
@@ -168,13 +167,17 @@ def parse_prompt(prompt: str | None) -> tuple[str, defaultdict[str, list[ExtraNe
|
||||
return updated_prompt, res
|
||||
|
||||
|
||||
def parse_prompts(prompts: list[str]):
|
||||
def parse_prompts(prompts: list[str], extra_data=None):
|
||||
updated_prompt_list: list[str] = []
|
||||
extra_data: defaultdict[str, list[ExtraNetworkParams]] = defaultdict(list)
|
||||
extra_data: defaultdict[str, list[ExtraNetworkParams]] = extra_data or defaultdict(list)
|
||||
for prompt in prompts:
|
||||
updated_prompt, parsed_extra_data = parse_prompt(prompt)
|
||||
if not extra_data:
|
||||
extra_data = parsed_extra_data
|
||||
elif parsed_extra_data:
|
||||
extra_data = parsed_extra_data
|
||||
else:
|
||||
pass
|
||||
updated_prompt_list.append(updated_prompt)
|
||||
|
||||
return updated_prompt_list, extra_data
|
||||
|
||||
@@ -272,7 +272,6 @@ def process_init(p: StableDiffusionProcessing):
|
||||
p.all_prompts, p.all_negative_prompts = shared.prompt_styles.apply_styles_to_prompts(p.all_prompts, p.all_negative_prompts, p.styles, p.all_seeds)
|
||||
p.prompts = p.all_prompts[(p.iteration * p.batch_size):((p.iteration+1) * p.batch_size)]
|
||||
p.negative_prompts = p.all_negative_prompts[(p.iteration * p.batch_size):((p.iteration+1) * p.batch_size)]
|
||||
p.prompts, _ = extra_networks.parse_prompts(p.prompts)
|
||||
|
||||
|
||||
def process_samples(p: StableDiffusionProcessing, samples):
|
||||
|
||||
@@ -171,6 +171,7 @@ def process_base(p: processing.StableDiffusionProcessing):
|
||||
modelstats.analyze()
|
||||
try:
|
||||
t0 = time.time()
|
||||
p.prompts, p.network_data = extra_networks.parse_prompts(p.prompts, p.network_data)
|
||||
extra_networks.activate(p, exclude=['text_encoder', 'text_encoder_2', 'text_encoder_3'])
|
||||
|
||||
if hasattr(shared.sd_model, 'tgate') and getattr(p, 'gate_step', -1) > 0:
|
||||
@@ -297,10 +298,20 @@ def process_hires(p: processing.StableDiffusionProcessing, output):
|
||||
p.denoising_strength = strength
|
||||
orig_image = p.task_args.pop('image', None) # remove image override from hires
|
||||
process_pre(p)
|
||||
|
||||
prompts = p.prompts
|
||||
reset_prompts = False
|
||||
if len(p.refiner_prompt) > 0:
|
||||
prompts = len(output.images)* [p.refiner_prompt]
|
||||
prompts, p.network_data = extra_networks.parse_prompts(prompts)
|
||||
reset_prompts = True
|
||||
if reset_prompts or ('base' in p.skip):
|
||||
extra_networks.activate(p)
|
||||
|
||||
hires_args = set_pipeline_args(
|
||||
p=p,
|
||||
model=shared.sd_model,
|
||||
prompts=len(output.images)* [p.refiner_prompt] if len(p.refiner_prompt) > 0 else p.prompts,
|
||||
prompts=prompts,
|
||||
negative_prompts=len(output.images) * [p.refiner_negative] if len(p.refiner_negative) > 0 else p.negative_prompts,
|
||||
prompts_2=len(output.images) * [p.refiner_prompt] if len(p.refiner_prompt) > 0 else p.prompts,
|
||||
negative_prompts_2=len(output.images) * [p.refiner_negative] if len(p.refiner_negative) > 0 else p.negative_prompts,
|
||||
@@ -314,11 +325,10 @@ def process_hires(p: processing.StableDiffusionProcessing, output):
|
||||
strength=strength,
|
||||
desc='Hires',
|
||||
)
|
||||
|
||||
hires_steps = hires_args.get('prior_num_inference_steps', None) or p.hr_second_pass_steps or hires_args.get('num_inference_steps', None)
|
||||
shared.state.update(get_job_name(p, shared.sd_model), hires_steps, 1)
|
||||
try:
|
||||
if 'base' in p.skip:
|
||||
extra_networks.activate(p)
|
||||
taskid = shared.state.begin('Inference')
|
||||
output = shared.sd_model(**hires_args) # pylint: disable=not-callable
|
||||
shared.state.end(taskid)
|
||||
|
||||
Reference in New Issue
Block a user