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
c01ab3b1
Commit
c01ab3b1
authored
Nov 29, 2019
by
Wenwei Zhang
Committed by
Kai Chen
Nov 29, 2019
Browse files
fix scale factor bug (#1730)
* fix scale factor bug * reformat * clean code
parent
8cf2de8a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
1 deletion
+10
-1
mmdet/models/bbox_heads/bbox_head.py
mmdet/models/bbox_heads/bbox_head.py
+3
-1
mmdet/models/detectors/test_mixins.py
mmdet/models/detectors/test_mixins.py
+5
-0
mmdet/models/mask_heads/fcn_mask_head.py
mmdet/models/mask_heads/fcn_mask_head.py
+2
-0
No files found.
mmdet/models/bbox_heads/bbox_head.py
View file @
c01ab3b1
...
@@ -155,7 +155,9 @@ class BBoxHead(nn.Module):
...
@@ -155,7 +155,9 @@ class BBoxHead(nn.Module):
if
isinstance
(
scale_factor
,
float
):
if
isinstance
(
scale_factor
,
float
):
bboxes
/=
scale_factor
bboxes
/=
scale_factor
else
:
else
:
bboxes
/=
torch
.
from_numpy
(
scale_factor
).
to
(
bboxes
.
device
)
scale_factor
=
torch
.
from_numpy
(
scale_factor
).
to
(
bboxes
.
device
)
bboxes
=
(
bboxes
.
view
(
bboxes
.
size
(
0
),
-
1
,
4
)
/
scale_factor
).
view
(
bboxes
.
size
()[
0
],
-
1
)
if
cfg
is
None
:
if
cfg
is
None
:
return
bboxes
,
scores
return
bboxes
,
scores
...
...
mmdet/models/detectors/test_mixins.py
View file @
c01ab3b1
import
torch
from
mmdet.core
import
(
bbox2roi
,
bbox_mapping
,
merge_aug_bboxes
,
from
mmdet.core
import
(
bbox2roi
,
bbox_mapping
,
merge_aug_bboxes
,
merge_aug_masks
,
merge_aug_proposals
,
multiclass_nms
)
merge_aug_masks
,
merge_aug_proposals
,
multiclass_nms
)
...
@@ -114,6 +116,9 @@ class MaskTestMixin(object):
...
@@ -114,6 +116,9 @@ class MaskTestMixin(object):
else
:
else
:
# if det_bboxes is rescaled to the original image size, we need to
# if det_bboxes is rescaled to the original image size, we need to
# rescale it back to the testing scale to obtain RoIs.
# rescale it back to the testing scale to obtain RoIs.
if
rescale
and
not
isinstance
(
scale_factor
,
float
):
scale_factor
=
torch
.
from_numpy
(
scale_factor
).
to
(
det_bboxes
.
device
)
_bboxes
=
(
_bboxes
=
(
det_bboxes
[:,
:
4
]
*
scale_factor
if
rescale
else
det_bboxes
)
det_bboxes
[:,
:
4
]
*
scale_factor
if
rescale
else
det_bboxes
)
mask_rois
=
bbox2roi
([
_bboxes
])
mask_rois
=
bbox2roi
([
_bboxes
])
...
...
mmdet/models/mask_heads/fcn_mask_head.py
View file @
c01ab3b1
...
@@ -159,6 +159,8 @@ class FCNMaskHead(nn.Module):
...
@@ -159,6 +159,8 @@ class FCNMaskHead(nn.Module):
scale_factor
=
1.0
scale_factor
=
1.0
for
i
in
range
(
bboxes
.
shape
[
0
]):
for
i
in
range
(
bboxes
.
shape
[
0
]):
if
not
isinstance
(
scale_factor
,
(
float
,
np
.
ndarray
)):
scale_factor
=
scale_factor
.
cpu
().
numpy
()
bbox
=
(
bboxes
[
i
,
:]
/
scale_factor
).
astype
(
np
.
int32
)
bbox
=
(
bboxes
[
i
,
:]
/
scale_factor
).
astype
(
np
.
int32
)
label
=
labels
[
i
]
label
=
labels
[
i
]
w
=
max
(
bbox
[
2
]
-
bbox
[
0
]
+
1
,
1
)
w
=
max
(
bbox
[
2
]
-
bbox
[
0
]
+
1
,
1
)
...
...
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