Spaces:
Running
Running
Commit ·
abd882e
1
Parent(s): b3255f0
Fix: expand mask to 3 channels before Laplacian pyramid to prevent shape broadcast error
Browse files- processors/face_swap.py +3 -1
processors/face_swap.py
CHANGED
|
@@ -384,9 +384,11 @@ class FaceSwapper:
|
|
| 384 |
"""
|
| 385 |
A = swapped.astype(np.float32)
|
| 386 |
B = original.astype(np.float32)
|
| 387 |
-
M =
|
| 388 |
if M.ndim == 2:
|
| 389 |
M = M[:, :, np.newaxis]
|
|
|
|
|
|
|
| 390 |
|
| 391 |
# Build Gaussian pyramids
|
| 392 |
gA, gB, gM = [A], [B], [M]
|
|
|
|
| 384 |
"""
|
| 385 |
A = swapped.astype(np.float32)
|
| 386 |
B = original.astype(np.float32)
|
| 387 |
+
M = mask.astype(np.float32) / 255.0
|
| 388 |
if M.ndim == 2:
|
| 389 |
M = M[:, :, np.newaxis]
|
| 390 |
+
# Expand to 3 channels so pyrDown/pyrUp never collapse the channel dim
|
| 391 |
+
M = np.repeat(M, 3, axis=2)
|
| 392 |
|
| 393 |
# Build Gaussian pyramids
|
| 394 |
gA, gB, gM = [A], [B], [M]
|