Astridkraft commited on
Commit
97fb2e8
·
verified ·
1 Parent(s): 8d34fc3

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +5 -4
controlnet_module.py CHANGED
@@ -539,11 +539,11 @@ class ControlNetProcessor:
539
  # SPEZIALBEHANDLUNG für Fokus-Änderung
540
  print(" 🎯 FOCUS-CHANGE: Passe Threshold für vollständige Körpermaske an")
541
  if best_score < 0.7: # Wenn Maskenqualität schlecht ist
542
- dynamic_threshold = 0.25 # NIEDRIGER Threshold, um mehr Pixel zu behalten
543
  print(f" ⚠️ Masken-Score niedrig ({best_score:.3f}). Setze Threshold auf {dynamic_threshold:.3f} für maximale Abdeckung.")
544
  else:
545
  # Bei guter Maske: moderaten Threshold verwenden
546
- dynamic_threshold = max(0.4, max_val * 0.5) # Viel niedriger als 0.8!
547
  print(f" ✅ Gute Maske. Verwende moderaten Threshold: {dynamic_threshold:.3f}")
548
 
549
  else: # environment_change oder andere
@@ -685,9 +685,10 @@ class ControlNetProcessor:
685
  print(f" DEBUG NACH MORPH_CLOSE - Min/Max: {mask_array.min()}/{mask_array.max()}")
686
 
687
  # 2. Dann Dilation für bessere Abdeckung
688
- kernel_dilate = np.ones((9,9), np.uint8)
689
- mask_array = cv2.dilate(mask_array, kernel_dilate, iterations=1)
690
  print(f" DEBUG NACH DILATION - Min/Max: {mask_array.min()}/{mask_array.max()}")
 
691
 
692
  # Mittelstarker Blur für natürliche Übergänge:
693
  mask_array = cv2.GaussianBlur(mask_array, (9, 9), 2.0)
 
539
  # SPEZIALBEHANDLUNG für Fokus-Änderung
540
  print(" 🎯 FOCUS-CHANGE: Passe Threshold für vollständige Körpermaske an")
541
  if best_score < 0.7: # Wenn Maskenqualität schlecht ist
542
+ dynamic_threshold = 0.05 # NIEDRIGER Threshold, um mehr Pixel zu behalten
543
  print(f" ⚠️ Masken-Score niedrig ({best_score:.3f}). Setze Threshold auf {dynamic_threshold:.3f} für maximale Abdeckung.")
544
  else:
545
  # Bei guter Maske: moderaten Threshold verwenden
546
+ dynamic_threshold = max(0.15, max_val * 0.3) # Viel niedriger als 0.8!
547
  print(f" ✅ Gute Maske. Verwende moderaten Threshold: {dynamic_threshold:.3f}")
548
 
549
  else: # environment_change oder andere
 
685
  print(f" DEBUG NACH MORPH_CLOSE - Min/Max: {mask_array.min()}/{mask_array.max()}")
686
 
687
  # 2. Dann Dilation für bessere Abdeckung
688
+ kernel_dilate_large = np.ones((25,25), np.uint8)
689
+ mask_array = cv2.dilate(mask_array, kernel_dilate_large, iterations=2)
690
  print(f" DEBUG NACH DILATION - Min/Max: {mask_array.min()}/{mask_array.max()}")
691
+ print(f" 🐛 DEBUG NACH VERSTÄRKTER DILATION - Min/Max: {mask_array.min()}/{mask_array.max()}, Weiße Pixel: {np.sum(mask_array > 0)}")
692
 
693
  # Mittelstarker Blur für natürliche Übergänge:
694
  mask_array = cv2.GaussianBlur(mask_array, (9, 9), 2.0)