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
c29ebbc5
Commit
c29ebbc5
authored
Dec 12, 2018
by
yhcao6
Browse files
fix
parent
5f6bbcf4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
16 deletions
+10
-16
mmdet/core/bbox/samplers/base_sampler.py
mmdet/core/bbox/samplers/base_sampler.py
+4
-5
mmdet/core/bbox/samplers/ohem_sampler.py
mmdet/core/bbox/samplers/ohem_sampler.py
+5
-6
mmdet/core/bbox/samplers/random_sampler.py
mmdet/core/bbox/samplers/random_sampler.py
+1
-5
No files found.
mmdet/core/bbox/samplers/base_sampler.py
View file @
c29ebbc5
...
...
@@ -58,9 +58,8 @@ class BaseSampler(metaclass=ABCMeta):
gt_flags
=
torch
.
cat
([
gt_ones
,
gt_flags
])
num_expected_pos
=
int
(
self
.
num
*
self
.
pos_fraction
)
kwargs
.
update
(
dict
(
bboxes
=
bboxes
))
pos_inds
=
self
.
pos_sampler
.
_sample_pos
(
assign_result
,
num_expected_pos
,
**
kwargs
)
pos_inds
=
self
.
pos_sampler
.
_sample_pos
(
assign_result
,
num_expected_pos
,
bboxes
=
bboxes
,
**
kwargs
)
# We found that sampled indices have duplicated items occasionally.
# (may be a bug of PyTorch)
pos_inds
=
pos_inds
.
unique
()
...
...
@@ -71,8 +70,8 @@ class BaseSampler(metaclass=ABCMeta):
neg_upper_bound
=
int
(
self
.
neg_pos_ub
*
_pos
)
if
num_expected_neg
>
neg_upper_bound
:
num_expected_neg
=
neg_upper_bound
neg_inds
=
self
.
neg_sampler
.
_sample_neg
(
assign_result
,
num_expected_neg
,
**
kwargs
)
neg_inds
=
self
.
neg_sampler
.
_sample_neg
(
assign_result
,
num_expected_neg
,
bboxes
=
bboxes
,
**
kwargs
)
neg_inds
=
neg_inds
.
unique
()
return
SamplingResult
(
pos_inds
,
neg_inds
,
bboxes
,
gt_bboxes
,
...
...
mmdet/core/bbox/samplers/ohem_sampler.py
View file @
c29ebbc5
...
...
@@ -9,17 +9,16 @@ class OHEMSampler(BaseSampler):
def
__init__
(
self
,
num
,
pos_fraction
,
neg_pos_ub
,
add_gt_as_proposals
,
context
,
neg_pos_ub
=-
1
,
add_gt_as_proposals
=
True
,
**
kwargs
):
super
(
OHEMSampler
,
self
).
__init__
(
num
,
pos_fraction
,
neg_pos_ub
,
add_gt_as_proposals
,
**
kwargs
)
add_gt_as_proposals
)
self
.
bbox_roi_extractor
=
context
.
bbox_roi_extractor
self
.
bbox_head
=
context
.
bbox_head
def
hard_mining
(
self
,
inds
,
num_expected
,
bboxes
,
labels
,
feats
):
# hard mining from the gallery.
with
torch
.
no_grad
():
rois
=
bbox2roi
([
bboxes
])
bbox_feats
=
self
.
bbox_roi_extractor
(
...
...
@@ -42,7 +41,7 @@ class OHEMSampler(BaseSampler):
bboxes
=
None
,
feats
=
None
,
**
kwargs
):
#
Hard s
ample some positive samples
#
S
ample some
hard
positive samples
pos_inds
=
torch
.
nonzero
(
assign_result
.
gt_inds
>
0
)
if
pos_inds
.
numel
()
!=
0
:
pos_inds
=
pos_inds
.
squeeze
(
1
)
...
...
@@ -58,7 +57,7 @@ class OHEMSampler(BaseSampler):
bboxes
=
None
,
feats
=
None
,
**
kwargs
):
#
Hard s
ample some negative samples
#
S
ample some
hard
negative samples
neg_inds
=
torch
.
nonzero
(
assign_result
.
gt_inds
==
0
)
if
neg_inds
.
numel
()
!=
0
:
neg_inds
=
neg_inds
.
squeeze
(
1
)
...
...
mmdet/core/bbox/samplers/random_sampler.py
View file @
c29ebbc5
...
...
@@ -13,11 +13,7 @@ class RandomSampler(BaseSampler):
add_gt_as_proposals
=
True
,
**
kwargs
):
super
(
RandomSampler
,
self
).
__init__
(
num
,
pos_fraction
,
neg_pos_ub
,
add_gt_as_proposals
,
**
kwargs
)
self
.
num
=
num
self
.
pos_fraction
=
pos_fraction
self
.
neg_pos_ub
=
neg_pos_ub
self
.
add_gt_as_proposals
=
add_gt_as_proposals
add_gt_as_proposals
)
@
staticmethod
def
random_choice
(
gallery
,
num
):
...
...
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