Update app.py
Browse files
app.py
CHANGED
|
@@ -1037,13 +1037,53 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 1037 |
print(f"🎯 OPTIMIERTER MODUS: Focus verändern")
|
| 1038 |
print(f" Strength: {adj_strength:.2f}, ControlNet: {controlnet_strength:.3f}")
|
| 1039 |
print(f" OpenPose: {pose_ratio*100}%, Canny: {canny_ratio*100}%")
|
| 1040 |
-
|
| 1041 |
elif mode == "environment_change":
|
| 1042 |
keep_environment = True
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
| 1046 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1047 |
else: # face_only_change
|
| 1048 |
keep_environment = True
|
| 1049 |
adj_strength = min(0.85, strength * 1.25) # Standard-Berechnung
|
|
|
|
| 1037 |
print(f"🎯 OPTIMIERTER MODUS: Focus verändern")
|
| 1038 |
print(f" Strength: {adj_strength:.2f}, ControlNet: {controlnet_strength:.3f}")
|
| 1039 |
print(f" OpenPose: {pose_ratio*100}%, Canny: {canny_ratio*100}%")
|
| 1040 |
+
|
| 1041 |
elif mode == "environment_change":
|
| 1042 |
keep_environment = True
|
| 1043 |
+
|
| 1044 |
+
# 1. OPTIMIERTE STÄRKE
|
| 1045 |
+
adj_strength = 0.6 # Festwert statt Multiplikation
|
| 1046 |
+
|
| 1047 |
+
# 2. CONTROLNET-STÄRKE ERHÖHT
|
| 1048 |
+
controlnet_strength = 0.75 # Kritisch für Hintergrundkonsistenz
|
| 1049 |
+
|
| 1050 |
+
# 3. DYNAMISCHE DEPTH:CANNY RATIO BASIEREND AUF PROMPT
|
| 1051 |
+
prompt_lower = prompt.lower()
|
| 1052 |
+
|
| 1053 |
+
# Heuristik für Naturszenen vs. Innenräume
|
| 1054 |
+
nature_keywords = ["beach", "forest", "mountain", "ocean", "sky", "field", "landscape", "nature", "outdoor"]
|
| 1055 |
+
interior_keywords = ["office", "room", "interior", "kitchen", "bedroom", "living room", "indoor", "wall", "furniture"]
|
| 1056 |
+
|
| 1057 |
+
# Standard: Deine gewünschte 90:10 Verteilung
|
| 1058 |
+
depth_ratio = 0.9
|
| 1059 |
+
canny_ratio = 0.1
|
| 1060 |
+
|
| 1061 |
+
# Anpassung für Innenräume (mehr Kantenerhalt)
|
| 1062 |
+
if any(keyword in prompt_lower for keyword in interior_keywords):
|
| 1063 |
+
depth_ratio = 0.8
|
| 1064 |
+
canny_ratio = 0.2
|
| 1065 |
+
print("🏠 Innenraum erkannt → Ratio 80:20 (Depth:Canny)")
|
| 1066 |
+
|
| 1067 |
+
# Anpassung für Naturszenen (maximale Flexibilität)
|
| 1068 |
+
elif any(keyword in prompt_lower for keyword in nature_keywords):
|
| 1069 |
+
depth_ratio = 0.95
|
| 1070 |
+
canny_ratio = 0.05
|
| 1071 |
+
print("🌳 Naturszene erkannt → Ratio 95:5 (Depth:Canny)")
|
| 1072 |
+
else:
|
| 1073 |
+
print("🎯 Standard-Ratio 90:10 (Depth:Canny)")
|
| 1074 |
+
|
| 1075 |
+
# 4. CONDITIONING SCALE BERECHNEN
|
| 1076 |
+
conditioning_scale = [
|
| 1077 |
+
controlnet_strength * depth_ratio, # Depth-Gewichtung
|
| 1078 |
+
controlnet_strength * canny_ratio # Canny-Gewichtung
|
| 1079 |
+
]
|
| 1080 |
+
|
| 1081 |
+
print(f"🎯 OPTIMIERTER MODUS: Umgebung ändern")
|
| 1082 |
+
print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
|
| 1083 |
+
print(f" Depth: {depth_ratio*100}%, Canny: {canny_ratio*100}%")
|
| 1084 |
+
print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
|
| 1085 |
+
|
| 1086 |
+
|
| 1087 |
else: # face_only_change
|
| 1088 |
keep_environment = True
|
| 1089 |
adj_strength = min(0.85, strength * 1.25) # Standard-Berechnung
|