Spaces:
Runtime error
Runtime error
Update generator.py
Browse files- generator.py +18 -7
generator.py
CHANGED
|
@@ -261,13 +261,23 @@ class RetroArtConverter:
|
|
| 261 |
return Image.fromarray(depth_colored)
|
| 262 |
|
| 263 |
|
| 264 |
-
|
|
|
|
| 265 |
"""Add trigger word to prompt if not present"""
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
if not prompt or not prompt.strip():
|
| 268 |
-
return
|
| 269 |
-
|
|
|
|
| 270 |
return prompt
|
|
|
|
| 271 |
|
| 272 |
def extract_multi_scale_face(self, face_crop, face):
|
| 273 |
"""
|
|
@@ -548,8 +558,9 @@ class RetroArtConverter:
|
|
| 548 |
expression_control_scale
|
| 549 |
)
|
| 550 |
|
| 551 |
-
#
|
| 552 |
-
prompt = self.add_trigger_word(prompt)
|
|
|
|
| 553 |
|
| 554 |
# Calculate optimal size with flexible aspect ratio support
|
| 555 |
original_width, original_height = input_image.size
|
|
@@ -662,7 +673,7 @@ class RetroArtConverter:
|
|
| 662 |
facial_attrs = get_facial_attributes(face)
|
| 663 |
|
| 664 |
# Update prompt with detected attributes
|
| 665 |
-
prompt = build_enhanced_prompt(prompt, facial_attrs, TRIGGER_WORD)
|
| 666 |
|
| 667 |
# Legacy output for compatibility
|
| 668 |
age = facial_attrs['age']
|
|
|
|
| 261 |
return Image.fromarray(depth_colored)
|
| 262 |
|
| 263 |
|
| 264 |
+
# --- START FIX: Updated function to use lora_choice ---
|
| 265 |
+
def add_trigger_word(self, prompt, lora_choice="RetroArt"):
|
| 266 |
"""Add trigger word to prompt if not present"""
|
| 267 |
+
|
| 268 |
+
# Get the correct trigger word from the config dictionary
|
| 269 |
+
trigger = TRIGGER_WORD.get(lora_choice, TRIGGER_WORD["RetroArt"])
|
| 270 |
+
|
| 271 |
+
if not trigger:
|
| 272 |
+
return prompt
|
| 273 |
+
|
| 274 |
+
if trigger.lower() not in prompt.lower():
|
| 275 |
if not prompt or not prompt.strip():
|
| 276 |
+
return trigger
|
| 277 |
+
# Prepend the trigger word as requested
|
| 278 |
+
return f"{trigger}, {prompt}"
|
| 279 |
return prompt
|
| 280 |
+
# --- END FIX ---
|
| 281 |
|
| 282 |
def extract_multi_scale_face(self, face_crop, face):
|
| 283 |
"""
|
|
|
|
| 558 |
expression_control_scale
|
| 559 |
)
|
| 560 |
|
| 561 |
+
# --- START FIX: Pass lora_choice to add_trigger_word ---
|
| 562 |
+
prompt = self.add_trigger_word(prompt, lora_choice)
|
| 563 |
+
# --- END FIX ---
|
| 564 |
|
| 565 |
# Calculate optimal size with flexible aspect ratio support
|
| 566 |
original_width, original_height = input_image.size
|
|
|
|
| 673 |
facial_attrs = get_facial_attributes(face)
|
| 674 |
|
| 675 |
# Update prompt with detected attributes
|
| 676 |
+
prompt = build_enhanced_prompt(prompt, facial_attrs, TRIGGER_WORD[lora_choice])
|
| 677 |
|
| 678 |
# Legacy output for compatibility
|
| 679 |
age = facial_attrs['age']
|