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
81a2e105
Unverified
Commit
81a2e105
authored
Nov 07, 2022
by
Philip Meier
Committed by
GitHub
Nov 07, 2022
Browse files
add mitigation for empty bounding boxes (#6923)
parent
f30a92f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
torchvision/prototype/transforms/functional/_geometry.py
torchvision/prototype/transforms/functional/_geometry.py
+9
-0
No files found.
torchvision/prototype/transforms/functional/_geometry.py
View file @
81a2e105
...
@@ -337,6 +337,9 @@ def _affine_bounding_box_xyxy(
...
@@ -337,6 +337,9 @@ def _affine_bounding_box_xyxy(
center
:
Optional
[
List
[
float
]]
=
None
,
center
:
Optional
[
List
[
float
]]
=
None
,
expand
:
bool
=
False
,
expand
:
bool
=
False
,
)
->
Tuple
[
torch
.
Tensor
,
Tuple
[
int
,
int
]]:
)
->
Tuple
[
torch
.
Tensor
,
Tuple
[
int
,
int
]]:
if
bounding_box
.
numel
()
==
0
:
return
bounding_box
,
spatial_size
angle
,
translate
,
shear
,
center
=
_affine_parse_args
(
angle
,
translate
,
shear
,
center
=
_affine_parse_args
(
angle
,
translate
,
scale
,
shear
,
InterpolationMode
.
NEAREST
,
center
angle
,
translate
,
scale
,
shear
,
InterpolationMode
.
NEAREST
,
center
)
)
...
@@ -1013,6 +1016,9 @@ def perspective_bounding_box(
...
@@ -1013,6 +1016,9 @@ def perspective_bounding_box(
endpoints
:
Optional
[
List
[
List
[
int
]]],
endpoints
:
Optional
[
List
[
List
[
int
]]],
coefficients
:
Optional
[
List
[
float
]]
=
None
,
coefficients
:
Optional
[
List
[
float
]]
=
None
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
if
bounding_box
.
numel
()
==
0
:
return
bounding_box
perspective_coeffs
=
_perspective_coefficients
(
startpoints
,
endpoints
,
coefficients
)
perspective_coeffs
=
_perspective_coefficients
(
startpoints
,
endpoints
,
coefficients
)
original_shape
=
bounding_box
.
shape
original_shape
=
bounding_box
.
shape
...
@@ -1203,6 +1209,9 @@ def elastic_bounding_box(
...
@@ -1203,6 +1209,9 @@ def elastic_bounding_box(
format
:
features
.
BoundingBoxFormat
,
format
:
features
.
BoundingBoxFormat
,
displacement
:
torch
.
Tensor
,
displacement
:
torch
.
Tensor
,
)
->
torch
.
Tensor
:
)
->
torch
.
Tensor
:
if
bounding_box
.
numel
()
==
0
:
return
bounding_box
# TODO: add in docstring about approximation we are doing for grid inversion
# TODO: add in docstring about approximation we are doing for grid inversion
displacement
=
displacement
.
to
(
bounding_box
.
device
)
displacement
=
displacement
.
to
(
bounding_box
.
device
)
...
...
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