Spaces:
Runtime error
Runtime error
ImageStudio Maintainer Claude Opus 4.8 (1M context) commited on
Commit Β·
5c7571d
1
Parent(s): 50c4793
fix: pad SDXL compel conditionings for long prompts
Browse filescompel([prompt, negative]) pads internally via
conditioning_provider.empty_z, which the SDXL dual-encoder
EmbeddingsProviderMulti does not expose, so long prompts (whose chunk
count differs from the negative) crashed with AttributeError. Encode the
prompt and negative separately and pad with the empty-string conditioning
passed as precomputed_padding.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
app.py
CHANGED
|
@@ -342,13 +342,24 @@ def generate_image(
|
|
| 342 |
negative_prompt = ""
|
| 343 |
conv_prompt = get_embed_new(prompt, noobxl_pipe, compel, only_convert_string=True)
|
| 344 |
conv_negative = get_embed_new(negative_prompt, noobxl_pipe, compel, only_convert_string=True)
|
| 345 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
|
| 347 |
image = noobxl_pipe(
|
| 348 |
-
prompt_embeds=
|
| 349 |
-
pooled_prompt_embeds=
|
| 350 |
-
negative_prompt_embeds=
|
| 351 |
-
negative_pooled_prompt_embeds=
|
| 352 |
width=int(width),
|
| 353 |
height=int(height),
|
| 354 |
guidance_scale=float(guidance_scale),
|
|
|
|
| 342 |
negative_prompt = ""
|
| 343 |
conv_prompt = get_embed_new(prompt, noobxl_pipe, compel, only_convert_string=True)
|
| 344 |
conv_negative = get_embed_new(negative_prompt, noobxl_pipe, compel, only_convert_string=True)
|
| 345 |
+
# Encode prompt and negative separately, then pad to equal length. The
|
| 346 |
+
# batched ``compel([prompt, negative])`` call pads internally via
|
| 347 |
+
# ``conditioning_provider.empty_z``, which the SDXL dual-encoder
|
| 348 |
+
# ``EmbeddingsProviderMulti`` does not expose (crashes on long prompts
|
| 349 |
+
# whose chunk count differs from the negative). Supplying the empty-string
|
| 350 |
+
# conditioning as ``precomputed_padding`` sidesteps that missing attribute.
|
| 351 |
+
cond_prompt, pooled_prompt = compel(conv_prompt)
|
| 352 |
+
cond_negative, pooled_negative = compel(conv_negative)
|
| 353 |
+
empty_padding, _ = compel("")
|
| 354 |
+
cond_prompt, cond_negative = compel.pad_conditioning_tensors_to_same_length(
|
| 355 |
+
[cond_prompt, cond_negative], precomputed_padding=empty_padding
|
| 356 |
+
)
|
| 357 |
|
| 358 |
image = noobxl_pipe(
|
| 359 |
+
prompt_embeds=cond_prompt,
|
| 360 |
+
pooled_prompt_embeds=pooled_prompt,
|
| 361 |
+
negative_prompt_embeds=cond_negative,
|
| 362 |
+
negative_pooled_prompt_embeds=pooled_negative,
|
| 363 |
width=int(width),
|
| 364 |
height=int(height),
|
| 365 |
guidance_scale=float(guidance_scale),
|