Update controlnet_module.py
Browse files- controlnet_module.py +7 -6
controlnet_module.py
CHANGED
|
@@ -910,7 +910,7 @@ class ControlNetProcessor:
|
|
| 910 |
best_mask_idx = 0
|
| 911 |
best_score = -1
|
| 912 |
|
| 913 |
-
for i, mask_np in enumerate(
|
| 914 |
mask_max = mask_np.max()
|
| 915 |
|
| 916 |
# Grundlegende Filterung
|
|
@@ -925,14 +925,15 @@ class ControlNetProcessor:
|
|
| 925 |
if np.sum(mask_binary) == 0:
|
| 926 |
print(f" ❌ Maske {i+1}: Keine Pixel nach Threshold {adaptive_threshold:.3f}")
|
| 927 |
continue
|
| 928 |
-
|
|
|
|
| 929 |
mask_area_pixels = np.sum(mask_binary)
|
| 930 |
|
| 931 |
# ============================================================
|
| 932 |
# SPEZIALHEURISTIK
|
| 933 |
# ============================================================
|
| 934 |
|
| 935 |
-
print(f" 🔍 Analysiere Maske {i+1}
|
| 936 |
|
| 937 |
# 1. FLÄCHENBASIERTE BEWERTUNG (40%)
|
| 938 |
area_ratio = mask_area_pixels / bbox_area
|
|
@@ -983,9 +984,9 @@ class ControlNetProcessor:
|
|
| 983 |
print(f" • Kompaktheits-Score: {compactness_score:.3f}")
|
| 984 |
|
| 985 |
# 3. BBOX-ÜBERLAPPUNG (20%)
|
| 986 |
-
bbox_mask = np.zeros((
|
| 987 |
-
|
| 988 |
-
bbox_mask[
|
| 989 |
|
| 990 |
overlap = np.sum(mask_binary & bbox_mask)
|
| 991 |
|
|
|
|
| 910 |
best_mask_idx = 0
|
| 911 |
best_score = -1
|
| 912 |
|
| 913 |
+
for i, mask_np in enumerate(all_masks_crop):
|
| 914 |
mask_max = mask_np.max()
|
| 915 |
|
| 916 |
# Grundlegende Filterung
|
|
|
|
| 925 |
if np.sum(mask_binary) == 0:
|
| 926 |
print(f" ❌ Maske {i+1}: Keine Pixel nach Threshold {adaptive_threshold:.3f}")
|
| 927 |
continue
|
| 928 |
+
|
| 929 |
+
#Maskenfläche in Pixeln (Crop-Grösse)
|
| 930 |
mask_area_pixels = np.sum(mask_binary)
|
| 931 |
|
| 932 |
# ============================================================
|
| 933 |
# SPEZIALHEURISTIK
|
| 934 |
# ============================================================
|
| 935 |
|
| 936 |
+
print(f" 🔍 Analysiere Maske {i+1} auf Crop-Größe")
|
| 937 |
|
| 938 |
# 1. FLÄCHENBASIERTE BEWERTUNG (40%)
|
| 939 |
area_ratio = mask_area_pixels / bbox_area
|
|
|
|
| 984 |
print(f" • Kompaktheits-Score: {compactness_score:.3f}")
|
| 985 |
|
| 986 |
# 3. BBOX-ÜBERLAPPUNG (20%)
|
| 987 |
+
bbox_mask = np.zeros((image.height, image.width), dtype=np.uint8)
|
| 988 |
+
|
| 989 |
+
bbox_mask[y1:y2, x1:x2] = 1
|
| 990 |
|
| 991 |
overlap = np.sum(mask_binary & bbox_mask)
|
| 992 |
|