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
4d711fdc
Unverified
Commit
4d711fdc
authored
Oct 05, 2021
by
Chungman Lee
Committed by
GitHub
Oct 05, 2021
Browse files
Use enumerate to get index of ModuleList (#4534)
Co-authored-by:
Nicolas Hug
<
contact@nicolas-hug.com
>
parent
6aa0fa30
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
9 deletions
+3
-9
torchvision/models/detection/ssd.py
torchvision/models/detection/ssd.py
+1
-3
torchvision/ops/feature_pyramid_network.py
torchvision/ops/feature_pyramid_network.py
+2
-6
No files found.
torchvision/models/detection/ssd.py
View file @
4d711fdc
...
@@ -62,12 +62,10 @@ class SSDScoringHead(nn.Module):
...
@@ -62,12 +62,10 @@ class SSDScoringHead(nn.Module):
num_blocks
=
len
(
self
.
module_list
)
num_blocks
=
len
(
self
.
module_list
)
if
idx
<
0
:
if
idx
<
0
:
idx
+=
num_blocks
idx
+=
num_blocks
i
=
0
out
=
x
out
=
x
for
module
in
self
.
module_list
:
for
i
,
module
in
enumerate
(
self
.
module_list
)
:
if
i
==
idx
:
if
i
==
idx
:
out
=
module
(
x
)
out
=
module
(
x
)
i
+=
1
return
out
return
out
def
forward
(
self
,
x
:
List
[
Tensor
])
->
Tensor
:
def
forward
(
self
,
x
:
List
[
Tensor
])
->
Tensor
:
...
...
torchvision/ops/feature_pyramid_network.py
View file @
4d711fdc
...
@@ -103,12 +103,10 @@ class FeaturePyramidNetwork(nn.Module):
...
@@ -103,12 +103,10 @@ class FeaturePyramidNetwork(nn.Module):
num_blocks
=
len
(
self
.
inner_blocks
)
num_blocks
=
len
(
self
.
inner_blocks
)
if
idx
<
0
:
if
idx
<
0
:
idx
+=
num_blocks
idx
+=
num_blocks
i
=
0
out
=
x
out
=
x
for
module
in
self
.
inner_blocks
:
for
i
,
module
in
enumerate
(
self
.
inner_blocks
)
:
if
i
==
idx
:
if
i
==
idx
:
out
=
module
(
x
)
out
=
module
(
x
)
i
+=
1
return
out
return
out
def
get_result_from_layer_blocks
(
self
,
x
:
Tensor
,
idx
:
int
)
->
Tensor
:
def
get_result_from_layer_blocks
(
self
,
x
:
Tensor
,
idx
:
int
)
->
Tensor
:
...
@@ -119,12 +117,10 @@ class FeaturePyramidNetwork(nn.Module):
...
@@ -119,12 +117,10 @@ class FeaturePyramidNetwork(nn.Module):
num_blocks
=
len
(
self
.
layer_blocks
)
num_blocks
=
len
(
self
.
layer_blocks
)
if
idx
<
0
:
if
idx
<
0
:
idx
+=
num_blocks
idx
+=
num_blocks
i
=
0
out
=
x
out
=
x
for
module
in
self
.
layer_blocks
:
for
i
,
module
in
enumerate
(
self
.
layer_blocks
)
:
if
i
==
idx
:
if
i
==
idx
:
out
=
module
(
x
)
out
=
module
(
x
)
i
+=
1
return
out
return
out
def
forward
(
self
,
x
:
Dict
[
str
,
Tensor
])
->
Dict
[
str
,
Tensor
]:
def
forward
(
self
,
x
:
Dict
[
str
,
Tensor
])
->
Dict
[
str
,
Tensor
]:
...
...
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