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
65d50d0f
Unverified
Commit
65d50d0f
authored
Sep 08, 2023
by
Edward Z. Yang
Committed by
GitHub
Sep 08, 2023
Browse files
Avoid creating a tensor of shape when not tracing (#7942)
Signed-off-by:
Edward Z. Yang
<
ezyang@meta.com
>
parent
e13b8f5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
torchvision/models/detection/transform.py
torchvision/models/detection/transform.py
+3
-1
No files found.
torchvision/models/detection/transform.py
View file @
65d50d0f
...
@@ -31,8 +31,10 @@ def _resize_image_and_masks(
...
@@ -31,8 +31,10 @@ def _resize_image_and_masks(
)
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
)
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
if
torchvision
.
_is_tracing
():
if
torchvision
.
_is_tracing
():
im_shape
=
_get_shape_onnx
(
image
)
im_shape
=
_get_shape_onnx
(
image
)
el
se
:
el
if
torch
.
jit
.
is_scripting
()
:
im_shape
=
torch
.
tensor
(
image
.
shape
[
-
2
:])
im_shape
=
torch
.
tensor
(
image
.
shape
[
-
2
:])
else
:
im_shape
=
image
.
shape
[
-
2
:]
size
:
Optional
[
List
[
int
]]
=
None
size
:
Optional
[
List
[
int
]]
=
None
scale_factor
:
Optional
[
float
]
=
None
scale_factor
:
Optional
[
float
]
=
None
...
...
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