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
5f6bbcf4
Commit
5f6bbcf4
authored
Dec 12, 2018
by
yhcao6
Browse files
reconstruct interfaces of sampler
parent
96e853f3
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
26 deletions
+35
-26
mmdet/core/bbox/samplers/base_sampler.py
mmdet/core/bbox/samplers/base_sampler.py
+10
-2
mmdet/core/bbox/samplers/combined_sampler.py
mmdet/core/bbox/samplers/combined_sampler.py
+12
-10
mmdet/core/bbox/samplers/ohem_sampler.py
mmdet/core/bbox/samplers/ohem_sampler.py
+6
-8
mmdet/core/bbox/samplers/pseudo_sampler.py
mmdet/core/bbox/samplers/pseudo_sampler.py
+4
-4
mmdet/core/bbox/samplers/random_sampler.py
mmdet/core/bbox/samplers/random_sampler.py
+3
-2
No files found.
mmdet/core/bbox/samplers/base_sampler.py
View file @
5f6bbcf4
...
...
@@ -7,8 +7,16 @@ from .sampling_result import SamplingResult
class
BaseSampler
(
metaclass
=
ABCMeta
):
def
__init__
(
self
,
context
):
self
.
context
=
context
def
__init__
(
self
,
num
,
pos_fraction
,
neg_pos_ub
=-
1
,
add_gt_as_proposals
=
True
,
**
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
self
.
pos_sampler
=
self
self
.
neg_sampler
=
self
...
...
mmdet/core/bbox/samplers/combined_sampler.py
View file @
5f6bbcf4
from
.
random
_sampler
import
Random
Sampler
from
.
base
_sampler
import
Base
Sampler
from
..assign_sampling
import
build_sampler
class
CombinedSampler
(
Random
Sampler
):
class
CombinedSampler
(
Base
Sampler
):
def
__init__
(
self
,
num
,
pos_fraction
,
pos_sampler
,
neg_sampler
,
**
kwargs
):
super
(
CombinedSampler
,
self
).
__init__
(
num
,
pos_fraction
,
**
kwargs
)
default_args
=
dict
(
num
=
num
,
pos_fraction
=
pos_fraction
)
default_args
.
update
(
kwargs
)
self
.
pos_sampler
=
build_sampler
(
pos_sampler
,
default_args
=
default_args
)
self
.
neg_sampler
=
build_sampler
(
neg_sampler
,
default_args
=
default_args
)
def
__init__
(
self
,
pos_sampler
,
neg_sampler
,
**
kwargs
):
super
(
CombinedSampler
,
self
).
__init__
(
**
kwargs
)
self
.
pos_sampler
=
build_sampler
(
pos_sampler
,
**
kwargs
)
self
.
neg_sampler
=
build_sampler
(
neg_sampler
,
**
kwargs
)
def
_sample_pos
(
self
,
**
kwargs
):
raise
NotImplementedError
def
_sample_neg
(
self
,
**
kwargs
):
raise
NotImplementedError
mmdet/core/bbox/samplers/ohem_sampler.py
View file @
5f6bbcf4
...
...
@@ -9,14 +9,12 @@ class OHEMSampler(BaseSampler):
def
__init__
(
self
,
num
,
pos_fraction
,
neg_pos_ub
=-
1
,
add_gt_as_proposals
=
True
,
context
=
None
):
super
(
OHEMSampler
,
self
).
__init__
(
context
)
self
.
num
=
num
self
.
pos_fraction
=
pos_fraction
self
.
neg_pos_ub
=
neg_pos_ub
self
.
add_gt_as_proposals
=
add_gt_as_proposals
neg_pos_ub
,
add_gt_as_proposals
,
context
,
**
kwargs
):
super
(
OHEMSampler
,
self
).
__init__
(
num
,
pos_fraction
,
neg_pos_ub
,
add_gt_as_proposals
,
**
kwargs
)
self
.
bbox_roi_extractor
=
context
.
bbox_roi_extractor
self
.
bbox_head
=
context
.
bbox_head
...
...
mmdet/core/bbox/samplers/pseudo_sampler.py
View file @
5f6bbcf4
...
...
@@ -6,16 +6,16 @@ from .sampling_result import SamplingResult
class
PseudoSampler
(
BaseSampler
):
def
__init__
(
self
):
def
__init__
(
self
,
**
kwargs
):
pass
def
_sample_pos
(
self
):
def
_sample_pos
(
self
,
**
kwargs
):
raise
NotImplementedError
def
_sample_neg
(
self
):
def
_sample_neg
(
self
,
**
kwargs
):
raise
NotImplementedError
def
sample
(
self
,
assign_result
,
bboxes
,
gt_bboxes
):
def
sample
(
self
,
assign_result
,
bboxes
,
gt_bboxes
,
**
kwargs
):
pos_inds
=
torch
.
nonzero
(
assign_result
.
gt_inds
>
0
).
squeeze
(
-
1
).
unique
()
neg_inds
=
torch
.
nonzero
(
...
...
mmdet/core/bbox/samplers/random_sampler.py
View file @
5f6bbcf4
...
...
@@ -11,8 +11,9 @@ class RandomSampler(BaseSampler):
pos_fraction
,
neg_pos_ub
=-
1
,
add_gt_as_proposals
=
True
,
context
=
None
):
super
(
RandomSampler
,
self
).
__init__
(
context
)
**
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
...
...
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