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
ModelZoo
SOLOv2-pytorch
Commits
d9172919
Commit
d9172919
authored
Oct 23, 2019
by
Jon Crall
Committed by
Kai Chen
Oct 23, 2019
Browse files
Fix SSD Head and GHM Loss on CPU (#1578)
* Fix GHM loss on CPU * Fix SSD head on CPU
parent
e68c3d90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
mmdet/models/anchor_heads/ssd_head.py
mmdet/models/anchor_heads/ssd_head.py
+3
-1
mmdet/models/losses/ghm_loss.py
mmdet/models/losses/ghm_loss.py
+8
-4
No files found.
mmdet/models/anchor_heads/ssd_head.py
View file @
d9172919
...
...
@@ -143,8 +143,10 @@ class SSDHead(AnchorHead):
featmap_sizes
=
[
featmap
.
size
()[
-
2
:]
for
featmap
in
cls_scores
]
assert
len
(
featmap_sizes
)
==
len
(
self
.
anchor_generators
)
device
=
cls_scores
[
0
].
device
anchor_list
,
valid_flag_list
=
self
.
get_anchors
(
featmap_sizes
,
img_metas
)
featmap_sizes
,
img_metas
,
device
=
device
)
cls_reg_targets
=
anchor_target
(
anchor_list
,
valid_flag_list
,
...
...
mmdet/models/losses/ghm_loss.py
View file @
d9172919
...
...
@@ -35,10 +35,12 @@ class GHMC(nn.Module):
super
(
GHMC
,
self
).
__init__
()
self
.
bins
=
bins
self
.
momentum
=
momentum
self
.
edges
=
torch
.
arange
(
bins
+
1
).
float
().
cuda
()
/
bins
edges
=
torch
.
arange
(
bins
+
1
).
float
()
/
bins
self
.
register_buffer
(
'edges'
,
edges
)
self
.
edges
[
-
1
]
+=
1e-6
if
momentum
>
0
:
self
.
acc_sum
=
torch
.
zeros
(
bins
).
cuda
()
acc_sum
=
torch
.
zeros
(
bins
)
self
.
register_buffer
(
'acc_sum'
,
acc_sum
)
self
.
use_sigmoid
=
use_sigmoid
if
not
self
.
use_sigmoid
:
raise
NotImplementedError
...
...
@@ -111,11 +113,13 @@ class GHMR(nn.Module):
super
(
GHMR
,
self
).
__init__
()
self
.
mu
=
mu
self
.
bins
=
bins
self
.
edges
=
torch
.
arange
(
bins
+
1
).
float
().
cuda
()
/
bins
edges
=
torch
.
arange
(
bins
+
1
).
float
()
/
bins
self
.
register_buffer
(
'edges'
,
edges
)
self
.
edges
[
-
1
]
=
1e3
self
.
momentum
=
momentum
if
momentum
>
0
:
self
.
acc_sum
=
torch
.
zeros
(
bins
).
cuda
()
acc_sum
=
torch
.
zeros
(
bins
)
self
.
register_buffer
(
'acc_sum'
,
acc_sum
)
self
.
loss_weight
=
loss_weight
# TODO: support reduction parameter
...
...
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