Spaces:
Runtime error
Runtime error
Update generator.py
Browse files- generator.py +5 -6
generator.py
CHANGED
|
@@ -704,7 +704,7 @@ class RetroArtConverter:
|
|
| 704 |
else:
|
| 705 |
print("✗ MediapipeFace found no faces")
|
| 706 |
except Exception as e:
|
| 707 |
-
print(f"ERROR] MediapipeFace detection failed: {e}")
|
| 708 |
import traceback
|
| 709 |
traceback.print_exc()
|
| 710 |
else:
|
|
@@ -763,22 +763,21 @@ class RetroArtConverter:
|
|
| 763 |
|
| 764 |
pipe_kwargs["generator"] = generator
|
| 765 |
|
| 766 |
-
# --- START FIX:
|
| 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}")
|
|
|
|
| 704 |
else:
|
| 705 |
print("✗ MediapipeFace found no faces")
|
| 706 |
except Exception as e:
|
| 707 |
+
print(f"[ERROR] MediapipeFace detection failed: {e}")
|
| 708 |
import traceback
|
| 709 |
traceback.print_exc()
|
| 710 |
else:
|
|
|
|
| 763 |
|
| 764 |
pipe_kwargs["generator"] = generator
|
| 765 |
|
| 766 |
+
# --- START FIX: Correct Compel batching and slicing ---
|
|
|
|
| 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}")
|