Spaces:
Runtime error
Runtime error
Update generator.py
Browse files- generator.py +12 -9
generator.py
CHANGED
|
@@ -764,22 +764,25 @@ 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
|
| 772 |
-
conditioning_batch = self.compel([prompt, negative_prompt])
|
| 773 |
-
|
| 774 |
-
# Unpack the batch results
|
| 775 |
-
|
| 776 |
-
pipe_kwargs["
|
| 777 |
-
pipe_kwargs["
|
| 778 |
-
pipe_kwargs["
|
|
|
|
| 779 |
|
| 780 |
print("[OK] Using Compel-encoded prompts")
|
| 781 |
except Exception as e:
|
| 782 |
print(f"Compel encoding failed, using standard prompts: {e}")
|
|
|
|
|
|
|
| 783 |
pipe_kwargs["prompt"] = prompt
|
| 784 |
pipe_kwargs["negative_prompt"] = negative_prompt
|
| 785 |
else:
|
|
|
|
| 764 |
pipe_kwargs["generator"] = generator
|
| 765 |
|
| 766 |
# --- START FIX: Call Compel in a single batch ---
|
| 767 |
+
if self.use_compel and self.compel is not None:
|
| 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}")
|
| 784 |
+
import traceback
|
| 785 |
+
traceback.print_exc()
|
| 786 |
pipe_kwargs["prompt"] = prompt
|
| 787 |
pipe_kwargs["negative_prompt"] = negative_prompt
|
| 788 |
else:
|