本文整理匯總了Python中maskrcnn_benchmark.modeling.registry.RPN_HEADS屬性的典型用法代碼示例。如果您正苦於以下問題:Python registry.RPN_HEADS屬性的具體用法?Python registry.RPN_HEADS怎麽用?Python registry.RPN_HEADS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類maskrcnn_benchmark.modeling.registry
的用法示例。
在下文中一共展示了registry.RPN_HEADS屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from maskrcnn_benchmark.modeling import registry [as 別名]
# 或者: from maskrcnn_benchmark.modeling.registry import RPN_HEADS [as 別名]
def __init__(self, cfg, in_channels):
super(RPNModule, self).__init__()
self.cfg = cfg.clone()
anchor_generator = make_anchor_generator(cfg)
rpn_head = registry.RPN_HEADS[cfg.MODEL.RPN.RPN_HEAD]
head = rpn_head(
cfg, in_channels, anchor_generator.num_anchors_per_location()[0]
)
rpn_box_coder = BoxCoder(weights=(1.0, 1.0, 1.0, 1.0))
box_selector_train = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=True)
box_selector_test = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=False)
loss_evaluator = make_rpn_loss_evaluator(cfg, rpn_box_coder)
self.anchor_generator = anchor_generator
self.head = head
self.box_selector_train = box_selector_train
self.box_selector_test = box_selector_test
self.loss_evaluator = loss_evaluator
示例2: __init__
# 需要導入模塊: from maskrcnn_benchmark.modeling import registry [as 別名]
# 或者: from maskrcnn_benchmark.modeling.registry import RPN_HEADS [as 別名]
def __init__(self, cfg):
super(RPNModule, self).__init__()
self.cfg = cfg.clone()
anchor_generator = make_anchor_generator(cfg)
in_channels = cfg.MODEL.BACKBONE.OUT_CHANNELS
rpn_head = registry.RPN_HEADS[cfg.MODEL.RPN.RPN_HEAD]
head = rpn_head(
cfg, in_channels, anchor_generator.num_anchors_per_location()[0]
)
rpn_box_coder = BoxCoder(weights=(1.0, 1.0, 1.0, 1.0))
box_selector_train = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=True)
box_selector_test = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=False)
loss_evaluator = make_rpn_loss_evaluator(cfg, rpn_box_coder)
self.anchor_generator = anchor_generator
self.head = head
self.box_selector_train = box_selector_train
self.box_selector_test = box_selector_test
self.loss_evaluator = loss_evaluator
示例3: __init__
# 需要導入模塊: from maskrcnn_benchmark.modeling import registry [as 別名]
# 或者: from maskrcnn_benchmark.modeling.registry import RPN_HEADS [as 別名]
def __init__(self, cfg):
super(RPNModule, self).__init__()
self.cfg = cfg.clone()
anchor_generator = make_anchor_generator(cfg)
in_channels = cfg.MODEL.BACKBONE.OUT_CHANNELS
rpn_head = registry.RPN_HEADS[cfg.MODEL.RPN.RPN_HEAD]
head = rpn_head(
cfg, in_channels, anchor_generator.num_anchors_per_location()[0]
)
rpn_box_coder = RBoxCoder(weights=(1.0, 1.0, 1.0, 1.0, 1.0))
box_selector_train = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=True)
box_selector_test = make_rpn_postprocessor(cfg, rpn_box_coder, is_train=False)
loss_evaluator = make_rpn_loss_evaluator(cfg, rpn_box_coder)
self.anchor_generator = anchor_generator
self.head = head
self.box_selector_train = box_selector_train
self.box_selector_test = box_selector_test
self.loss_evaluator = loss_evaluator
示例4: test_build_rpn_heads
# 需要導入模塊: from maskrcnn_benchmark.modeling import registry [as 別名]
# 或者: from maskrcnn_benchmark.modeling.registry import RPN_HEADS [as 別名]
def test_build_rpn_heads(self):
''' Make sure rpn heads run '''
self.assertGreater(len(registry.RPN_HEADS), 0)
in_channels = 64
num_anchors = 10
for name, builder in registry.RPN_HEADS.items():
print('Testing {}...'.format(name))
if name in RPN_CFGS:
cfg = load_config(RPN_CFGS[name])
else:
# Use default config if config file is not specified
cfg = copy.deepcopy(g_cfg)
rpn = builder(cfg, in_channels, num_anchors)
N, C_in, H, W = 2, in_channels, 24, 32
input = torch.rand([N, C_in, H, W], dtype=torch.float32)
LAYERS = 3
out = rpn([input] * LAYERS)
self.assertEqual(len(out), 2)
logits, bbox_reg = out
for idx in range(LAYERS):
self.assertEqual(
logits[idx].shape,
torch.Size([
input.shape[0], num_anchors,
input.shape[2], input.shape[3],
])
)
self.assertEqual(
bbox_reg[idx].shape,
torch.Size([
logits[idx].shape[0], num_anchors * 4,
logits[idx].shape[2], logits[idx].shape[3],
]),
)