π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
chore: remove dead code (discarded validate_bbox calls, vestigial params) (#3862)
Edgar Ribaef07de85bd48
diff --git a/kornia/augmentation/container/base.py b/kornia/augmentation/container/base.pyindex c63c8e63f..f1c444e2f 100644--- a/kornia/augmentation/container/base.py+++ b/kornia/augmentation/container/base.py@@ -156,8 +156,6 @@ class SequentialBase(BasicSequentialBase):*args : a list of kornia augmentation and image operation modules.same_on_batch: apply the same transformation across the batch.If None, it will not overwrite the function-wise settings.- return_transform: if ``True`` return the matrix describing the transformation- applied to each. If None, it will not overwrite the function-wise settings.keepdim: whether to keep the output shape the same as input (True) or broadcast itto the batch form (False). If None, it will not overwrite the function-wise settings.@@ -173,25 +171,22 @@ class SequentialBase(BasicSequentialBase):def update_attribute(self,same_on_batch: Optional[bool] = None,- return_transform: Optional[bool] = None,keepdim: Optional[bool] = None,) -> None:"""Propagate sequence-level flags to child augmentation modules.Args:same_on_batch: Override for ``same_on_batch``.- return_transform: Reserved for compatibility with older interfaces.keepdim: Override for ``keepdim``."""for mod in self.children():- # MixAugmentation does not have return transformif isinstance(mod, (_AugmentationBase, K.MixAugmentationBaseV2)):if same_on_batch is not None:mod.same_on_batch = same_on_batchif keepdim is not None:mod.keepdim = keepdimif isinstance(mod, SequentialBase):- mod.update_attribute(same_on_batch, return_transform, keepdim)+ mod.update_attribute(same_on_batch, keepdim)@propertydef same_on_batch(self) -> Optional[bool]:diff --git a/kornia/geometry/bbox.py b/kornia/geometry/bbox.pyindex 3a376331d..dbfddf0df 100644--- a/kornia/geometry/bbox.py+++ b/kornia/geometry/bbox.py@@ -138,7 +138,6 @@ def infer_bbox_shape(boxes: torch.Tensor) -> tuple[torch.Tensor, torch.Tensor]:(tensor([2., 2.]), tensor([2., 3.]))"""- validate_bbox(boxes)width: torch.Tensor = boxes[:, 1, 0] - boxes[:, 0, 0] + 1height: torch.Tensor = boxes[:, 2, 1] - boxes[:, 0, 1] + 1return height, widthdiff --git a/kornia/geometry/boxes.py b/kornia/geometry/boxes.pyindex b9bd40f68..84faff2c9 100644--- a/kornia/geometry/boxes.py+++ b/kornia/geometry/boxes.py@@ -23,7 +23,6 @@ import torchfrom torch import Sizefrom kornia.core.ops import eye_like-from kornia.geometry.bbox import validate_bboxfrom kornia.geometry.linalg import transform_points__all__ = ["Boxes", "Boxes3D"]@@ -127,7 +126,6 @@ def _boxes_to_quadrilaterals(boxes: torch.Tensor, mode: str = "xyxy", validate_bquadrilaterals = boxes.clone()else:raise ValueError(f"Unknown mode {mode}")- not validate_boxes or validate_bbox(quadrilaterals)elif mode.startswith("xy"):if mode == "xyxy":height, width = boxes[..., 3] - boxes[..., 1], boxes[..., 2] - boxes[..., 0]diff --git a/kornia/geometry/grid.py b/kornia/geometry/grid.pyindex 5a338c709..c3a46304b 100644--- a/kornia/geometry/grid.py+++ b/kornia/geometry/grid.py@@ -76,11 +76,6 @@ def create_meshgrid(xs = (xs / (width - 1) - 0.5) * 2ys = (ys / (height - 1) - 0.5) * 2# generate grid by stacking coordinates- # TODO: torchscript doesn't like `torch_version_ge`- # if torch_version_ge(1, 13, 0):- # x, y = torch.meshgrid([xs, ys], indexing="xy")- # return torch.stack([x, y], -1).unsqueeze(0) # 1xHxWx2- # TODO: remove after we drop support of old versionsbase_grid: torch.Tensor = torch.stack(torch.meshgrid([xs, ys], indexing="ij"), dim=-1) # WxHx2return base_grid.permute(1, 0, 2).unsqueeze(0) # 1xHxWx2diff --git a/kornia/geometry/transform/crop2d.py b/kornia/geometry/transform/crop2d.pyindex 383d89687..1ec96ac05 100644--- a/kornia/geometry/transform/crop2d.py+++ b/kornia/geometry/transform/crop2d.py@@ -23,7 +23,7 @@ from torch import nnfrom kornia.constants import Resamplefrom kornia.core.check import KORNIA_CHECK_SHAPE-from kornia.geometry.bbox import infer_bbox_shape, validate_bbox+from kornia.geometry.bbox import infer_bbox_shapefrom .affwarp import resizefrom .imgwarp import get_perspective_transform, warp_affine@@ -250,10 +250,6 @@ def crop_by_boxes(RuntimeError: solve_cpu: For batch 0: U(2,2) is zero, singular U."""- if validate_boxes:- validate_bbox(src_box)- validate_bbox(dst_box)-if len(input_tensor.shape) != 4:raise AssertionError(f"Only torch.Tensor with shape (B, C, H, W) supported. Got {input_tensor.shape}.")