Skip to content

Commit 2ca482b

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] remove strEnum from BoundingBoxFormat (#7322)
Reviewed By: vmoens Differential Revision: D44416609 fbshipit-source-id: 9e55cd66b2dd32b87535c1769ce6314573d6cdac
1 parent a219784 commit 2ca482b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

test/test_datapoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ def test_bbox_instance(data, format):
2828
assert isinstance(bboxes, torch.Tensor)
2929
assert bboxes.ndim == 2 and bboxes.shape[1] == 4
3030
if isinstance(format, str):
31-
format = datapoints.BoundingBoxFormat.from_str(format.upper())
31+
format = datapoints.BoundingBoxFormat[(format.upper())]
3232
assert bboxes.format == format

torchvision/datapoints/_bounding_box.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
from __future__ import annotations
22

3+
from enum import Enum
34
from typing import Any, List, Optional, Sequence, Tuple, Union
45

56
import torch
6-
from torchvision._utils import StrEnum
77
from torchvision.transforms import InterpolationMode # TODO: this needs to be moved out of transforms
88

99
from ._datapoint import _FillTypeJIT, Datapoint
1010

1111

12-
class BoundingBoxFormat(StrEnum):
13-
XYXY = StrEnum.auto()
14-
XYWH = StrEnum.auto()
15-
CXCYWH = StrEnum.auto()
12+
class BoundingBoxFormat(Enum):
13+
XYXY = "XYXY"
14+
XYWH = "XYWH"
15+
CXCYWH = "CXCYWH"
1616

1717

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

4141
if isinstance(format, str):
42-
format = BoundingBoxFormat.from_str(format.upper())
42+
format = BoundingBoxFormat[format.upper()]
4343

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

0 commit comments

Comments
 (0)