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
76144bad
Unverified
Commit
76144bad
authored
Mar 23, 2023
by
Philip Meier
Committed by
GitHub
Mar 23, 2023
Browse files
prevent unwrapping in SanitizeBoundingBoxes (#7446)
parent
995f9b95
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
test/test_transforms_v2.py
test/test_transforms_v2.py
+3
-0
torchvision/transforms/v2/_misc.py
torchvision/transforms/v2/_misc.py
+10
-5
No files found.
test/test_transforms_v2.py
View file @
76144bad
...
@@ -2020,6 +2020,9 @@ def test_sanitize_bounding_boxes(min_size, labels_getter, sample_type):
...
@@ -2020,6 +2020,9 @@ def test_sanitize_bounding_boxes(min_size, labels_getter, sample_type):
assert
out_image
is
input_img
assert
out_image
is
input_img
assert
out_whatever
is
whatever
assert
out_whatever
is
whatever
assert
isinstance
(
out_boxes
,
datapoints
.
BoundingBox
)
assert
isinstance
(
out_masks
,
datapoints
.
Mask
)
if
labels_getter
is
None
or
(
callable
(
labels_getter
)
and
labels_getter
({
"labels"
:
"blah"
})
is
None
):
if
labels_getter
is
None
or
(
callable
(
labels_getter
)
and
labels_getter
({
"labels"
:
"blah"
})
is
None
):
assert
out_labels
is
labels
assert
out_labels
is
labels
else
:
else
:
...
...
torchvision/transforms/v2/_misc.py
View file @
76144bad
...
@@ -397,10 +397,15 @@ class SanitizeBoundingBox(Transform):
...
@@ -397,10 +397,15 @@ class SanitizeBoundingBox(Transform):
return
tree_unflatten
(
flat_outputs
,
spec
)
return
tree_unflatten
(
flat_outputs
,
spec
)
def
_transform
(
self
,
inpt
:
Any
,
params
:
Dict
[
str
,
Any
])
->
Any
:
def
_transform
(
self
,
inpt
:
Any
,
params
:
Dict
[
str
,
Any
])
->
Any
:
is_label
=
inpt
is
not
None
and
inpt
is
params
[
"labels"
]
is_bounding_box_or_mask
=
isinstance
(
inpt
,
(
datapoints
.
BoundingBox
,
datapoints
.
Mask
))
if
(
inpt
is
not
None
and
inpt
is
params
[
"labels"
])
or
isinstance
(
if
not
(
is_label
or
is_bounding_box_or_mask
):
inpt
,
(
datapoints
.
BoundingBox
,
datapoints
.
Mask
)
):
inpt
=
inpt
[
params
[
"valid"
]]
return
inpt
return
inpt
output
=
inpt
[
params
[
"valid"
]]
if
is_label
:
return
output
return
type
(
inpt
).
wrap_like
(
inpt
,
output
)
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