Update controlnet_module.py
Browse files- controlnet_module.py +8 -18
controlnet_module.py
CHANGED
|
@@ -305,21 +305,10 @@ class ControlNetProcessor:
|
|
| 305 |
print(f"working_mask shape: {working_mask.shape}")
|
| 306 |
|
| 307 |
|
| 308 |
-
#
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
inpaint_mask = working_mask.copy() # Person=weiß
|
| 313 |
-
|
| 314 |
-
kernel_inpaint = np.ones((5, 5), np.uint8)
|
| 315 |
-
inpaint_mask = cv2.dilate(inpaint_mask, kernel_inpaint, iterations=1)
|
| 316 |
-
print(f" ✅ Inpaint Dilate (5x5) - Person leicht erweitert")
|
| 317 |
-
# Später invertieren für Inpaint
|
| 318 |
-
|
| 319 |
-
# === 2. FÜR COMPOSITING: Größere Dilatation (15×15) auf working_mask ===
|
| 320 |
-
kernel_comp = np.ones((15, 15), np.uint8)
|
| 321 |
-
working_mask = cv2.dilate(working_mask, kernel_comp, iterations=1)
|
| 322 |
-
print(f" ✅ Compositing Dilate (15x15) - Person stark erweitert")
|
| 323 |
|
| 324 |
|
| 325 |
# MORPH_CLOSE auf dem schwarzen Hintergrund (feine Löcher)- kleiner Kernel filigrane Heranarbeitung an Person,
|
|
@@ -355,10 +344,11 @@ class ControlNetProcessor:
|
|
| 355 |
print(f" ✅ Konturenfilter - Größte Kontur behalten, {len(contours)-1} kleine entfernt")
|
| 356 |
|
| 357 |
|
| 358 |
-
|
| 359 |
-
|
|
|
|
| 360 |
#Invertieren da SAM segmentierte Person/Gegenstand weiß ausgibt
|
| 361 |
-
inpaint_binary_mask = 255 -
|
| 362 |
|
| 363 |
|
| 364 |
# Gaussian-BLUR für weiche Kanten für Composition
|
|
|
|
| 305 |
print(f"working_mask shape: {working_mask.shape}")
|
| 306 |
|
| 307 |
|
| 308 |
+
# DILATE auf der weißen Person - dadurch wird Person etwas vergrößert
|
| 309 |
+
kernel_dilate = np.ones((5, 5), np.uint8)
|
| 310 |
+
working_mask = cv2.dilate(working_mask, kernel_dilate, iterations=1)
|
| 311 |
+
print(f" ✅ Dilate (5x5) - Person leicht erweitert")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
|
| 313 |
|
| 314 |
# MORPH_CLOSE auf dem schwarzen Hintergrund (feine Löcher)- kleiner Kernel filigrane Heranarbeitung an Person,
|
|
|
|
| 344 |
print(f" ✅ Konturenfilter - Größte Kontur behalten, {len(contours)-1} kleine entfernt")
|
| 345 |
|
| 346 |
|
| 347 |
+
#Inpaint darf auch nur eine schwarz/weiß Maske (Binärmaske 0,255) bekommen. Bei
|
| 348 |
+
#weichen/grauen Pixeln könnte Inpaint etwas anderes generieren.
|
| 349 |
+
inpaint_binary_mask = working_mask.copy() #Person weiß
|
| 350 |
#Invertieren da SAM segmentierte Person/Gegenstand weiß ausgibt
|
| 351 |
+
inpaint_binary_mask = 255 - inpaint_binary_mask
|
| 352 |
|
| 353 |
|
| 354 |
# Gaussian-BLUR für weiche Kanten für Composition
|