mirror of
https://github.com/hacksider/Deep-Live-Cam.git
synced 2026-07-25 03:20:51 +02:00
Make square aligned-face assumption explicit in _fast_paste_back
Addresses Sourcery feedback on PR #1776: _get_soft_alpha caches a single NxN template keyed by N, which is correct for the inswapper model (128x128 aligned-face space) but would silently mis-warp if a caller ever passed a non-square aligned face. Assert the shape instead of silently assuming it.
This commit is contained in:
@@ -297,6 +297,10 @@ def _fast_paste_back(target_img: Frame, bgr_fake: np.ndarray, aimg: np.ndarray,
|
||||
"""
|
||||
h, w = target_img.shape[:2]
|
||||
face_h, face_w = aimg.shape[:2]
|
||||
# inswapper's aligned-face space is square (128x128). _get_soft_alpha
|
||||
# caches a single NxN template keyed by N, so fail loudly if that ever
|
||||
# stops being true rather than silently mis-warping the alpha mask.
|
||||
assert face_h == face_w, f"Expected square aligned face, got {face_h}x{face_w}"
|
||||
IM = cv2.invertAffineTransform(M)
|
||||
|
||||
# Bbox in output coords from the affine corners of the aligned-face square.
|
||||
|
||||
Reference in New Issue
Block a user