本文整理汇总了Python中modeling.collect_and_distribute_fpn_rpn_proposals.CollectAndDistributeFpnRpnProposalsOp方法的典型用法代码示例。如果您正苦于以下问题:Python collect_and_distribute_fpn_rpn_proposals.CollectAndDistributeFpnRpnProposalsOp方法的具体用法?Python collect_and_distribute_fpn_rpn_proposals.CollectAndDistributeFpnRpnProposalsOp怎么用?Python collect_and_distribute_fpn_rpn_proposals.CollectAndDistributeFpnRpnProposalsOp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modeling.collect_and_distribute_fpn_rpn_proposals
的用法示例。
在下文中一共展示了collect_and_distribute_fpn_rpn_proposals.CollectAndDistributeFpnRpnProposalsOp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from modeling import collect_and_distribute_fpn_rpn_proposals [as 别名]
# 或者: from modeling.collect_and_distribute_fpn_rpn_proposals import CollectAndDistributeFpnRpnProposalsOp [as 别名]
def __init__(self, dim_in, spatial_scales):
super().__init__()
self.dim_in = dim_in
self.spatial_scales = spatial_scales
self.dim_out = self.dim_in
num_anchors = len(cfg.FPN.RPN_ASPECT_RATIOS)
# Create conv ops shared by all FPN levels
self.FPN_RPN_conv = nn.Conv2d(dim_in, self.dim_out, 3, 1, 1)
dim_score = num_anchors * 2 if cfg.RPN.CLS_ACTIVATION == 'softmax' \
else num_anchors
self.FPN_RPN_cls_score = nn.Conv2d(self.dim_out, dim_score, 1, 1, 0)
self.FPN_RPN_bbox_pred = nn.Conv2d(self.dim_out, 4 * num_anchors, 1, 1, 0)
self.GenerateProposals_modules = nn.ModuleList()
k_max = cfg.FPN.RPN_MAX_LEVEL # coarsest level of pyramid
k_min = cfg.FPN.RPN_MIN_LEVEL # finest level of pyramid
for lvl in range(k_min, k_max + 1):
sc = self.spatial_scales[k_max - lvl] # in reversed order
lvl_anchors = generate_anchors(
stride=2.**lvl,
sizes=(cfg.FPN.RPN_ANCHOR_START_SIZE * 2.**(lvl - k_min), ),
aspect_ratios=cfg.FPN.RPN_ASPECT_RATIOS
)
self.GenerateProposals_modules.append(GenerateProposalsOp(lvl_anchors, sc))
self.CollectAndDistributeFpnRpnProposals = CollectAndDistributeFpnRpnProposalsOp()
self._init_weights()
示例2: __init__
# 需要导入模块: from modeling import collect_and_distribute_fpn_rpn_proposals [as 别名]
# 或者: from modeling.collect_and_distribute_fpn_rpn_proposals import CollectAndDistributeFpnRpnProposalsOp [as 别名]
def __init__(self, dim_in, spatial_scales):
super().__init__()
self.dim_in = dim_in
self.spatial_scales = spatial_scales
self.dim_out = self.dim_in
num_anchors = len(cfg.FPN.RPN_ASPECT_RATIOS)
# Create conv ops shared by all FPN levels
self.FPN_RPN_conv = nn.Conv2d(dim_in, self.dim_out, 3, 1, 1)
dim_score = num_anchors * 2 if cfg.RPN.CLS_ACTIVATION == 'softmax' \
else num_anchors
self.FPN_RPN_cls_score = nn.Conv2d(self.dim_out, dim_score, 1, 1, 0)
self.FPN_RPN_bbox_pred = nn.Conv2d(self.dim_out, 4 * num_anchors, 1, 1, 0)
self.GenerateProposals_modules = nn.ModuleList()
k_max = cfg.FPN.RPN_MAX_LEVEL # coarsest level of pyramid
k_min = cfg.FPN.RPN_MIN_LEVEL # finest level of pyramid
for lvl in range(k_min, k_max + 1):
sc = self.spatial_scales[k_max - lvl] # in reversed order
lvl_anchors = generate_anchors(
stride=2. ** lvl,
sizes=(cfg.FPN.RPN_ANCHOR_START_SIZE * 2. ** (lvl - k_min),),
aspect_ratios=cfg.FPN.RPN_ASPECT_RATIOS
)
self.GenerateProposals_modules.append(GenerateProposalsOp(lvl_anchors, sc))
self.CollectAndDistributeFpnRpnProposals = CollectAndDistributeFpnRpnProposalsOp()
self._init_weights()