Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
food-round2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nikhil_rayaprolu
food-round2
Commits
c64beaf1
Commit
c64beaf1
authored
5 years ago
by
Cao Yuhang
Committed by
Kai Chen
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix dpool (#1390)
* fix dpool * add _pair in dpool func
parent
69e93f6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmdet/ops/dcn/deform_pool.py
+17
-10
17 additions, 10 deletions
mmdet/ops/dcn/deform_pool.py
with
17 additions
and
10 deletions
mmdet/ops/dcn/deform_pool.py
+
17
−
10
View file @
c64beaf1
...
...
@@ -2,6 +2,7 @@ import torch
import
torch.nn
as
nn
from
torch.autograd
import
Function
from
torch.autograd.function
import
once_differentiable
from
torch.nn.modules.utils
import
_pair
from
.
import
deform_pool_cuda
...
...
@@ -21,6 +22,12 @@ class DeformRoIPoolingFunction(Function):
part_size
=
None
,
sample_per_part
=
4
,
trans_std
=
.
0
):
# TODO: support unsquare RoIs
out_h
,
out_w
=
_pair
(
out_size
)
assert
isinstance
(
out_h
,
int
)
and
isinstance
(
out_w
,
int
)
assert
out_h
==
out_w
out_size
=
out_h
# out_h and out_w must be equal
ctx
.
spatial_scale
=
spatial_scale
ctx
.
out_size
=
out_size
ctx
.
out_channels
=
out_channels
...
...
@@ -85,7 +92,7 @@ class DeformRoIPooling(nn.Module):
trans_std
=
.
0
):
super
(
DeformRoIPooling
,
self
).
__init__
()
self
.
spatial_scale
=
spatial_scale
self
.
out_size
=
out_size
self
.
out_size
=
_pair
(
out_size
)
self
.
out_channels
=
out_channels
self
.
no_trans
=
no_trans
self
.
group_size
=
group_size
...
...
@@ -125,12 +132,12 @@ class DeformRoIPoolingPack(DeformRoIPooling):
if
not
no_trans
:
seq
=
[]
ic
=
self
.
out_size
*
self
.
out_size
*
self
.
out_channels
ic
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
*
self
.
out_channels
for
i
in
range
(
self
.
num_offset_fcs
):
if
i
<
self
.
num_offset_fcs
-
1
:
oc
=
self
.
deform_fc_channels
else
:
oc
=
self
.
out_size
*
self
.
out_size
*
2
oc
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
*
2
seq
.
append
(
nn
.
Linear
(
ic
,
oc
))
ic
=
oc
if
i
<
self
.
num_offset_fcs
-
1
:
...
...
@@ -156,7 +163,7 @@ class DeformRoIPoolingPack(DeformRoIPooling):
self
.
group_size
,
self
.
part_size
,
self
.
sample_per_part
,
self
.
trans_std
)
offset
=
self
.
offset_fc
(
x
.
view
(
n
,
-
1
))
offset
=
offset
.
view
(
n
,
2
,
self
.
out_size
,
self
.
out_size
)
offset
=
offset
.
view
(
n
,
2
,
self
.
out_size
[
0
]
,
self
.
out_size
[
1
]
)
return
deform_roi_pooling
(
data
,
rois
,
offset
,
self
.
spatial_scale
,
self
.
out_size
,
self
.
out_channels
,
self
.
no_trans
,
self
.
group_size
,
...
...
@@ -188,12 +195,12 @@ class ModulatedDeformRoIPoolingPack(DeformRoIPooling):
if
not
no_trans
:
offset_fc_seq
=
[]
ic
=
self
.
out_size
*
self
.
out_size
*
self
.
out_channels
ic
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
*
self
.
out_channels
for
i
in
range
(
self
.
num_offset_fcs
):
if
i
<
self
.
num_offset_fcs
-
1
:
oc
=
self
.
deform_fc_channels
else
:
oc
=
self
.
out_size
*
self
.
out_size
*
2
oc
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
*
2
offset_fc_seq
.
append
(
nn
.
Linear
(
ic
,
oc
))
ic
=
oc
if
i
<
self
.
num_offset_fcs
-
1
:
...
...
@@ -203,12 +210,12 @@ class ModulatedDeformRoIPoolingPack(DeformRoIPooling):
self
.
offset_fc
[
-
1
].
bias
.
data
.
zero_
()
mask_fc_seq
=
[]
ic
=
self
.
out_size
*
self
.
out_size
*
self
.
out_channels
ic
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
*
self
.
out_channels
for
i
in
range
(
self
.
num_mask_fcs
):
if
i
<
self
.
num_mask_fcs
-
1
:
oc
=
self
.
deform_fc_channels
else
:
oc
=
self
.
out_size
*
self
.
out_size
oc
=
self
.
out_size
[
0
]
*
self
.
out_size
[
1
]
mask_fc_seq
.
append
(
nn
.
Linear
(
ic
,
oc
))
ic
=
oc
if
i
<
self
.
num_mask_fcs
-
1
:
...
...
@@ -236,9 +243,9 @@ class ModulatedDeformRoIPoolingPack(DeformRoIPooling):
self
.
group_size
,
self
.
part_size
,
self
.
sample_per_part
,
self
.
trans_std
)
offset
=
self
.
offset_fc
(
x
.
view
(
n
,
-
1
))
offset
=
offset
.
view
(
n
,
2
,
self
.
out_size
,
self
.
out_size
)
offset
=
offset
.
view
(
n
,
2
,
self
.
out_size
[
0
]
,
self
.
out_size
[
1
]
)
mask
=
self
.
mask_fc
(
x
.
view
(
n
,
-
1
))
mask
=
mask
.
view
(
n
,
1
,
self
.
out_size
,
self
.
out_size
)
mask
=
mask
.
view
(
n
,
1
,
self
.
out_size
[
0
]
,
self
.
out_size
[
1
]
)
return
deform_roi_pooling
(
data
,
rois
,
offset
,
self
.
spatial_scale
,
self
.
out_size
,
self
.
out_channels
,
self
.
no_trans
,
self
.
group_size
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment