Skip to content

Commit 1cf674c

Browse files
committed
Remove convert_bounding_boxes_to_keypoints
1 parent 2ab521b commit 1cf674c

File tree

4 files changed

+0
-62
lines changed

4 files changed

+0
-62
lines changed

docs/source/transforms.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ functionals
459459
v2.functional.to_pil_image
460460
v2.functional.to_dtype
461461
v2.functional.convert_bounding_box_format
462-
v2.functional.convert_bounding_boxes_to_keypoints
463462

464463

465464
Deprecated

test/test_transforms_v2.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7274,37 +7274,3 @@ def test_different_sizes(self, make_input1, make_input2, query):
72747274
def test_no_valid_input(self, query):
72757275
with pytest.raises(TypeError, match="No image"):
72767276
query(["blah"])
7277-
7278-
7279-
@pytest.mark.parametrize(
7280-
"boxes",
7281-
[
7282-
tv_tensors.BoundingBoxes(torch.tensor([[1.0, 1.0, 2.0, 2.0]]), format="XYXY", canvas_size=(4, 4)),
7283-
tv_tensors.BoundingBoxes(torch.tensor([[1.0, 1.0, 1.0, 1.0]]), format="XYWH", canvas_size=(4, 4)),
7284-
tv_tensors.BoundingBoxes(torch.tensor([[1.5, 1.5, 1.0, 1.0]]), format="CXCYWH", canvas_size=(4, 4)),
7285-
tv_tensors.BoundingBoxes(torch.tensor([[1.5, 1.5, 1.0, 1.0, 45]]), format="CXCYWHR", canvas_size=(4, 4)),
7286-
tv_tensors.BoundingBoxes(torch.tensor([[1.0, 1.0, 1.0, 1.0, 45.0]]), format="XYWHR", canvas_size=(4, 4)),
7287-
tv_tensors.BoundingBoxes(
7288-
torch.tensor([[1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 1.0]]), format="XYXYXYXY", canvas_size=(4, 4)
7289-
),
7290-
],
7291-
)
7292-
def test_convert_bounding_boxes_to_keypoints(boxes: tv_tensors.BoundingBoxes):
7293-
kp = F.convert_bounding_boxes_to_keypoints(boxes)
7294-
assert kp.shape == (boxes.shape[0], 4, 2)
7295-
assert kp.dtype == boxes.dtype
7296-
7297-
# We manually convert the kp back into a BoundingBoxes, and convert that
7298-
# bbox back into the original `boxes` format to compare against it.
7299-
if tv_tensors.is_rotated_bounding_format(boxes.format):
7300-
reconverted = kp.reshape(-1, 8)
7301-
intermediate_format = tv_tensors.BoundingBoxFormat.XYXYXYXY
7302-
else:
7303-
reconverted = torch.cat([kp[..., 0, :], kp[..., 2, :]], dim=-1)
7304-
intermediate_format = tv_tensors.BoundingBoxFormat.XYXY
7305-
7306-
reconverted_bbox = F.convert_bounding_box_format(
7307-
tv_tensors.BoundingBoxes(reconverted, format=intermediate_format, canvas_size=kp.canvas_size),
7308-
new_format=boxes.format,
7309-
)
7310-
assert_equal(reconverted_bbox, boxes, atol=1e-5, rtol=0)

torchvision/transforms/v2/functional/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
clamp_bounding_boxes,
77
clamp_keypoints,
88
convert_bounding_box_format,
9-
convert_bounding_boxes_to_keypoints,
109
get_dimensions_image,
1110
get_dimensions_video,
1211
get_dimensions,

torchvision/transforms/v2/functional/_meta.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -189,32 +189,6 @@ def _xyxyxyxy_to_keypoints(bounding_boxes: torch.Tensor) -> torch.Tensor:
189189
return bounding_boxes[:, [[0, 1], [2, 3], [4, 5], [6, 7]]]
190190

191191

192-
# Note: this doesn't have a corresponding transforms class.
193-
def convert_bounding_boxes_to_keypoints(bounding_boxes: tv_tensors.BoundingBoxes) -> tv_tensors.KeyPoints:
194-
"""Convert a set of bounding boxes to its edge points.
195-
196-
Args:
197-
bounding_boxes (tv_tensors.BoundingBoxes): A set of ``N`` bounding boxes (of shape ``[N, 4]``)
198-
199-
Returns:
200-
tv_tensors.KeyPoints: The edges, as a polygon of shape ``[N, 4, 2]``
201-
"""
202-
if tv_tensors.is_rotated_bounding_format(bounding_boxes.format):
203-
intermediate_format = BoundingBoxFormat.XYXYXYXY
204-
to_keypoints = _xyxyxyxy_to_keypoints
205-
else:
206-
intermediate_format = BoundingBoxFormat.XYXY
207-
to_keypoints = _xyxy_to_keypoints
208-
209-
bbox = _convert_bounding_box_format(
210-
bounding_boxes.as_subclass(torch.Tensor),
211-
old_format=bounding_boxes.format,
212-
new_format=intermediate_format,
213-
inplace=False,
214-
)
215-
return tv_tensors.KeyPoints(to_keypoints(bbox), canvas_size=bounding_boxes.canvas_size)
216-
217-
218192
def _cxcywhr_to_xywhr(cxcywhr: torch.Tensor, inplace: bool) -> torch.Tensor:
219193
if not inplace:
220194
cxcywhr = cxcywhr.clone()

0 commit comments

Comments
 (0)