From 8071ddce6420b9872cf30704e3eea50808027621 Mon Sep 17 00:00:00 2001 From: wunianze666-netizen Date: Tue, 9 Jun 2026 15:24:12 +0800 Subject: [PATCH] fix kornia 0.8 pad import compatibility --- pyramid_blending.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pyramid_blending.py b/pyramid_blending.py index afc4bac..ee280c8 100644 --- a/pyramid_blending.py +++ b/pyramid_blending.py @@ -10,7 +10,6 @@ build_pyramid, find_next_powerof_two, is_powerof_two, - pad, ) from torch import Tensor @@ -28,7 +27,7 @@ def _pad_for_laplacian(image: torch.Tensor) -> tuple[torch.Tensor, tuple[int, in if not (is_powerof_two(h) and is_powerof_two(w)): pad_right = find_next_powerof_two(w) - w pad_down = find_next_powerof_two(h) - h - image = pad(image, (0, pad_right, 0, pad_down), "reflect") + image = F.pad(image, (0, pad_right, 0, pad_down), mode="reflect") return image, (pad_right, pad_down) @@ -41,7 +40,7 @@ def _gaussian_pyramid( h, w = images.shape[2], images.shape[3] if not (is_powerof_two(w) and is_powerof_two(h)): padding = (0, find_next_powerof_two(w) - w, 0, find_next_powerof_two(h) - h) - images = pad(images, padding, border_type) + images = F.pad(images, padding, mode=border_type) return build_pyramid(images, max_level, border_type, align_corners)