Spaces:
Runtime error
Runtime error
Update generator.py
Browse files- generator.py +10 -5
generator.py
CHANGED
|
@@ -756,13 +756,15 @@ class RetroArtConverter:
|
|
| 756 |
try:
|
| 757 |
print("Encoding prompts with Compel...")
|
| 758 |
|
| 759 |
-
# --- FIX
|
| 760 |
self.pipe.text_encoder.to(self.device)
|
| 761 |
self.pipe.text_encoder_2.to(self.device)
|
|
|
|
| 762 |
|
| 763 |
-
# --- FIX
|
| 764 |
-
conditioning = self.compel(prompt
|
| 765 |
-
negative_conditioning = self.compel(negative_prompt
|
|
|
|
| 766 |
|
| 767 |
pipe_kwargs["prompt_embeds"] = conditioning[0]
|
| 768 |
pipe_kwargs["pooled_prompt_embeds"] = conditioning[1]
|
|
@@ -772,15 +774,18 @@ class RetroArtConverter:
|
|
| 772 |
print("[OK] Using Compel-encoded prompts")
|
| 773 |
except Exception as e:
|
| 774 |
print(f"Compel encoding failed, using standard prompts: {e}")
|
|
|
|
|
|
|
| 775 |
pipe_kwargs["prompt"] = prompt
|
| 776 |
pipe_kwargs["negative_prompt"] = negative_prompt
|
| 777 |
finally:
|
| 778 |
-
# --- FIX
|
| 779 |
try:
|
| 780 |
self.pipe.text_encoder.to("cpu")
|
| 781 |
self.pipe.text_encoder_2.to("cpu")
|
| 782 |
except Exception as e:
|
| 783 |
print(f"Could not move text encoders back to CPU: {e}")
|
|
|
|
| 784 |
else:
|
| 785 |
pipe_kwargs["prompt"] = prompt
|
| 786 |
pipe_kwargs["negative_prompt"] = negative_prompt
|
|
|
|
| 756 |
try:
|
| 757 |
print("Encoding prompts with Compel...")
|
| 758 |
|
| 759 |
+
# --- FIX: Move text encoders to GPU for Compel ---
|
| 760 |
self.pipe.text_encoder.to(self.device)
|
| 761 |
self.pipe.text_encoder_2.to(self.device)
|
| 762 |
+
# --- END FIX ---
|
| 763 |
|
| 764 |
+
# --- FIX: Remove 'device=self.device' argument ---
|
| 765 |
+
conditioning = self.compel(prompt)
|
| 766 |
+
negative_conditioning = self.compel(negative_prompt)
|
| 767 |
+
# --- END FIX ---
|
| 768 |
|
| 769 |
pipe_kwargs["prompt_embeds"] = conditioning[0]
|
| 770 |
pipe_kwargs["pooled_prompt_embeds"] = conditioning[1]
|
|
|
|
| 774 |
print("[OK] Using Compel-encoded prompts")
|
| 775 |
except Exception as e:
|
| 776 |
print(f"Compel encoding failed, using standard prompts: {e}")
|
| 777 |
+
import traceback
|
| 778 |
+
traceback.print_exc()
|
| 779 |
pipe_kwargs["prompt"] = prompt
|
| 780 |
pipe_kwargs["negative_prompt"] = negative_prompt
|
| 781 |
finally:
|
| 782 |
+
# --- FIX: Move text encoders back to CPU to save VRAM ---
|
| 783 |
try:
|
| 784 |
self.pipe.text_encoder.to("cpu")
|
| 785 |
self.pipe.text_encoder_2.to("cpu")
|
| 786 |
except Exception as e:
|
| 787 |
print(f"Could not move text encoders back to CPU: {e}")
|
| 788 |
+
# --- END FIX ---
|
| 789 |
else:
|
| 790 |
pipe_kwargs["prompt"] = prompt
|
| 791 |
pipe_kwargs["negative_prompt"] = negative_prompt
|