Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Fix LightGlue normalize_keypoints with torch.Size input (#3075)

Dávid Komorowicz5985885d6636
diff --git a/kornia/feature/lightglue.py b/kornia/feature/lightglue.py
index 0454c900d..b7a01be41 100644
--- a/kornia/feature/lightglue.py
+++ b/kornia/feature/lightglue.py
@@ -45,7 +45,7 @@ def math_clamp(x, min_, max_): # type: ignore
@custom_fwd(cast_inputs=torch.float32)
def normalize_keypoints(kpts: Tensor, size: Tensor) -> Tensor:
if isinstance(size, torch.Size):
- size = Tensor(size)[None]
+ size = torch.tensor(size)[None]
shift = size.float().to(kpts) / 2
scale = size.max(1).values.float().to(kpts) / 2
kpts = (kpts - shift[:, None]) / scale[:, None, None]