Astridkraft commited on
Commit
444aa66
·
verified ·
1 Parent(s): 733d6f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -27
app.py CHANGED
@@ -1236,8 +1236,7 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
1236
 
1237
  # CONTROLNET-STÄRKE
1238
  controlnet_strength = 0.55 #Inpaint kann bei Neugenerierung nicht so viel Kontrolle vertragen
1239
-
1240
-
1241
  depth_ratio = 0.50 # 35%
1242
  canny_ratio = 0.12 # 10%
1243
 
@@ -1249,32 +1248,36 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
1249
 
1250
  # Anpassung für Innenräume (mehr Kantenerhalt)
1251
  if any(keyword in prompt_lower for keyword in interior_keywords):
1252
- adj_strength = 0.75
1253
- controlnet_strength = 0.55
1254
- depth_ratio = 0.55
1255
- canny_ratio = 0.20
1256
-
 
1257
  conditioning_scale = [
1258
- controlnet_strength * depth_ratio, # Depth-Gewichtung
1259
- controlnet_strength * canny_ratio # Canny-Gewichtung
1260
  ]
1261
-
1262
- print("🏠 Innenraum erkannt → Ratio 80:20 (Depth:Canny)")
 
 
 
1263
 
1264
 
1265
  # Anpassung für Naturszenen (maximale Flexibilität) - die optimalen UI-Werte: strength:0,72 , steps: 35 , guidance: 9-9,5
1266
  elif any(keyword in prompt_lower for keyword in nature_keywords):
1267
 
1268
  # 1. DENOISING: Radikaler bei Naturszenen (Wald→Wüste)
1269
- adj_strength = 0.3 + (ui_strength * 0.5) # 0.3-0.8
1270
 
1271
  # 2. CONTROLNET: WENIGER bei Naturszenen (mehr Freiheit)
1272
  controlnet_strength = 0.3 + (ui_strength * 0.3) # 0.3-0.6
1273
 
1274
  # 3. RATIOS: WENIG Canny (Kanten stören bei Naturveränderung)
1275
  # MEHR Depth (Maßstab/Tiefe erhalten)
1276
- depth_ratio = 0.8 - (ui_strength * 0.3) # 0.8-0.5
1277
- canny_ratio = 1.0 - depth_ratio # 0.2-0.5
1278
 
1279
  conditioning_scale = [
1280
  controlnet_strength * depth_ratio,
@@ -1282,16 +1285,9 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
1282
  ]
1283
 
1284
  print(f"🌳 NATURSZENE: UI={ui_strength:.2f}")
1285
- print(f" Radikaler Hintergrundwechsel möglich")
1286
  print(f" Depth: {depth_ratio*100:.0f}% (Maßstab), Canny: {canny_ratio*100:.0f}%")
1287
-
1288
-
1289
- #bisherige
1290
- #adj_strength = 0.75 #wie stark das bestehende Bild überschrieben wird im kompletten Denoising-Prozess-also Strukturveränderung
1291
- #controlnet_strength = 0.3
1292
- #depth_ratio = 0.15 #Depth-Wert hält Maßstab und Boden (Emi groß, Liege klein - Emi im Meer)
1293
- #canny_ratio = 0.00 #erzwingt Kanten - hält dadurch an alter Umgebung fest - schlecht bei Umgebungswechsel
1294
-
1295
 
1296
  else:
1297
  print("🎯 Standard-Ratio 90:10 (Depth:Canny)")
@@ -1302,10 +1298,10 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
1302
  controlnet_strength * canny_ratio # Canny-Gewichtung
1303
  ]
1304
 
1305
- print(f"🎯 OPTIMIERTER MODUS: Umgebung ändern")
1306
- print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1307
- print(f" Depth: {depth_ratio*100}%, Canny: {canny_ratio*100}%")
1308
- print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
1309
 
1310
 
1311
  else: # face_only_change
 
1236
 
1237
  # CONTROLNET-STÄRKE
1238
  controlnet_strength = 0.55 #Inpaint kann bei Neugenerierung nicht so viel Kontrolle vertragen
1239
+
 
1240
  depth_ratio = 0.50 # 35%
1241
  canny_ratio = 0.12 # 10%
1242
 
 
1248
 
1249
  # Anpassung für Innenräume (mehr Kantenerhalt)
1250
  if any(keyword in prompt_lower for keyword in interior_keywords):
1251
+ # Vorherige Formel für exakten Objektschutz
1252
+ adj_strength = 0.2 + (ui_strength * 0.5)
1253
+ controlnet_strength = 0.7 + (ui_strength * 0.2)
1254
+ canny_ratio = 0.8 + (ui_strength * 0.1)
1255
+ depth_ratio = 1.0 - canny_ratio
1256
+
1257
  conditioning_scale = [
1258
+ controlnet_strength * depth_ratio,
1259
+ controlnet_strength * canny_ratio
1260
  ]
1261
+
1262
+ print(f"🏠 INNENRÄUME: UI={ui_strength:.2f}")
1263
+ print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1264
+ print(f" Depth: {depth_ratio*100:.0f}% (Maßstab), Canny: {canny_ratio*100:.0f}%")
1265
+ print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
1266
 
1267
 
1268
  # Anpassung für Naturszenen (maximale Flexibilität) - die optimalen UI-Werte: strength:0,72 , steps: 35 , guidance: 9-9,5
1269
  elif any(keyword in prompt_lower for keyword in nature_keywords):
1270
 
1271
  # 1. DENOISING: Radikaler bei Naturszenen (Wald→Wüste)
1272
+ adj_strength = 0.3 + (ui_strength * 0.5) # wie stark das bestehende Bild überschrieben wird im kompletten Denoising-Prozess-also Strukturveränderung
1273
 
1274
  # 2. CONTROLNET: WENIGER bei Naturszenen (mehr Freiheit)
1275
  controlnet_strength = 0.3 + (ui_strength * 0.3) # 0.3-0.6
1276
 
1277
  # 3. RATIOS: WENIG Canny (Kanten stören bei Naturveränderung)
1278
  # MEHR Depth (Maßstab/Tiefe erhalten)
1279
+ depth_ratio = 0.8 - (ui_strength * 0.3) # Depth-Wert hält Maßstab und Boden (Emi groß, Liege klein - Emi im Meer)
1280
+ canny_ratio = 1.0 - depth_ratio # erzwingt Kanten - hält dadurch an alter Umgebung fest - schlecht bei Umgebungswechsel
1281
 
1282
  conditioning_scale = [
1283
  controlnet_strength * depth_ratio,
 
1285
  ]
1286
 
1287
  print(f"🌳 NATURSZENE: UI={ui_strength:.2f}")
1288
+ print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1289
  print(f" Depth: {depth_ratio*100:.0f}% (Maßstab), Canny: {canny_ratio*100:.0f}%")
1290
+ print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
 
 
 
 
 
 
 
1291
 
1292
  else:
1293
  print("🎯 Standard-Ratio 90:10 (Depth:Canny)")
 
1298
  controlnet_strength * canny_ratio # Canny-Gewichtung
1299
  ]
1300
 
1301
+ print(f"🎯 STANDARD MODUS: Umgebung ändern")
1302
+ print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1303
+ print(f" Depth: {depth_ratio*100}%, Canny: {canny_ratio*100}%")
1304
+ print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
1305
 
1306
 
1307
  else: # face_only_change