Astridkraft commited on
Commit
4f64838
·
verified ·
1 Parent(s): ffb4be7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -464,20 +464,25 @@ def load_txt2img(model_id):
464
  raise
465
 
466
  def load_img2img():
467
- """Lädt ControlNet-Inpainting-Pipeline"""
468
  global pipe_img2img
469
  if pipe_img2img is None:
470
- print("🔄 Lade ControlNet-Inpainting-Modell...")
471
  try:
472
- # WICHTIG: Nur EIN ControlNet laden (Canny) für die neue Pipeline
473
- controlnet = ControlNetModel.from_pretrained(
 
 
 
 
474
  "lllyasviel/sd-controlnet-canny",
475
  torch_dtype=torch_dtype
476
  )
477
 
 
478
  pipe_img2img = StableDiffusionControlNetInpaintPipeline.from_pretrained(
479
  "runwayml/stable-diffusion-v1-5",
480
- controlnet=controlnet,
481
  torch_dtype=torch_dtype,
482
  safety_checker=None,
483
  requires_safety_checker=False
@@ -490,22 +495,19 @@ def load_img2img():
490
  use_karras_sigmas=True,
491
  timestep_spacing="trailing"
492
  )
493
-
494
- print("✅ DPMSolver++ Multistep Scheduler für ControlNet-Inpainting konfiguriert")
495
 
496
  except Exception as e:
497
- print(f"❌ Fehler beim Laden des ControlNet-Inpainting-Modells: {e}")
498
  raise
499
 
500
  # Optimierungen
501
  pipe_img2img.enable_attention_slicing()
502
- pipe_img2img.enable_vae_tiling()
503
- if hasattr(pipe_img2img, 'vae_slicing'):
504
- pipe_img2img.vae_slicing = True
505
- print("✅ ControlNet-Inpainting-Modell geladen und optimiert")
506
 
507
  return pipe_img2img
508
 
 
509
 
510
  #Die Callback-Funktion wird von der Pipeline nach jedem Verarbeitungsschritt aufgerufen und erhält Informationen
511
  #wie den aktuellen step und timestep. Diese nutzt der Progressbalken-Callback, um den Fortschritt zu berechnen und anzuzeigen.
 
464
  raise
465
 
466
  def load_img2img():
467
+ """Lädt Multi-ControlNet-Inpainting-Pipeline (Pose + Canny)"""
468
  global pipe_img2img
469
  if pipe_img2img is None:
470
+ print("🔄 Lade Multi-ControlNet-Inpainting-Modell (OpenPose + Canny)...")
471
  try:
472
+ # LADE BEIDE ControlNet-Modelle
473
+ controlnet_openpose = ControlNetModel.from_pretrained(
474
+ "lllyasviel/sd-controlnet-openpose",
475
+ torch_dtype=torch_dtype
476
+ )
477
+ controlnet_canny = ControlNetModel.from_pretrained(
478
  "lllyasviel/sd-controlnet-canny",
479
  torch_dtype=torch_dtype
480
  )
481
 
482
+ # ÜBERGEBE EINE LISTE an die Pipeline
483
  pipe_img2img = StableDiffusionControlNetInpaintPipeline.from_pretrained(
484
  "runwayml/stable-diffusion-v1-5",
485
+ controlnet=[controlnet_openpose, controlnet_canny], # <-- Liste
486
  torch_dtype=torch_dtype,
487
  safety_checker=None,
488
  requires_safety_checker=False
 
495
  use_karras_sigmas=True,
496
  timestep_spacing="trailing"
497
  )
498
+ print("✅ Multi-ControlNet-Inpainting-Pipeline geladen (OpenPose + Canny)")
 
499
 
500
  except Exception as e:
501
+ print(f"❌ Fehler beim Laden der Multi-ControlNet-Inpainting-Pipeline: {e}")
502
  raise
503
 
504
  # Optimierungen
505
  pipe_img2img.enable_attention_slicing()
506
+ print("✅ Multi-ControlNet-Inpainting-Pipeline optimiert")
 
 
 
507
 
508
  return pipe_img2img
509
 
510
+
511
 
512
  #Die Callback-Funktion wird von der Pipeline nach jedem Verarbeitungsschritt aufgerufen und erhält Informationen
513
  #wie den aktuellen step und timestep. Diese nutzt der Progressbalken-Callback, um den Fortschritt zu berechnen und anzuzeigen.