Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
449cc090
Unverified
Commit
449cc090
authored
Feb 24, 2023
by
Nicolas Hug
Committed by
GitHub
Feb 24, 2023
Browse files
remove strEnum from BoundingBoxFormat (#7322)
parent
7fefdea3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
test/test_datapoints.py
test/test_datapoints.py
+1
-1
torchvision/datapoints/_bounding_box.py
torchvision/datapoints/_bounding_box.py
+6
-6
No files found.
test/test_datapoints.py
View file @
449cc090
...
...
@@ -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
torchvision/datapoints/_bounding_box.py
View file @
449cc090
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
(
Str
Enum
):
XYXY
=
StrEnum
.
auto
()
XYWH
=
StrEnum
.
auto
()
CXCYWH
=
StrEnum
.
auto
()
class
BoundingBoxFormat
(
Enum
):
XYXY
=
"XYXY"
XYWH
=
"XYWH"
CXCYWH
=
"CXCYWH"
class
BoundingBox
(
Datapoint
):
...
...
@@ -39,7 +39,7 @@ class BoundingBox(Datapoint):
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment