Astridkraft commited on
Commit
36daa31
·
verified ·
1 Parent(s): 286fca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -15
app.py CHANGED
@@ -11,22 +11,34 @@ import tempfile
11
  import random
12
  import re
13
 
14
- # === FACE-FIX IMPORT (korrigierte Version) ===
 
15
  try:
16
- # Versuche verschiedene Import-Möglichkeiten
 
 
 
 
 
17
  try:
18
- from controlnet_facefix import apply_facefix
19
- except ImportError:
20
- # Alternative Import-Methode
21
  import sys
22
  sys.path.append(".")
23
  from controlnet_facefix import apply_facefix
24
-
25
- FACEFIX_AVAILABLE = True
26
- print("Face-Fix erfolgreich geladen")
 
 
 
 
27
  except Exception as e:
28
- print(f"Face-Fix nicht verfügbar: {e}")
29
  FACEFIX_AVAILABLE = False
 
 
 
 
30
 
31
  # === OPTIMIERTE EINSTELLUNGEN ===
32
  device = "cuda" if torch.cuda.is_available() else "cpu"
@@ -97,15 +109,24 @@ def auto_negative_prompt(positive_prompt):
97
  base_negatives = "low quality, worst quality, blurry, jpeg artifacts, ugly, deformed"
98
 
99
  return base_negatives + ", " + ", ".join(negatives) if negatives else base_negatives
 
100
 
101
- # === PERSONEN-ERKENNUNG (für Face-Fix) ===
102
  def is_person_prompt(prompt: str) -> bool:
103
  p = prompt.lower()
104
- person_keywords = [
105
- "person", "man", "woman", "face", "portrait", "people", "child", "girl", "boy",
106
- "fairy", "elf", "witch", "santa", "nikolaus", "human", "character", "figure"
107
- ]
108
- return any(w in p for w in person_keywords)
 
 
 
 
 
 
 
 
 
109
 
110
  # === GESICHTSMASKEN-FUNKTIONEN ===
111
  def create_face_mask(image, bbox_coords, face_preserve):
 
11
  import random
12
  import re
13
 
14
+
15
+ # === FACE-FIX IMPORT - MIT DETAILLIERTEM DEBUGGING ===
16
  try:
17
+ print("Versuch 1: Importiere controlnet_facefix...")
18
+ from controlnet_facefix import apply_facefix
19
+ FACEFIX_AVAILABLE = True
20
+ print("✅ Face-Fix erfolgreich geladen")
21
+ except ImportError as e1:
22
+ print(f"❌ ImportError: {e1}")
23
  try:
24
+ print("Versuch 2: Import mit sys.path...")
 
 
25
  import sys
26
  sys.path.append(".")
27
  from controlnet_facefix import apply_facefix
28
+ FACEFIX_AVAILABLE = True
29
+ print("✅ Face-Fix erfolgreich geladen (mit sys.path)")
30
+ except Exception as e2:
31
+ print(f"❌ Endgültiger Fehler: {e2}")
32
+ FACEFIX_AVAILABLE = False
33
+ import traceback
34
+ traceback.print_exc()
35
  except Exception as e:
36
+ print(f" Anderer Fehler: {e}")
37
  FACEFIX_AVAILABLE = False
38
+ import traceback
39
+ traceback.print_exc()
40
+
41
+
42
 
43
  # === OPTIMIERTE EINSTELLUNGEN ===
44
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
109
  base_negatives = "low quality, worst quality, blurry, jpeg artifacts, ugly, deformed"
110
 
111
  return base_negatives + ", " + ", ".join(negatives) if negatives else base_negatives
112
+
113
 
 
114
  def is_person_prompt(prompt: str) -> bool:
115
  p = prompt.lower()
116
+ print(f"DEBUG: Prüfe '{p}' auf Personen...")
117
+
118
+ # EINFACHE Version die garantiert funktioniert:
119
+ keywords = ["fairy", "person", "man", "woman", "face", "portrait"]
120
+
121
+ for keyword in keywords:
122
+ if keyword in p: # Einfach 'in' ohne Leerzeichen
123
+ print(f"✅ Person erkannt durch '{keyword}'")
124
+ return True
125
+
126
+ print(f"❌ Keine Person erkannt")
127
+ return False
128
+
129
+
130
 
131
  # === GESICHTSMASKEN-FUNKTIONEN ===
132
  def create_face_mask(image, bbox_coords, face_preserve):