forked from open-mmlab/mmdetection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sampler and assigner registry (open-mmlab#2419)
* add sampler and assigner registry * rename with bbox prefix * restore __init__ * roll back atss_head * change import level * import from sampler/assigner
- Loading branch information
Showing
16 changed files
with
56 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from mmdet.utils import build_from_cfg | ||
from .assigners import BaseAssigner | ||
from .registry import BBOX_ASSIGNERS, BBOX_SAMPLERS | ||
from .samplers import BaseSampler | ||
|
||
|
||
def build_assigner(cfg, **default_args): | ||
if isinstance(cfg, BaseAssigner): | ||
return cfg | ||
return build_from_cfg(cfg, BBOX_ASSIGNERS, default_args) | ||
|
||
|
||
def build_sampler(cfg, **default_args): | ||
if isinstance(cfg, BaseSampler): | ||
return cfg | ||
return build_from_cfg(cfg, BBOX_SAMPLERS, default_args) | ||
|
||
|
||
# TODO remove this function in anchor_target in the future | ||
def assign_and_sample(bboxes, gt_bboxes, gt_bboxes_ignore, gt_labels, cfg): | ||
bbox_assigner = build_assigner(cfg.assigner) | ||
bbox_sampler = build_sampler(cfg.sampler) | ||
assign_result = bbox_assigner.assign(bboxes, gt_bboxes, gt_bboxes_ignore, | ||
gt_labels) | ||
sampling_result = bbox_sampler.sample(assign_result, bboxes, gt_bboxes, | ||
gt_labels) | ||
return assign_result, sampling_result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from mmdet.utils import Registry | ||
|
||
BBOX_ASSIGNERS = Registry('bbox_assigner') | ||
BBOX_SAMPLERS = Registry('bbox_sampler') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters