Astridkraft commited on
Commit
e820f39
·
verified ·
1 Parent(s): e558370

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +14 -1
controlnet_module.py CHANGED
@@ -554,9 +554,22 @@ class ControlNetProcessor:
554
  dynamic_threshold = max_val * 0.8
555
  print(f" ✅ SAM ist sicher (max_val={max_val:.3f} >= 0.6)")
556
 
557
- print(f" 🎯 Standard-Threshold: {dynamic_threshold:.3f}")
 
558
 
 
559
  mask_array = (mask_np > dynamic_threshold).astype(np.uint8) * 255
 
 
 
 
 
 
 
 
 
 
 
560
 
561
  # HIER: Rohmaske speichern (vor Smoothing)
562
  raw_mask_array = mask_array.copy()
 
554
  dynamic_threshold = max_val * 0.8
555
  print(f" ✅ SAM ist sicher (max_val={max_val:.3f} >= 0.6)")
556
 
557
+
558
+ print(f" 🎯 Standard-Threshold: {dynamic_threshold:.3f}")
559
 
560
+ print(f" 🐛 DEBUG THRESHOLD: max_val={max_val:.3f}, dynamic_threshold={dynamic_threshold:.3f}")
561
  mask_array = (mask_np > dynamic_threshold).astype(np.uint8) * 255
562
+ print(f" 🐛 DEBUG BINÄRMASKE: Min/Max: {mask_array.min()}/{mask_array.max()}, Weiße Pixel: {np.sum(mask_array > 0)}")
563
+ #mask_array = (mask_np > dynamic_threshold).astype(np.uint8) * 255
564
+
565
+ # 2. Wenn die Maske immer noch leer ist, ERZwinge eine einfache Maske für den Test:
566
+ if mask_array.max() == 0:
567
+ print(" ⚠️ KRITISCH: Binärmaske ist leer! Erzwinge Testmaske (BBox).")
568
+ # Erstelle eine einfache weiße Box innerhalb der BBox als Fallback
569
+ test_mask = np.zeros((image.height, image.width), dtype=np.uint8)
570
+ cv2.rectangle(test_mask, (x1, y1), (x2, y2), 255, -1) # -1 = ausgefüllt
571
+ mask_array = test_mask
572
+ print(f" 🐛 DEBUG ERZWUNGENE MASKE: Min/Max: {mask_array.min()}/{mask_array.max()}")
573
 
574
  # HIER: Rohmaske speichern (vor Smoothing)
575
  raw_mask_array = mask_array.copy()