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
b0601631
Unverified
Commit
b0601631
authored
May 21, 2021
by
Zhiqiang Wang
Committed by
GitHub
May 20, 2021
Browse files
Make target argument in transform.py truly optional (#3866)
parent
26e34735
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
torchvision/models/detection/transform.py
torchvision/models/detection/transform.py
+7
-4
No files found.
torchvision/models/detection/transform.py
View file @
b0601631
...
...
@@ -24,8 +24,9 @@ def _fake_cast_onnx(v):
def
_resize_image_and_masks
(
image
:
Tensor
,
self_min_size
:
float
,
self_max_size
:
float
,
target
:
Optional
[
Dict
[
str
,
Tensor
]],
fixed_size
:
Optional
[
Tuple
[
int
,
int
]])
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
target
:
Optional
[
Dict
[
str
,
Tensor
]]
=
None
,
fixed_size
:
Optional
[
Tuple
[
int
,
int
]]
=
None
,
)
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
if
torchvision
.
_is_tracing
():
im_shape
=
_get_shape_onnx
(
image
)
else
:
...
...
@@ -146,8 +147,10 @@ class GeneralizedRCNNTransform(nn.Module):
index
=
int
(
torch
.
empty
(
1
).
uniform_
(
0.
,
float
(
len
(
k
))).
item
())
return
k
[
index
]
def
resize
(
self
,
image
,
target
):
# type: (Tensor, Optional[Dict[str, Tensor]]) -> Tuple[Tensor, Optional[Dict[str, Tensor]]]
def
resize
(
self
,
image
:
Tensor
,
target
:
Optional
[
Dict
[
str
,
Tensor
]]
=
None
,
)
->
Tuple
[
Tensor
,
Optional
[
Dict
[
str
,
Tensor
]]]:
h
,
w
=
image
.
shape
[
-
2
:]
if
self
.
training
:
size
=
float
(
self
.
torch_choice
(
self
.
min_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