Spaces:
Runtime error
Runtime error
Update generator.py
Browse files- generator.py +5 -4
generator.py
CHANGED
|
@@ -764,20 +764,21 @@ class RetroArtConverter:
|
|
| 764 |
pipe_kwargs["generator"] = generator
|
| 765 |
|
| 766 |
# --- START FIX: Call Compel in a single batch ---
|
| 767 |
-
|
|
|
|
| 768 |
try:
|
| 769 |
print("Encoding prompts with Compel...")
|
| 770 |
-
|
| 771 |
# Pass both prompts as a list to be batched
|
| 772 |
conditioning_batch, pooled_batch = self.compel([prompt, negative_prompt])
|
| 773 |
-
|
| 774 |
# Unpack the batch results using slicing
|
| 775 |
# [0:1] keeps the batch dimension, which is required
|
| 776 |
pipe_kwargs["prompt_embeds"] = conditioning_batch[0:1]
|
| 777 |
pipe_kwargs["pooled_prompt_embeds"] = pooled_batch[0:1]
|
| 778 |
pipe_kwargs["negative_prompt_embeds"] = conditioning_batch[1:2]
|
| 779 |
pipe_kwargs["negative_pooled_prompt_embeds"] = pooled_batch[1:2]
|
| 780 |
-
|
| 781 |
print("[OK] Using Compel-encoded prompts")
|
| 782 |
except Exception as e:
|
| 783 |
print(f"Compel encoding failed, using standard prompts: {e}")
|
|
|
|
| 764 |
pipe_kwargs["generator"] = generator
|
| 765 |
|
| 766 |
# --- START FIX: Call Compel in a single batch ---
|
| 767 |
+
# Use Compel for prompt encoding if available
|
| 768 |
+
if self.use_compel and self.compel is not None:
|
| 769 |
try:
|
| 770 |
print("Encoding prompts with Compel...")
|
| 771 |
+
|
| 772 |
# Pass both prompts as a list to be batched
|
| 773 |
conditioning_batch, pooled_batch = self.compel([prompt, negative_prompt])
|
| 774 |
+
|
| 775 |
# Unpack the batch results using slicing
|
| 776 |
# [0:1] keeps the batch dimension, which is required
|
| 777 |
pipe_kwargs["prompt_embeds"] = conditioning_batch[0:1]
|
| 778 |
pipe_kwargs["pooled_prompt_embeds"] = pooled_batch[0:1]
|
| 779 |
pipe_kwargs["negative_prompt_embeds"] = conditioning_batch[1:2]
|
| 780 |
pipe_kwargs["negative_pooled_prompt_embeds"] = pooled_batch[1:2]
|
| 781 |
+
|
| 782 |
print("[OK] Using Compel-encoded prompts")
|
| 783 |
except Exception as e:
|
| 784 |
print(f"Compel encoding failed, using standard prompts: {e}")
|