diff --git a/extensions-builtin/Lora/extra_networks_lora.py b/extensions-builtin/Lora/extra_networks_lora.py index 1d319d0b6..bba57943c 100644 --- a/extensions-builtin/Lora/extra_networks_lora.py +++ b/extensions-builtin/Lora/extra_networks_lora.py @@ -64,6 +64,10 @@ class ExtraNetworkLora(extra_networks.ExtraNetwork): shared.log.debug(f"Load network: type=LoRA tags={all_tags} max={shared.opts.lora_apply_tags} apply") all_tags = ', '.join(all_tags) p.extra_generation_params["LoRA tags"] = all_tags + if '_tags_' in p.prompt: + p.prompt = p.prompt.replace('_tags_', all_tags) + else: + p.prompt = f"{p.prompt}, {all_tags}" if p.all_prompts is not None: for i in range(len(p.all_prompts)): if '_tags_' in p.all_prompts[i]: diff --git a/modules/processing.py b/modules/processing.py index 6e85999d0..c26668763 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -250,6 +250,9 @@ def process_init(p: StableDiffusionProcessing): p.all_subseeds = [int(subseed) + x for x in range(len(p.all_prompts))] if reset_prompts: 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] + def process_images_inner(p: StableDiffusionProcessing) -> Processed: """this is the main loop that both txt2img and img2img use; it calls func_init once inside all the scopes and func_sample once per batch""" diff --git a/modules/processing_diffusers.py b/modules/processing_diffusers.py index 3a8f5d2c8..22293fb02 100644 --- a/modules/processing_diffusers.py +++ b/modules/processing_diffusers.py @@ -379,6 +379,8 @@ def process_diffusers(p: processing.StableDiffusionProcessing): shared.sd_model = sd_models.set_diffuser_pipe(shared.sd_model, sd_models.DiffusersTaskType.INPAINTING) # force pipeline if len(getattr(p, 'init_images', [])) == 0: p.init_images = [TF.to_pil_image(torch.rand((3, getattr(p, 'height', 512), getattr(p, 'width', 512))))] + 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] sd_models.move_model(shared.sd_model, devices.device) sd_models_compile.openvino_recompile_model(p, hires=False, refiner=False) # recompile if a parameter changes diff --git a/scripts/xyz_grid_shared.py b/scripts/xyz_grid_shared.py index f4474d60b..586070658 100644 --- a/scripts/xyz_grid_shared.py +++ b/scripts/xyz_grid_shared.py @@ -207,10 +207,8 @@ def apply_lora(p, x, xs): return x = os.path.basename(x) p.prompt = p.prompt + f" " - if p.all_prompts is not None: - p.all_prompts = len(p.all_prompts) * [p.prompt] - if p.all_negative_prompts is not None: - p.all_negative_prompts = len(p.all_negative_prompts) * [p.prompt] + p.all_prompts = None + p.all_negative_prompts = None shared.log.debug(f'XYZ grid apply LoRA: "{x}"')