From 4d9dc6205b793ffd0fb319816136d9b8c0dbfdff Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Mon, 5 Aug 2024 02:39:29 +0300 Subject: [PATCH] cleanup --- liveportrait/live_portrait_pipeline.py | 1 - liveportrait/utils/crop.py | 16 +++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/liveportrait/live_portrait_pipeline.py b/liveportrait/live_portrait_pipeline.py index 202481a..a20b0cc 100644 --- a/liveportrait/live_portrait_pipeline.py +++ b/liveportrait/live_portrait_pipeline.py @@ -54,7 +54,6 @@ class LivePortraitPipeline(object): else: total_frames = driving_images.shape[0] - disable_progress_bar = True if relative_motion_mode == "single_frame" else False diff --git a/liveportrait/utils/crop.py b/liveportrait/utils/crop.py index b617e00..f914d66 100644 --- a/liveportrait/utils/crop.py +++ b/liveportrait/utils/crop.py @@ -43,23 +43,17 @@ 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 + 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)