Update app.py
Browse files
app.py
CHANGED
|
@@ -1419,6 +1419,88 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
|
|
| 1419 |
drawing_keywords = ["drawing", "illustration", "sketch", "painting", "artwork", "watercolor"]
|
| 1420 |
|
| 1421 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1422 |
|
| 1423 |
if any(keyword in prompt_lower for keyword in anime_keywords):
|
| 1424 |
print("🎨 ANIME-TRANSFORM-MODUS")
|
|
|
|
| 1419 |
drawing_keywords = ["drawing", "illustration", "sketch", "painting", "artwork", "watercolor"]
|
| 1420 |
|
| 1421 |
|
| 1422 |
+
|
| 1423 |
+
# Anime-Stile
|
| 1424 |
+
anime_keywords = ["anime", "manga", "cartoon", "character", "chibi", "cel-shading", "lineart"]
|
| 1425 |
+
|
| 1426 |
+
|
| 1427 |
+
front_face_keywords = [
|
| 1428 |
+
"portrait", "face", "eyes", "smile", "lips", "nose", "expression",
|
| 1429 |
+
"looking at camera", "frontal view", "headshot", "selfie", "close-up",
|
| 1430 |
+
"profile", "side view", "front", "frontal", "facing camera"
|
| 1431 |
+
]
|
| 1432 |
+
|
| 1433 |
+
back_head_keywords = [
|
| 1434 |
+
"back of head", "from behind", "rear view", "looking away",
|
| 1435 |
+
"turned away", "back view", "backside", "back", "rear",
|
| 1436 |
+
"hair only", "ponytail", "hairstyle", "hair", "back hair"
|
| 1437 |
+
]
|
| 1438 |
+
|
| 1439 |
+
# Bestimme ob Gesicht vorne oder Hinterkopf
|
| 1440 |
+
is_front_face = any(keyword in prompt_lower for keyword in front_face_keywords)
|
| 1441 |
+
is_back_head = any(keyword in prompt_lower for keyword in back_head_keywords)
|
| 1442 |
+
|
| 1443 |
+
# Fallback: Wenn keine spezifischen Keywords, annehmen es ist Gesicht
|
| 1444 |
+
if not is_front_face and not is_back_head:
|
| 1445 |
+
is_front_face = True # Standard: Gesicht vorne
|
| 1446 |
+
print(" ℹ️ Keine Gesicht/Hinterkopf-Keywords → Standard: Gesicht vorne")
|
| 1447 |
+
|
| 1448 |
+
print(f" 🎯 Gesichtserkennung: Vorne={is_front_face}, Hinten={is_back_head}")
|
| 1449 |
+
|
| 1450 |
+
if any(keyword in prompt_lower for keyword in anime_keywords):
|
| 1451 |
+
print("🎨 ANIME-TRANSFORM-MODUS")
|
| 1452 |
+
|
| 1453 |
+
def smoothstep(min_val, max_val, x):
|
| 1454 |
+
x = max(0, min(1, (x - min_val) / (max_val - min_val)))
|
| 1455 |
+
return x * x * (3 - 2 * x)
|
| 1456 |
+
|
| 1457 |
+
# Basiseinstellungen für Anime
|
| 1458 |
+
adj_strength = 0.30 + 0.55 * smoothstep(0.35, 0.9, ui_strength)
|
| 1459 |
+
adj_strength = max(0.3, min(adj_strength, 0.85))
|
| 1460 |
+
|
| 1461 |
+
controlnet_strength = 0.30 + 0.52 * smoothstep(0.65, 0.9, ui_strength)
|
| 1462 |
+
controlnet_strength = max(0.25, min(controlnet_strength, 0.85))
|
| 1463 |
+
|
| 1464 |
+
# ANPASSUNG BASIEREND AUF GESICHT/HINTERKOPF
|
| 1465 |
+
if is_front_face:
|
| 1466 |
+
# Anime-GESICHT vorne
|
| 1467 |
+
depth_ratio = 0.65 + 0.15 * smoothstep(0.5, 0.9, ui_strength) # Höher für Gesichtsstruktur
|
| 1468 |
+
canny_ratio = 1.0 - depth_ratio
|
| 1469 |
+
print(" 👤 Anime-Gesicht (vorne): Mehr Depth für 3D-Struktur")
|
| 1470 |
+
|
| 1471 |
+
elif is_back_head:
|
| 1472 |
+
# Anime-HINTERKOPF
|
| 1473 |
+
depth_ratio = 0.35 + 0.15 * smoothstep(0.5, 0.9, ui_strength) # Niedriger
|
| 1474 |
+
canny_ratio = 1.0 - depth_ratio
|
| 1475 |
+
print(" 💇 Anime-Hinterkopf: Mehr Canny für Haarkontur")
|
| 1476 |
+
else:
|
| 1477 |
+
# Standard-Anime (Fallback)
|
| 1478 |
+
depth_ratio = 0.55 + 0.15 * smoothstep(0.5, 0.9, ui_strength)
|
| 1479 |
+
canny_ratio = 1.0 - depth_ratio
|
| 1480 |
+
|
| 1481 |
+
conditioning_scale = [
|
| 1482 |
+
controlnet_strength * depth_ratio,
|
| 1483 |
+
controlnet_strength * canny_ratio
|
| 1484 |
+
]
|
| 1485 |
+
|
| 1486 |
+
|
| 1487 |
+
|
| 1488 |
+
|
| 1489 |
+
|
| 1490 |
+
|
| 1491 |
+
|
| 1492 |
+
|
| 1493 |
+
|
| 1494 |
+
|
| 1495 |
+
|
| 1496 |
+
|
| 1497 |
+
|
| 1498 |
+
|
| 1499 |
+
|
| 1500 |
+
|
| 1501 |
+
|
| 1502 |
+
|
| 1503 |
+
|
| 1504 |
|
| 1505 |
if any(keyword in prompt_lower for keyword in anime_keywords):
|
| 1506 |
print("🎨 ANIME-TRANSFORM-MODUS")
|