Astridkraft commited on
Commit
ed472aa
·
verified ·
1 Parent(s): 2223dbc

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +8 -5
controlnet_module.py CHANGED
@@ -546,13 +546,16 @@ class ControlNetProcessor:
546
  # Pixel unter 0.05 auf 0 gesetzt werden, alle darüber auf 1.
547
  # ============================================================
548
  mask_max = mask_np.max() #höchster Wahrscheinlichkeitswert in SAM-Maske
549
- if best_score < 0.7: # Schlechte Maskenqualität
550
- dynamic_threshold = 0.05 # SEHR NIEDRIG für maximale Abdeckung
551
  print(f" ⚠️ Masken-Score niedrig ({best_score:.3f}). "
552
- f"Threshold=0.05 für maximale Abdeckung")
 
 
 
553
  else:
554
- dynamic_threshold = max(0.15, mask_max * 0.3) # Moderater Threshold
555
- print(f" ✅ Gute Maske. Threshold={dynamic_threshold:.3f}")
556
 
557
  # Binärmaske erstellen
558
  mask_array = (mask_np > dynamic_threshold).astype(np.uint8) * 255
 
546
  # Pixel unter 0.05 auf 0 gesetzt werden, alle darüber auf 1.
547
  # ============================================================
548
  mask_max = mask_np.max() #höchster Wahrscheinlichkeitswert in SAM-Maske
549
+ if best_score < 0.6: # Schlechte Maskenqualität
550
+ dynamic_threshold = 0.15 # SEHR NIEDRIG für maximale Abdeckung
551
  print(f" ⚠️ Masken-Score niedrig ({best_score:.3f}). "
552
+ f"Threshold=0.15 für bessere Präzision")
553
+ elif best_score < 0.8:
554
+ dynamic_threshold = max(0.25, mask_max * 0.5) # Vorher 0.15/0.3 - JETZT 0.25/0.5
555
+ print(f" ℹ️ Mittlere Maskenqualität. Threshold={dynamic_threshold:.3f}")
556
  else:
557
+ dynamic_threshold = max(0.35, mask_max * 0.7) # sehr hoher Threshold für gute Masken
558
+ print(f" ✅ Excellente Maske. Threshold={dynamic_threshold:.3f}")
559
 
560
  # Binärmaske erstellen
561
  mask_array = (mask_np > dynamic_threshold).astype(np.uint8) * 255