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
25960493
Unverified
Commit
25960493
authored
Feb 17, 2023
by
Philip Meier
Committed by
GitHub
Feb 17, 2023
Browse files
convert all bounding boxes to XYXY in dataset wrapper (#7275)
parent
276ee2ae
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
torchvision/datapoints/_dataset_wrapper.py
torchvision/datapoints/_dataset_wrapper.py
+19
-8
No files found.
torchvision/datapoints/_dataset_wrapper.py
View file @
25960493
...
...
@@ -230,10 +230,13 @@ def coco_dectection_wrapper_factory(dataset):
batched_target
[
"image_id"
]
=
image_id
spatial_size
=
tuple
(
F
.
get_spatial_size
(
image
))
batched_target
[
"boxes"
]
=
datapoints
.
BoundingBox
(
batched_target
[
"boxes"
]
=
F
.
convert_format_bounding_box
(
datapoints
.
BoundingBox
(
batched_target
[
"bbox"
],
format
=
datapoints
.
BoundingBoxFormat
.
XYWH
,
spatial_size
=
spatial_size
,
),
new_format
=
datapoints
.
BoundingBoxFormat
.
XYXY
,
)
batched_target
[
"masks"
]
=
datapoints
.
Mask
(
torch
.
stack
(
...
...
@@ -323,8 +326,13 @@ def celeba_wrapper_factory(dataset):
target
,
target_types
=
dataset
.
target_type
,
type_wrappers
=
{
"bbox"
:
lambda
item
:
datapoints
.
BoundingBox
(
item
,
format
=
datapoints
.
BoundingBoxFormat
.
XYWH
,
spatial_size
=
(
image
.
height
,
image
.
width
)
"bbox"
:
lambda
item
:
F
.
convert_format_bounding_box
(
datapoints
.
BoundingBox
(
item
,
format
=
datapoints
.
BoundingBoxFormat
.
XYWH
,
spatial_size
=
(
image
.
height
,
image
.
width
),
),
new_format
=
datapoints
.
BoundingBoxFormat
.
XYXY
,
),
},
)
...
...
@@ -416,8 +424,11 @@ def widerface_wrapper(dataset):
image
,
target
=
sample
if
target
is
not
None
:
target
[
"bbox"
]
=
datapoints
.
BoundingBox
(
target
[
"bbox"
]
=
F
.
convert_format_bounding_box
(
datapoints
.
BoundingBox
(
target
[
"bbox"
],
format
=
datapoints
.
BoundingBoxFormat
.
XYWH
,
spatial_size
=
(
image
.
height
,
image
.
width
)
),
new_format
=
datapoints
.
BoundingBoxFormat
.
XYXY
,
)
return
image
,
target
...
...
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