π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Fix dedode when calling detect() with padding correctly handled (#3147)
hit2sjtuf519aff95aae
diff --git a/kornia/feature/dedode/dedode.py b/kornia/feature/dedode/dedode.pyindex 9f5bf0ea6..9579a955c 100644--- a/kornia/feature/dedode/dedode.py+++ b/kornia/feature/dedode/dedode.py@@ -105,8 +105,8 @@ class DeDoDe(Module):if apply_imagenet_normalization:images = self.normalizer(images)B, C, H, W = images.shape+ h, w = images.shape[2:]if pad_if_not_divisible:- h, w = images.shape[2:]pd_h = 14 - h % 14 if h % 14 > 0 else 0pd_w = 14 - w % 14 if w % 14 > 0 else 0images = torch.nn.functional.pad(images, (0, pd_w, 0, pd_h), value=0.0)@@ -142,6 +142,7 @@ class DeDoDe(Module):"""KORNIA_CHECK_SHAPE(images, ["B", "3", "H", "W"])self.train(False)+ B, C, H, W = images.shapeif pad_if_not_divisible:h, w = images.shape[2:]pd_h = 14 - h % 14 if h % 14 > 0 else 0@@ -149,8 +150,9 @@ class DeDoDe(Module):images = torch.nn.functional.pad(images, (0, pd_w, 0, pd_h), value=0.0)if apply_imagenet_normalization:images = self.normalizer(images)- B, C, H, W = images.shapelogits = self.detector.forward(images)+ # Remove the padding, if any+ logits = logits[..., :H, :W]if crop_h is not None and crop_w is not None:logits = logits[..., :crop_h, :crop_w]H, W = crop_h, crop_w