Update app.py
Browse files
app.py
CHANGED
|
@@ -631,6 +631,8 @@ def text_to_image(prompt, model_id, steps, guidance_scale, progress=gr.Progress(
|
|
| 631 |
traceback.print_exc()
|
| 632 |
return None, error_msg
|
| 633 |
|
|
|
|
|
|
|
| 634 |
def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
| 635 |
mode, bbox_x1, bbox_y1, bbox_x2, bbox_y2,
|
| 636 |
progress=gr.Progress()):
|
|
@@ -704,17 +706,17 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 704 |
if mode == "face_only_change":
|
| 705 |
# Gesichtsspezifische Booster hinzufügen
|
| 706 |
face_boosters = "(perfect face:1.2), (symmetrical face:1.1), realistic shaded perfect face, "
|
| 707 |
-
|
| 708 |
-
|
| 709 |
-
|
| 710 |
-
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
|
| 715 |
-
|
| 716 |
else:
|
| 717 |
-
# Für andere Modi: Normaler Prompt
|
| 718 |
enhanced_prompt = prompt
|
| 719 |
|
| 720 |
print(f"🎯 Finaler Prompt für {mode}: {enhanced_prompt}")
|
|
@@ -749,13 +751,13 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 749 |
# ===== CONTROLNET AUFRUF =====
|
| 750 |
controlnet_output, inpaint_input = controlnet_processor.generate_with_controlnet(
|
| 751 |
image=image,
|
| 752 |
-
prompt=
|
| 753 |
negative_prompt=combined_negative_prompt,
|
| 754 |
steps=controlnet_steps,
|
| 755 |
guidance_scale=guidance_scale,
|
| 756 |
controlnet_strength=controlnet_strength,
|
| 757 |
-
progress=None,
|
| 758 |
-
keep_environment=keep_environment
|
| 759 |
)
|
| 760 |
|
| 761 |
print(f"✅ ControlNet Output erhalten: {type(controlnet_output)}")
|
|
@@ -811,7 +813,7 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 811 |
|
| 812 |
# ===== INPAINT DURCHFÜHREN =====
|
| 813 |
result = pipe(
|
| 814 |
-
prompt=
|
| 815 |
negative_prompt=combined_negative_prompt,
|
| 816 |
image=img_resized,
|
| 817 |
mask_image=mask,
|
|
@@ -837,6 +839,7 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 837 |
import traceback
|
| 838 |
traceback.print_exc()
|
| 839 |
return None
|
|
|
|
| 840 |
|
| 841 |
def update_bbox_from_image(image):
|
| 842 |
"""Aktualisiert die Bounding-Box-Koordinaten wenn ein Bild hochgeladen wird"""
|
|
|
|
| 631 |
traceback.print_exc()
|
| 632 |
return None, error_msg
|
| 633 |
|
| 634 |
+
|
| 635 |
+
|
| 636 |
def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
| 637 |
mode, bbox_x1, bbox_y1, bbox_x2, bbox_y2,
|
| 638 |
progress=gr.Progress()):
|
|
|
|
| 706 |
if mode == "face_only_change":
|
| 707 |
# Gesichtsspezifische Booster hinzufügen
|
| 708 |
face_boosters = "(perfect face:1.2), (symmetrical face:1.1), realistic shaded perfect face, "
|
| 709 |
+
|
| 710 |
+
# Prüfen ob Prompts schon gewichtete Face-Booster haben
|
| 711 |
+
if not any(keyword in prompt.lower() for keyword in
|
| 712 |
+
["perfect face", "symmetrical", "realistic face", "shaded face"]):
|
| 713 |
+
enhanced_prompt = face_boosters + prompt
|
| 714 |
+
print(f"👤 Gesichts-Booster hinzugefügt: {face_boosters}")
|
| 715 |
+
else:
|
| 716 |
+
enhanced_prompt = prompt
|
| 717 |
+
print(f"👤 Benutzer hat bereits Gesichts-Booster im Prompt")
|
| 718 |
else:
|
| 719 |
+
# Für andere Modi: Normaler Prompt
|
| 720 |
enhanced_prompt = prompt
|
| 721 |
|
| 722 |
print(f"🎯 Finaler Prompt für {mode}: {enhanced_prompt}")
|
|
|
|
| 751 |
# ===== CONTROLNET AUFRUF =====
|
| 752 |
controlnet_output, inpaint_input = controlnet_processor.generate_with_controlnet(
|
| 753 |
image=image,
|
| 754 |
+
prompt=enhanced_prompt, # WICHTIG: enhanced_prompt verwenden!
|
| 755 |
negative_prompt=combined_negative_prompt,
|
| 756 |
steps=controlnet_steps,
|
| 757 |
guidance_scale=guidance_scale,
|
| 758 |
controlnet_strength=controlnet_strength,
|
| 759 |
+
progress=None, # kein Progress an ControlNet
|
| 760 |
+
keep_environment=keep_environment
|
| 761 |
)
|
| 762 |
|
| 763 |
print(f"✅ ControlNet Output erhalten: {type(controlnet_output)}")
|
|
|
|
| 813 |
|
| 814 |
# ===== INPAINT DURCHFÜHREN =====
|
| 815 |
result = pipe(
|
| 816 |
+
prompt=enhanced_prompt, # WICHTIG: enhanced_prompt verwenden!
|
| 817 |
negative_prompt=combined_negative_prompt,
|
| 818 |
image=img_resized,
|
| 819 |
mask_image=mask,
|
|
|
|
| 839 |
import traceback
|
| 840 |
traceback.print_exc()
|
| 841 |
return None
|
| 842 |
+
|
| 843 |
|
| 844 |
def update_bbox_from_image(image):
|
| 845 |
"""Aktualisiert die Bounding-Box-Koordinaten wenn ein Bild hochgeladen wird"""
|