mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 17:24:32 +02:00
fix prompt parser with batch size
Signed-off-by: Vladimir Mandic <mandic00@live.com>
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
- Fix TAESD model type detection
|
||||
- Fix LoRA loader incorrectly reporting errors
|
||||
- Fix hypertile for img2img and inpaint operations
|
||||
- Fix prompt parser batch size
|
||||
|
||||
## Update for 2025-06-16
|
||||
|
||||
|
||||
@@ -424,19 +424,28 @@ def resize_hires(p, latents): # input=latents output=pil if not latent_upscaler
|
||||
def fix_prompts(p, prompts, negative_prompts, prompts_2, negative_prompts_2):
|
||||
if hasattr(p, 'keep_prompts'):
|
||||
return prompts, negative_prompts, prompts_2, negative_prompts_2
|
||||
|
||||
if type(prompts) is str:
|
||||
prompts = [prompts]
|
||||
if type(negative_prompts) is str:
|
||||
negative_prompts = [negative_prompts]
|
||||
|
||||
if hasattr(p, '[init_images]') and p.init_images is not None and len(p.init_images) > 1:
|
||||
while len(prompts) < len(p.init_images):
|
||||
prompts.append(prompts[-1])
|
||||
while len(negative_prompts) < len(p.init_images):
|
||||
negative_prompts.append(negative_prompts[-1])
|
||||
|
||||
while len(prompts) < p.batch_size:
|
||||
prompts.append(prompts[-1])
|
||||
while len(negative_prompts) < p.batch_size:
|
||||
negative_prompts.append(negative_prompts[-1])
|
||||
|
||||
while len(negative_prompts) < len(prompts):
|
||||
negative_prompts.append(negative_prompts[-1])
|
||||
while len(prompts) < len(negative_prompts):
|
||||
prompts.append(prompts[-1])
|
||||
|
||||
if type(prompts_2) is str:
|
||||
prompts_2 = [prompts_2]
|
||||
if type(prompts_2) is list:
|
||||
|
||||
@@ -53,7 +53,8 @@ class PromptEmbedder:
|
||||
self.negative_prompts = negative_prompts
|
||||
self.batchsize = len(self.prompts)
|
||||
self.attention = last_attention
|
||||
self.allsame = self.compare_prompts() # collapses batched prompts to single prompt if possible
|
||||
self.allsame = False # dont collapse prompts
|
||||
# self.allsame = self.compare_prompts() # collapses batched prompts to single prompt if possible
|
||||
self.steps = steps
|
||||
self.clip_skip = clip_skip
|
||||
# All embeds are nested lists, outer list batch length, inner schedule length
|
||||
@@ -83,7 +84,7 @@ class PromptEmbedder:
|
||||
self.checkcache(p)
|
||||
debug(f"Prompt encode: time={(time.time() - t0):.3f}")
|
||||
|
||||
def checkcache(self, p):
|
||||
def checkcache(self, p) -> bool:
|
||||
if shared.opts.sd_textencoder_cache_size == 0:
|
||||
return False
|
||||
if self.scheduled_prompt:
|
||||
@@ -176,13 +177,13 @@ class PromptEmbedder:
|
||||
else:
|
||||
prompt_embed, positive_pooled, negative_embed, negative_pooled = get_weighted_text_embeddings(pipe, positive_prompt, negative_prompt, self.clip_skip)
|
||||
if prompt_embed is not None:
|
||||
self.prompt_embeds[batchidx].append(prompt_embed)
|
||||
self.prompt_embeds[batchidx] = [prompt_embed]
|
||||
if negative_embed is not None:
|
||||
self.negative_prompt_embeds[batchidx].append(negative_embed)
|
||||
self.negative_prompt_embeds[batchidx] = [negative_embed]
|
||||
if positive_pooled is not None:
|
||||
self.positive_pooleds[batchidx].append(positive_pooled)
|
||||
self.positive_pooleds[batchidx] = [positive_pooled]
|
||||
if negative_pooled is not None:
|
||||
self.negative_pooleds[batchidx].append(negative_pooled)
|
||||
self.negative_pooleds[batchidx] = [negative_pooled]
|
||||
|
||||
if debug_enabled:
|
||||
get_tokens(pipe, 'positive', positive_prompt)
|
||||
|
||||
Reference in New Issue
Block a user