Astridkraft commited on
Commit
3f045c5
·
verified ·
1 Parent(s): 1332dda

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +21 -8
controlnet_module.py CHANGED
@@ -259,17 +259,26 @@ class ControlNetProcessor:
259
  steps, guidance_scale, controlnet_strength,
260
  progress=None, keep_environment=False
261
  ):
262
- """Generiert Bild mit ControlNet und Fortschrittsanzeige"""
 
 
 
 
 
 
 
 
 
263
  try:
264
- # --- KORRIGIERTE LOGIK FÜR KONSISTENZ MIT APP.PY ---
265
  if keep_environment:
266
- # OUTSIDE-BOX ÄNDERN (Umgebung bleibt erhalten) → Depth + Canny
267
- print("🎯 ControlNet Modus: Outside-Box ändern (Depth + Canny)")
268
 
269
  # Beide Conditioning Maps erstellen
270
  depth_image = self.extract_depth_map(image)
271
  canny_image = self.extract_canny_edges(image)
272
- print("✅ Depth + Canny Maps für Outside-Box erstellt")
273
 
274
  # Multi-ControlNet für Outside verwenden
275
  conditioning_images = [depth_image, canny_image]
@@ -280,8 +289,8 @@ class ControlNetProcessor:
280
  controlnet_strength * 0.4] # Canny: 40% für Strukturen
281
 
282
  else:
283
- # INSIDE-BOX ÄNDERN (Person bleibt erhalten) → OpenPose + Canny
284
- print("🎯 ControlNet Modus: Inside-Box ändern (OpenPose + Canny)")
285
 
286
  # Beide Conditioning Maps erstellen
287
  pose_image = self.extract_pose(image)
@@ -326,7 +335,8 @@ class ControlNetProcessor:
326
 
327
  print("✅ ControlNet abgeschlossen!")
328
 
329
- return result.images[0], image # ControlNet-Output + Originalbild
 
330
 
331
  except Exception as e:
332
  print(f"❌ Fehler in ControlNet: {e}")
@@ -339,6 +349,9 @@ class ControlNetProcessor:
339
  """
340
  Bereitet das Input-Bild für Inpaint vor
341
  Rückgabe: (image_für_inpaint, conditioning_info)
 
 
 
342
  """
343
  if keep_environment:
344
  # OUTSIDE-BOX ÄNDERN: Depth+Canny Info für Umgebung
 
259
  steps, guidance_scale, controlnet_strength,
260
  progress=None, keep_environment=False
261
  ):
262
+ """
263
+ GENERIERT BILD MIT CONTROLNET
264
+ WICHTIG: Diese Funktion wird von app.py aufgerufen
265
+
266
+ Parameter keep_environment bestimmt:
267
+ - True: "Umgebung ändern" und "Ausschließlich Gesicht" → Depth+Canny
268
+ - False: "Focus verändern" → OpenPose+Canny
269
+
270
+ Die eigentliche Maskenlogik wird in app.py (create_face_mask) gehandhabt
271
+ """
272
  try:
273
+ # --- LOGIK FÜR 3 MODI (VON APP.PY GESTEUERT) ---
274
  if keep_environment:
275
+ # FALL 1 & 3: Umgebung ändern ODER Ausschließlich Gesicht → Depth + Canny
276
+ print("🎯 ControlNet: Depth + Canny (keep_environment=True)")
277
 
278
  # Beide Conditioning Maps erstellen
279
  depth_image = self.extract_depth_map(image)
280
  canny_image = self.extract_canny_edges(image)
281
+ print("✅ Depth + Canny Maps für Outside/Inside-Box erstellt")
282
 
283
  # Multi-ControlNet für Outside verwenden
284
  conditioning_images = [depth_image, canny_image]
 
289
  controlnet_strength * 0.4] # Canny: 40% für Strukturen
290
 
291
  else:
292
+ # FALL 2: Focus verändern → OpenPose + Canny
293
+ print("🎯 ControlNet: OpenPose + Canny (keep_environment=False)")
294
 
295
  # Beide Conditioning Maps erstellen
296
  pose_image = self.extract_pose(image)
 
335
 
336
  print("✅ ControlNet abgeschlossen!")
337
 
338
+ # Rückgabe: ControlNet-Output + Originalbild (für Inpaint)
339
+ return result.images[0], image
340
 
341
  except Exception as e:
342
  print(f"❌ Fehler in ControlNet: {e}")
 
349
  """
350
  Bereitet das Input-Bild für Inpaint vor
351
  Rückgabe: (image_für_inpaint, conditioning_info)
352
+
353
+ HINWEIS: Diese Funktion wird nicht direkt von app.py verwendet,
354
+ da die Logik in generate_with_controlnet enthalten ist.
355
  """
356
  if keep_environment:
357
  # OUTSIDE-BOX ÄNDERN: Depth+Canny Info für Umgebung