Update app.py
Browse files
app.py
CHANGED
|
@@ -1017,32 +1017,73 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 1017 |
########################################################################
|
| 1018 |
if mode == "focus_change":
|
| 1019 |
keep_environment = False
|
| 1020 |
-
|
| 1021 |
-
# OPTIMIERTE WERTE FÜR FOCUS_CHANGE
|
| 1022 |
-
adj_strength = min(0.6, strength * 1.05) # Konservativer (0.65)
|
| 1023 |
-
controlnet_weight = 0.85 # Stärkere ControlNet-Kontrolle
|
| 1024 |
-
|
| 1025 |
-
#Controlnet gesteuertes Inpainting
|
| 1026 |
-
pose_ratio = 0.8 # OpenPose dominiert
|
| 1027 |
-
canny_ratio = 0.2 # Canny unterstützt
|
| 1028 |
|
| 1029 |
-
#
|
| 1030 |
-
|
| 1031 |
-
|
| 1032 |
-
|
| 1033 |
-
|
| 1034 |
-
|
| 1035 |
-
|
| 1036 |
-
|
| 1037 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1038 |
conditioning_scale = [
|
| 1039 |
-
controlnet_strength * pose_ratio, #
|
| 1040 |
-
controlnet_strength * canny_ratio #
|
| 1041 |
]
|
| 1042 |
-
|
| 1043 |
-
print(f"🎯
|
| 1044 |
-
print(f" Strength: {adj_strength
|
| 1045 |
print(f" OpenPose: {pose_ratio*100}%, Canny: {canny_ratio*100}%")
|
|
|
|
|
|
|
| 1046 |
|
| 1047 |
elif mode == "environment_change":
|
| 1048 |
keep_environment = True
|
|
|
|
| 1017 |
########################################################################
|
| 1018 |
if mode == "focus_change":
|
| 1019 |
keep_environment = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1020 |
|
| 1021 |
+
# 1. DENOISING-STÄRKE
|
| 1022 |
+
adj_strength = min(0.6, strength)
|
| 1023 |
+
|
| 1024 |
+
# 2. CONTROLNET-STÄRKE (wie environment_change)
|
| 1025 |
+
controlnet_strength = 0.5 # Stärkere ControlNet-Kontrolle für Focus
|
| 1026 |
+
|
| 1027 |
+
# 3. DYNAMISCHE POSE:CANNY RATIO BASIEREND AUF PROMPT
|
| 1028 |
+
prompt_lower = prompt.lower()
|
| 1029 |
+
|
| 1030 |
+
# Keyword-Gruppen
|
| 1031 |
+
humanoid_keywords = [
|
| 1032 |
+
"anime", "cartoon", "manga", "witch", "wizard", "sorcerer",
|
| 1033 |
+
"alien", "elf", "fairy", "character", "fantasy", "superhero",
|
| 1034 |
+
"cyborg", "robot", "android", "santa", "person", "woman", "man",
|
| 1035 |
+
"girl", "boy", "child", "business", "suit", "professional",
|
| 1036 |
+
"sports", "athlete", "runner", "dancer", "portrait", "face"
|
| 1037 |
+
]
|
| 1038 |
+
|
| 1039 |
+
object_keywords = [
|
| 1040 |
+
"car", "vehicle", "automobile", "chair", "table", "desk",
|
| 1041 |
+
"statue", "sculpture", "monument", "lamp", "bottle", "vase",
|
| 1042 |
+
"product", "object", "furniture", "device", "tool", "item",
|
| 1043 |
+
"building", "house", "tree", "plant", "rock", "stone"
|
| 1044 |
+
]
|
| 1045 |
+
|
| 1046 |
+
animal_keywords = [
|
| 1047 |
+
"dog", "cat", "wolf", "lion", "tiger", "bear", "rabbit",
|
| 1048 |
+
"horse", "bird", "animal", "creature", "beast", "monkey",
|
| 1049 |
+
"elephant", "giraffe", "zebra", "deer", "fox", "pet"
|
| 1050 |
+
]
|
| 1051 |
+
|
| 1052 |
+
# Standard-Ratio
|
| 1053 |
+
pose_ratio = 0.7 # 70%
|
| 1054 |
+
canny_ratio = 0.3 # 30%
|
| 1055 |
+
|
| 1056 |
+
# Anpassung für Humanoid → Humanoid
|
| 1057 |
+
if any(keyword in prompt_lower for keyword in humanoid_keywords):
|
| 1058 |
+
pose_ratio = 0.90 # 85% Pose
|
| 1059 |
+
canny_ratio = 0.10 # 15% Canny
|
| 1060 |
+
print("👤 Humanoid → Humanoid → Ratio 85:15 (Pose:Canny)")
|
| 1061 |
+
|
| 1062 |
+
# Anpassung für Gegenstand → Gegenstand
|
| 1063 |
+
elif any(keyword in prompt_lower for keyword in object_keywords):
|
| 1064 |
+
pose_ratio = 0.20 # 25% Pose
|
| 1065 |
+
canny_ratio = 0.80 # 75% Canny
|
| 1066 |
+
adj_strength = min(0.7, strength * 1.15) # Stärkere Transformation
|
| 1067 |
+
print("📦 Gegenstand → Gegenstand → Ratio 25:75 (Pose:Canny)")
|
| 1068 |
+
|
| 1069 |
+
# Anpassung für Mensch → Tier
|
| 1070 |
+
elif any(keyword in prompt_lower for keyword in animal_keywords):
|
| 1071 |
+
pose_ratio = 0.5 # 50% Pose
|
| 1072 |
+
canny_ratio = 0.5 # 50% Canny
|
| 1073 |
+
adj_strength = min(0.65, strength * 1.1) # Etwas stärker
|
| 1074 |
+
print("🐾 Mensch → Tier → Ratio 50:50 (Pose:Canny)")
|
| 1075 |
+
|
| 1076 |
+
# CONDITIONING SCALE BERECHNEN (genau wie environment_change)
|
| 1077 |
conditioning_scale = [
|
| 1078 |
+
controlnet_strength * pose_ratio, # OpenPose
|
| 1079 |
+
controlnet_strength * canny_ratio # Canny
|
| 1080 |
]
|
| 1081 |
+
|
| 1082 |
+
print(f"🎯 MODUS: Focus verändern")
|
| 1083 |
+
print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
|
| 1084 |
print(f" OpenPose: {pose_ratio*100}%, Canny: {canny_ratio*100}%")
|
| 1085 |
+
print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
|
| 1086 |
+
|
| 1087 |
|
| 1088 |
elif mode == "environment_change":
|
| 1089 |
keep_environment = True
|