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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -939,12 +939,26 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
939
 
940
  # ===== CONTROLNET-GESTEUERTES INPAINTING DURCHFÜHREN =====
941
  print(f"🔄 Führe ControlNet-gesteuertes Inpainting durch...")
 
 
 
 
 
 
 
 
 
 
 
 
 
942
  result = pipe(
943
  prompt=enhanced_prompt,
944
  negative_prompt=combined_negative_prompt,
945
- image=scaled_image, # Das skalierte Originalbild
946
- mask_image=scaled_mask, # Die skalierte Maske
947
- control_image=controlnet_maps, # Die ControlNet-Maps als Liste
 
948
  strength=adj_strength,
949
  num_inference_steps=int(steps),
950
  guidance_scale=adj_guidance,
@@ -952,6 +966,7 @@ def img_to_image(image, prompt, neg_prompt, strength, steps, guidance_scale,
952
  callback_on_step_end=callback,
953
  callback_on_step_end_tensor_inputs=[],
954
  )
 
955
 
956
  print("✅ ControlNet-Inpainting abgeschlossen")
957
 
 
939
 
940
  # ===== CONTROLNET-GESTEUERTES INPAINTING DURCHFÜHREN =====
941
  print(f"🔄 Führe ControlNet-gesteuertes Inpainting durch...")
942
+ # Berechne die Gewichtung basierend auf dem Modus (wie in der alten ControlNet-Methode)
943
+
944
+ if keep_environment: # Depth + Canny
945
+ conditioning_scale = [
946
+ controlnet_strength * 0.6, # Depth: 60%
947
+ controlnet_strength * 0.4 # Canny: 40%
948
+ ]
949
+ else: # OpenPose + Canny
950
+ conditioning_scale = [
951
+ controlnet_strength * 0.7, # OpenPose: 70%
952
+ controlnet_strength * 0.3 # Canny: 30%
953
+ ]
954
+
955
  result = pipe(
956
  prompt=enhanced_prompt,
957
  negative_prompt=combined_negative_prompt,
958
+ image=scaled_image,
959
+ mask_image=scaled_mask,
960
+ control_image=controlnet_maps,
961
+ controlnet_conditioning_scale=conditioning_scale, # DYNAMISCHE Liste
962
  strength=adj_strength,
963
  num_inference_steps=int(steps),
964
  guidance_scale=adj_guidance,
 
966
  callback_on_step_end=callback,
967
  callback_on_step_end_tensor_inputs=[],
968
  )
969
+
970
 
971
  print("✅ ControlNet-Inpainting abgeschlossen")
972