Astridkraft commited on
Commit
197c2b0
·
verified ·
1 Parent(s): 6f3a829

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -88
app.py CHANGED
@@ -1421,105 +1421,36 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
1421
 
1422
 
1423
  if any(keyword in prompt_lower for keyword in anime_keywords):
1424
- print("🎨 ANIME-TRANSFORM-MODUS")
1425
-
1426
- def smoothstep(min_val, max_val, x):
1427
- x = max(0, min(1, (x - min_val) / (max_val - min_val)))
1428
- return x * x * (3 - 2 * x)
1429
-
1430
- # 1️⃣ Transformationsdruck (radikal erst spät)
1431
- adj_strength = 0.30 + 0.55 * smoothstep(0.35, 0.9, ui_strength)
1432
- adj_strength = max(0.3, min(adj_strength, 0.85))
1433
-
1434
- # 2️⃣ ControlNet: lange frei, dann stabilisieren
1435
- controlnet_strength = 0.30 + 0.52 * smoothstep(0.65, 0.9, ui_strength)
1436
- controlnet_strength = max(0.25, min(controlnet_strength, 0.85))
1437
-
1438
- # 3️⃣ Anime-Ratios (normiert!)
1439
- depth_ratio = 0.55 + 0.15 * smoothstep(0.5, 0.9, ui_strength)
1440
- canny_ratio = 1.0 - depth_ratio
1441
-
1442
- # 4️⃣ Conditioning
1443
- conditioning_scale = [
1444
- controlnet_strength * depth_ratio,
1445
- controlnet_strength * canny_ratio
1446
- ]
1447
-
1448
- print(f"UI Strength: {ui_strength}")
1449
- print(f"adj_strength: {adj_strength:.3f}")
1450
- print(f"controlnet_strength: {controlnet_strength:.3f}")
1451
- print(f"Depth: {depth_ratio*100:.1f}%, Canny: {canny_ratio*100:.1f}%")
1452
- print(f"conditioning_scale: {conditioning_scale}")
1453
-
1454
-
1455
-
1456
- if any(keyword in prompt_lower for keyword in anime_keywords):
1457
- # Anime: Mehr Denoising für Stiländerungen
1458
- adj_strength = 0.55 + (ui_strength * 0.3) # 0.2-1.0
1459
-
1460
 
1461
- if ui_strength > 0.6: # Bei radikalen Änderungen
1462
- controlnet_strength = 0.3 + (ui_strength * 0.4) # 0.3 0.66
1463
- else: # Bei milden Änderungen
1464
- controlnet_strength = 0.65 - (ui_strength * 0.3) # 0.65 → 0.35
1465
-
1466
-
1467
- # Anime: Weniger Depth, mehr Canny
1468
- depth_ratio = 0.7 - (ui_strength * 0.2) # 0.6 → 0.3
1469
- canny_ratio = 0.1 + (ui_strength * 0.1) # 0.4 → 0.8
1470
 
1471
- #Clipping
 
1472
  adj_strength = max(0.3, min(adj_strength, 0.85))
1473
- controlnet_strength = max(0.25, min(controlnet_strength, 0.75))
1474
- depth_ratio = max(0.4, min(depth_ratio, 0.8))
1475
- canny_ratio = max(0.05, min(canny_ratio, 0.15))
1476
-
1477
-
1478
- conditioning_scale = [
1479
- controlnet_strength * depth_ratio,
1480
- controlnet_strength * canny_ratio
1481
- ]
1482
-
1483
- print(" 🎨 Anime-Modus: Mehr Freiheit für Stiländerungen")
1484
- print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1485
- print(f" Depth: {depth_ratio*100}%, Canny: {canny_ratio*100}%")
1486
- print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
1487
-
1488
-
1489
- if any(keyword in prompt_lower for keyword in anime_keywords):
1490
- # Anime: Mehr Denoising für Stiländerungen
1491
- adj_strength = 0.55 + (ui_strength * 0.3) # 0.2-1.0
1492
 
 
 
 
1493
 
1494
- if ui_strength > 0.6: # Bei radikalen Änderungen
1495
- controlnet_strength = 0.3 + (ui_strength * 0.4) # 0.3 → 0.66
1496
- else: # Bei milden Änderungen
1497
- controlnet_strength = 0.65 - (ui_strength * 0.3) # 0.65 → 0.35
1498
-
1499
-
1500
- # Anime: Weniger Depth, mehr Canny
1501
- depth_ratio = 0.7 - (ui_strength * 0.2) # 0.6 → 0.3
1502
- canny_ratio = 0.1 + (ui_strength * 0.1) # 0.4 → 0.8
1503
-
1504
- #Clipping
1505
- adj_strength = max(0.3, min(adj_strength, 0.85))
1506
- controlnet_strength = max(0.25, min(controlnet_strength, 0.75))
1507
- depth_ratio = max(0.4, min(depth_ratio, 0.8))
1508
- canny_ratio = max(0.05, min(canny_ratio, 0.15))
1509
-
1510
 
 
1511
  conditioning_scale = [
1512
  controlnet_strength * depth_ratio,
1513
  controlnet_strength * canny_ratio
1514
  ]
1515
-
1516
- print(" 🎨 Anime-Modus: Mehr Freiheit für Stiländerungen")
1517
- print(f" Strength: {adj_strength}, ControlNet: {controlnet_strength}")
1518
- print(f" Depth: {depth_ratio*100}%, Canny: {canny_ratio*100}%")
1519
- print(f" Conditioning Scale: [{conditioning_scale[0]:.3f}, {conditioning_scale[1]:.3f}]")
1520
-
1521
-
1522
 
 
 
 
 
 
 
1523
 
1524
  elif any(keyword in prompt_lower for keyword in drawing_keywords):
1525
  # Weniger Denoising für anatomische Korrektheit
 
1421
 
1422
 
1423
  if any(keyword in prompt_lower for keyword in anime_keywords):
1424
+ print("🎨 ANIME-TRANSFORM-MODUS")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1425
 
1426
+ def smoothstep(min_val, max_val, x):
1427
+ x = max(0, min(1, (x - min_val) / (max_val - min_val)))
1428
+ return x * x * (3 - 2 * x)
 
 
 
 
 
 
1429
 
1430
+ # 1️⃣ Transformationsdruck (radikal erst spät)
1431
+ adj_strength = 0.30 + 0.55 * smoothstep(0.35, 0.9, ui_strength)
1432
  adj_strength = max(0.3, min(adj_strength, 0.85))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1433
 
1434
+ # 2️⃣ ControlNet: lange frei, dann stabilisieren
1435
+ controlnet_strength = 0.30 + 0.52 * smoothstep(0.65, 0.9, ui_strength)
1436
+ controlnet_strength = max(0.25, min(controlnet_strength, 0.85))
1437
 
1438
+ # 3️⃣ Anime-Ratios (normiert!)
1439
+ depth_ratio = 0.55 + 0.15 * smoothstep(0.5, 0.9, ui_strength)
1440
+ canny_ratio = 1.0 - depth_ratio
 
 
 
 
 
 
 
 
 
 
 
 
 
1441
 
1442
+ # 4️⃣ Conditioning
1443
  conditioning_scale = [
1444
  controlnet_strength * depth_ratio,
1445
  controlnet_strength * canny_ratio
1446
  ]
 
 
 
 
 
 
 
1447
 
1448
+ print(f"UI Strength: {ui_strength}")
1449
+ print(f"adj_strength: {adj_strength:.3f}")
1450
+ print(f"controlnet_strength: {controlnet_strength:.3f}")
1451
+ print(f"Depth: {depth_ratio*100:.1f}%, Canny: {canny_ratio*100:.1f}%")
1452
+ print(f"conditioning_scale: {conditioning_scale}")
1453
+
1454
 
1455
  elif any(keyword in prompt_lower for keyword in drawing_keywords):
1456
  # Weniger Denoising für anatomische Korrektheit