Skip to content

remove strEnum from BoundingBoxFormat #7322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/test_datapoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ def test_bbox_instance(data, format):
assert isinstance(bboxes, torch.Tensor)
assert bboxes.ndim == 2 and bboxes.shape[1] == 4
if isinstance(format, str):
format = datapoints.BoundingBoxFormat.from_str(format.upper())
format = datapoints.BoundingBoxFormat[(format.upper())]
assert bboxes.format == format
12 changes: 6 additions & 6 deletions torchvision/datapoints/_bounding_box.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from __future__ import annotations

from enum import Enum
from typing import Any, List, Optional, Sequence, Tuple, Union

import torch
from torchvision._utils import StrEnum
from torchvision.transforms import InterpolationMode # TODO: this needs to be moved out of transforms

from ._datapoint import _FillTypeJIT, Datapoint


class BoundingBoxFormat(StrEnum):
XYXY = StrEnum.auto()
XYWH = StrEnum.auto()
CXCYWH = StrEnum.auto()
class BoundingBoxFormat(Enum):
XYXY = "XYXY"
XYWH = "XYWH"
CXCYWH = "CXCYWH"


class BoundingBox(Datapoint):
Expand All @@ -39,7 +39,7 @@ def __new__(
tensor = cls._to_tensor(data, dtype=dtype, device=device, requires_grad=requires_grad)

if isinstance(format, str):
format = BoundingBoxFormat.from_str(format.upper())
format = BoundingBoxFormat[format.upper()]

return cls._wrap(tensor, format=format, spatial_size=spatial_size)

Expand Down