Astridkraft commited on
Commit
4a2ffe6
·
verified ·
1 Parent(s): a0a84b3

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +6 -12
controlnet_module.py CHANGED
@@ -839,14 +839,7 @@ class ControlNetProcessor:
839
  ##########################################################
840
 
841
  if use_crop_strategy:
842
- # Berechnung: wo wäre die Original-BBox im verkleinerten Crop-(Kopf am Rand des Bildes)
843
- #scale_x = image.width / original_image.width
844
- #scale_y = image.height / original_image.height
845
- #bbox_x1 = int(original_bbox[0] * scale_x)
846
- #bbox_y1 = int(original_bbox[1] * scale_y)
847
- #bbox_x2 = int(original_bbox[2] * scale_x)
848
- #bbox_y2 = int(original_bbox[3] * scale_y)
849
-
850
  bbox_x1, bbox_y1, bbox_x2, bbox_y2 = rel_x1, rel_y1, rel_x2, rel_y2
851
 
852
  print(f" 🎯 Heuristik-BBox im Crop: [{bbox_x1}, {bbox_y1}, {bbox_x2}, {bbox_y2}]")
@@ -1094,15 +1087,16 @@ class ControlNetProcessor:
1094
  # ============================================================
1095
  # THRESHOLD-BESTIMMUNG Wahrscheinlichkeiten -> Binär (0,1)
1096
  # ============================================================
1097
- # Spezieller Threshold für Gesichter
 
1098
  if max_val < 0.5:
1099
- dynamic_threshold = 0.25
1100
  print(f" ⚠️ SAM ist unsicher für Gesicht (max_val={max_val:.3f} < 0.5)")
1101
  elif max_val < 0.8:
1102
- dynamic_threshold = max_val * 0.65 # Mittlerer Threshold
1103
  print(f" ℹ️ SAM ist mäßig sicher für Gesicht (max_val={max_val:.3f})")
1104
  else:
1105
- dynamic_threshold = max_val * 0.75 # Hoher Threshold
1106
  print(f" ✅ SAM ist sicher für Gesicht (max_val={max_val:.3f} >= 0.8)")
1107
 
1108
  print(f" 🎯 Gesichts-Threshold: {dynamic_threshold:.3f}")
 
839
  ##########################################################
840
 
841
  if use_crop_strategy:
842
+
 
 
 
 
 
 
 
843
  bbox_x1, bbox_y1, bbox_x2, bbox_y2 = rel_x1, rel_y1, rel_x2, rel_y2
844
 
845
  print(f" 🎯 Heuristik-BBox im Crop: [{bbox_x1}, {bbox_y1}, {bbox_x2}, {bbox_y2}]")
 
1087
  # ============================================================
1088
  # THRESHOLD-BESTIMMUNG Wahrscheinlichkeiten -> Binär (0,1)
1089
  # ============================================================
1090
+ # Spezieller Threshold für Gesichter speziell Anime brauchen dickere Maske!
1091
+ # Aber auch allgemein für Kopf sind dicke Masken besser!
1092
  if max_val < 0.5:
1093
+ dynamic_threshold = 0.15 #anstatt 0.25
1094
  print(f" ⚠️ SAM ist unsicher für Gesicht (max_val={max_val:.3f} < 0.5)")
1095
  elif max_val < 0.8:
1096
+ dynamic_threshold = max_val * 0.45 # anstatt 0.65 Mittlerer Threshold
1097
  print(f" ℹ️ SAM ist mäßig sicher für Gesicht (max_val={max_val:.3f})")
1098
  else:
1099
+ dynamic_threshold = max_val * 0.55 # anstatt 0.75 Hoher Threshold
1100
  print(f" ✅ SAM ist sicher für Gesicht (max_val={max_val:.3f} >= 0.8)")
1101
 
1102
  print(f" 🎯 Gesichts-Threshold: {dynamic_threshold:.3f}")