Update controlnet_module.py
Browse files- controlnet_module.py +12 -5
controlnet_module.py
CHANGED
|
@@ -613,11 +613,18 @@ class ControlNetProcessor:
|
|
| 613 |
largest_component = np.argmax(sizes) + 1
|
| 614 |
mask_array = np.where(labeled_array == largest_component, mask_array, 0)
|
| 615 |
print(f" ✅ Behalte größte Person-Komponente ({num_features} → 1 Komponente)")
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 621 |
|
| 622 |
elif mode == "environment_change":
|
| 623 |
print("🌳 ENVIRONMENT-CHANGE POSTPROCESSING")
|
|
|
|
| 613 |
largest_component = np.argmax(sizes) + 1
|
| 614 |
mask_array = np.where(labeled_array == largest_component, mask_array, 0)
|
| 615 |
print(f" ✅ Behalte größte Person-Komponente ({num_features} → 1 Komponente)")
|
| 616 |
+
|
| 617 |
+
|
| 618 |
+
# 1. Zuerst CLOSE, um schwarze Löcher IN der Person zu füllen
|
| 619 |
+
kernel_close = np.ones((5,5), np.uint8)
|
| 620 |
+
mask_array = cv2.morphologyEx(mask_array, cv2.MORPH_CLOSE, kernel_close, iterations=2)
|
| 621 |
+
|
| 622 |
+
# 2. Dann Dilation für bessere Abdeckung
|
| 623 |
+
kernel_dilate = np.ones((3,3), np.uint8)
|
| 624 |
+
mask_array = cv2.dilate(mask_array, kernel_dilate, iterations=1)
|
| 625 |
+
|
| 626 |
+
print(" ✅ MORPH_CLOSE füllt schwarze Löcher in der Person")
|
| 627 |
+
print(" ✅ Dilation für bessere Personenabdeckung")
|
| 628 |
|
| 629 |
elif mode == "environment_change":
|
| 630 |
print("🌳 ENVIRONMENT-CHANGE POSTPROCESSING")
|