Astridkraft commited on
Commit
6621478
·
verified ·
1 Parent(s): 5a77243

Update controlnet_module.py

Browse files
Files changed (1) hide show
  1. controlnet_module.py +3 -13
controlnet_module.py CHANGED
@@ -832,6 +832,7 @@ class ControlNetProcessor:
832
 
833
  # Keine Bildverbesserung für 512x512 - Original verwenden
834
  image = original_image
 
835
 
836
  ################################
837
  #BBox-Berechnung für Heuristik immer Oroginal-BBox
@@ -874,7 +875,7 @@ class ControlNetProcessor:
874
  # SAM erwartet NumPy-Array, kein PIL
875
  image_np = np.array(image.convert("RGB"))
876
 
877
- # Immer nur eine BBox verwenden (SAM 2 erwartet genau 1)
878
  input_boxes = [[[x1, y1, x2, y2]]]
879
 
880
  # Punkt in der BBox-Mitte (zur Ünterstützung von SAM damit BBox nicht zu dicht um Kopf gezogen werden muß!)
@@ -1261,18 +1262,7 @@ class ControlNetProcessor:
1261
 
1262
  else: #keine use_crop_stategy Bild<=512
1263
  print("👤 POSTPROCESSING AUF ORIGINALGRÖSSE (≤512px)")
1264
-
1265
- # POSTPROCESSING-LOGIK FÜR ORIGINALGRÖSSE
1266
- labeled_array, num_features = ndimage.label(mask_array)
1267
-
1268
- if num_features > 0:
1269
- print(f" 🔍 Gefundene Komponenten: {num_features}")
1270
- sizes = ndimage.sum(mask_array, labeled_array, range(1, num_features + 1))
1271
- largest_component_idx = np.argmax(sizes) + 1
1272
- print(f" 👑 Größte Komponente: Nr. {largest_component_idx} mit {sizes[largest_component_idx-1]:,} Pixel")
1273
-
1274
- mask_array = np.where(labeled_array == largest_component_idx, mask_array, 0)
1275
-
1276
  # ANGEPASSTE Morphologische Operationen für Originalgröße
1277
  kernel_close = np.ones((5, 5), np.uint8)
1278
  mask_array = cv2.morphologyEx(mask_array, cv2.MORPH_CLOSE, kernel_close, iterations=1)
 
832
 
833
  # Keine Bildverbesserung für 512x512 - Original verwenden
834
  image = original_image
835
+ #x1, y1, x2, y2 bleiben Originalkoordinaten
836
 
837
  ################################
838
  #BBox-Berechnung für Heuristik immer Oroginal-BBox
 
875
  # SAM erwartet NumPy-Array, kein PIL
876
  image_np = np.array(image.convert("RGB"))
877
 
878
+ # SAM bekommt die aktuelle BBox entweder Original oder transformiert
879
  input_boxes = [[[x1, y1, x2, y2]]]
880
 
881
  # Punkt in der BBox-Mitte (zur Ünterstützung von SAM damit BBox nicht zu dicht um Kopf gezogen werden muß!)
 
1262
 
1263
  else: #keine use_crop_stategy Bild<=512
1264
  print("👤 POSTPROCESSING AUF ORIGINALGRÖSSE (≤512px)")
1265
+
 
 
 
 
 
 
 
 
 
 
 
1266
  # ANGEPASSTE Morphologische Operationen für Originalgröße
1267
  kernel_close = np.ones((5, 5), np.uint8)
1268
  mask_array = cv2.morphologyEx(mask_array, cv2.MORPH_CLOSE, kernel_close, iterations=1)