This commit is contained in:
kijai
2024-08-05 02:39:29 +03:00
parent c74fb1d479
commit 4d9dc6205b
2 changed files with 5 additions and 12 deletions
-1
View File
@@ -55,7 +55,6 @@ class LivePortraitPipeline(object):
total_frames = driving_images.shape[0]
disable_progress_bar = True if relative_motion_mode == "single_frame" else False
source_info = crop_info["source_info"]
+4 -10
View File
@@ -43,22 +43,16 @@ def _transform_img_kornia(img, M, dsize, device, flags='bilinear', borderMode='z
# Convert M from numpy.ndarray to PyTorch tensor
M = torch.from_numpy(M).float().to(device)
if M.shape == (3, 3):
M = M[:2, :].unsqueeze(0) # Adjust M to the expected shape Bx2x3
elif M.shape == (2, 3):
M = M.unsqueeze(0) # Add batch dimension if not present
# Reshape M for Kornia (1, 2, 3) and upscale to 3D affine matrix if not already
if M.shape == (3, 3):
M = M[:2, :]
if M.shape == (2, 3):
M = M.unsqueeze(0) # Add batch dimension
M = M.unsqueeze(0)
# Convert image to floating point tensor if not already
if img.dtype != torch.float32:
img = img.float()
img = img.to(device)
# Reshape img for Kornia (B, C, H, W)
img = img.permute(0, 3, 1, 2)
img = img.permute(0, 3, 1, 2).to(device) # Reshape img for Kornia (B, C, H, W)
# Apply the affine transformation
img_warped = KGT.warp_affine(img, M, _dsize, mode=flags, padding_mode=borderMode)