本文整理汇总了Python中model.config.cfg.RPN_CHANNELS属性的典型用法代码示例。如果您正苦于以下问题:Python cfg.RPN_CHANNELS属性的具体用法?Python cfg.RPN_CHANNELS怎么用?Python cfg.RPN_CHANNELS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类model.config.cfg
的用法示例。
在下文中一共展示了cfg.RPN_CHANNELS属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_modules
# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import RPN_CHANNELS [as 别名]
def _init_modules(self):
self._init_head_tail()
# rpn
self.rpn_net = nn.Conv2d(self._net_conv_channels, cfg.RPN_CHANNELS, [3, 3], padding=1)
self.rpn_cls_score_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 2, [1, 1])
self.rpn_bbox_pred_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 4, [1, 1])
self.cls_score_net_fast = nn.Linear(self._fc7_channels, self._num_classes+1)
self.bbox_pred_net_fast = nn.Linear(self._fc7_channels, (self._num_classes+1) * 4)
self.cls_score_net = nn.Linear(self._fc7_channels, self._num_classes) # between class
self.bbox_pred_net = nn.Linear(self._fc7_channels, self._num_classes) # between boxes
self.init_weights()
开发者ID:Sunarker,项目名称:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代码行数:20,代码来源:network.py
示例2: _region_proposal
# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import RPN_CHANNELS [as 别名]
def _region_proposal(self, net_conv, is_training, initializer, suffix=''):
rpn = slim.conv2d(net_conv, cfg.RPN_CHANNELS, [3, 3], trainable=is_training and cfg.STAGE_TYPE == 'rpn',
weights_initializer=initializer, scope='rpn_conv'+suffix)
self._act_summaries.append(rpn)
rpn_cls_score = slim.conv2d(rpn, self._num_anchors * 2, [1, 1], trainable=is_training and cfg.STAGE_TYPE == 'rpn',
weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_cls_score'+suffix)
# change it so that the score has 2 as its channel size
rpn_cls_score_reshape = self._reshape_layer(rpn_cls_score, 2, 'rpn_cls_score_reshape'+suffix)
rpn_cls_prob_reshape = self._softmax_layer(rpn_cls_score_reshape, "rpn_cls_prob_reshape"+suffix)
rpn_cls_pred = tf.argmax(tf.reshape(rpn_cls_score_reshape, [-1, 2]), axis=1, name="rpn_cls_pred"+suffix)
rpn_cls_prob = self._reshape_layer(rpn_cls_prob_reshape, self._num_anchors * 2, "rpn_cls_prob"+suffix)
rpn_bbox_pred = slim.conv2d(rpn, self._num_anchors * 4, [1, 1], trainable=is_training and cfg.STAGE_TYPE == 'rpn',
weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_bbox_pred'+suffix)
rois, roi_scores, rpn_scores = self._proposal_layer(rpn_cls_prob, rpn_bbox_pred, rpn_cls_score, 'TEST', 'rois'+suffix)
self._predictions["rpn_cls_score_reshape"+suffix] = rpn_cls_score_reshape
self._predictions["rpn_cls_prob"+suffix] = rpn_cls_prob
self._predictions["rpn_cls_pred"+suffix] = rpn_cls_pred
self._predictions["rpn_bbox_pred"+suffix] = rpn_bbox_pred
self._predictions["rois"+suffix] = rois
self._predictions["roi_scores" + suffix] = roi_scores
self._predictions["rpn_scores" + suffix] = rpn_scores
示例3: _init_modules
# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import RPN_CHANNELS [as 别名]
def _init_modules(self):
self._init_head_tail()
# rpn
self.rpn_net = nn.Conv2d(self._net_conv_channels, cfg.RPN_CHANNELS, [3, 3], padding=1)
self.rpn_cls_score_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 2, [1, 1])
self.rpn_bbox_pred_net = nn.Conv2d(cfg.RPN_CHANNELS, self._num_anchors * 4, [1, 1])
self.cls_score_net = nn.Linear(self._fc7_channels, self._num_classes)
self.bbox_pred_net = nn.Linear(self._fc7_channels, self._num_classes * 4)
self.init_weights()
示例4: _region_proposal
# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import RPN_CHANNELS [as 别名]
def _region_proposal(self, net_conv, is_training, initializer):
rpn = slim.conv2d(net_conv, cfg.RPN_CHANNELS, [3, 3], trainable=is_training, weights_initializer=initializer,
scope="rpn_conv/3x3")
self._act_summaries.append(rpn)
rpn_cls_score = slim.conv2d(rpn, self._num_anchors * 2, [1, 1], trainable=is_training,
weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_cls_score')
# change it so that the score has 2 as its channel size
rpn_cls_score_reshape = self._reshape_layer(rpn_cls_score, 2, 'rpn_cls_score_reshape')
rpn_cls_prob_reshape = self._softmax_layer(rpn_cls_score_reshape, "rpn_cls_prob_reshape")
rpn_cls_pred = tf.argmax(tf.reshape(rpn_cls_score_reshape, [-1, 2]), axis=1, name="rpn_cls_pred")
rpn_cls_prob = self._reshape_layer(rpn_cls_prob_reshape, self._num_anchors * 2, "rpn_cls_prob")
rpn_bbox_pred = slim.conv2d(rpn, self._num_anchors * 4, [1, 1], trainable=is_training,
weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_bbox_pred')
if is_training:
rois, roi_scores = self._proposal_layer(rpn_cls_prob, rpn_bbox_pred, "rois")
rpn_labels = self._anchor_target_layer(rpn_cls_score, "anchor")
# Try to have a deterministic order for the computing graph, for reproducibility
with tf.control_dependencies([rpn_labels]):
rois, _ = self._proposal_target_layer(rois, roi_scores, "rpn_rois")
else:
if cfg.TEST.MODE == 'nms':
rois, _ = self._proposal_layer(rpn_cls_prob, rpn_bbox_pred, "rois")
elif cfg.TEST.MODE == 'top':
rois, _ = self._proposal_top_layer(rpn_cls_prob, rpn_bbox_pred, "rois")
else:
raise NotImplementedError
self._predictions["rpn_cls_score"] = rpn_cls_score
self._predictions["rpn_cls_score_reshape"] = rpn_cls_score_reshape
self._predictions["rpn_cls_prob"] = rpn_cls_prob
self._predictions["rpn_cls_pred"] = rpn_cls_pred
self._predictions["rpn_bbox_pred"] = rpn_bbox_pred
self._predictions["rois"] = rois
return rois
示例5: _region_proposal
# 需要导入模块: from model.config import cfg [as 别名]
# 或者: from model.config.cfg import RPN_CHANNELS [as 别名]
def _region_proposal(self, net_conv, is_training):
initializer = slim.xavier_initializer(uniform=True)
rpn = slim.conv2d(net_conv, cfg.RPN_CHANNELS, [3, 3], trainable=is_training, weights_initializer=initializer,
scope="rpn_conv/3x3")
self._act_summaries.append(rpn)
hidden_num = 128
# bi_lstm shape: [-1, hidden_num * 2]
bi_lstm = self._BiLstm(rpn, cfg.RPN_CHANNELS, hidden_num, name="bi_lstm")
shape = tf.shape(rpn)
N, H, W, _ = shape[0], shape[1], shape[2], shape[3]
bi_lstm_reshape = tf.reshape(bi_lstm, [N, H, W, hidden_num * 2])
fc = slim.conv2d(bi_lstm_reshape, 512, [1, 1], weights_initializer=initializer,
padding='VALID', scope='conv_fc')
# use 1x1 conv as FC (N, H, W, num_anchors * 2)
rpn_cls_score = slim.conv2d(fc, self._num_anchors * 2, [1, 1], weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_cls_score')
# use 1x1 conv as FC (N, H, W, num_anchors * 4)
rpn_bbox_pred = slim.conv2d(fc, self._num_anchors * 4, [1, 1], weights_initializer=initializer,
padding='VALID', activation_fn=None, scope='rpn_bbox_pred')
# (N, H, W, num_anchors * 2) -> (N, H, W * num_anchors, 2)
rpn_cls_score_reshape = self._reshape_layer(rpn_cls_score, 2, 'rpn_cls_score_reshape')
rpn_cls_prob = self._softmax_layer(rpn_cls_score_reshape, "rpn_cls_prob")
# (N, H, W*num_anchors, 2) -> (N, H, W, num_anchors*2)
rpn_cls_prob_reshape = self._reshape_layer(rpn_cls_prob, self._num_anchors * 2, "rpn_cls_prob_reshape")
if is_training:
self._anchor_target_layer(rpn_cls_score, "anchor")
else:
if cfg.TEST.MODE == 'nms':
rois, _ = self._proposal_layer(rpn_cls_prob_reshape, rpn_bbox_pred, "rois")
elif cfg.TEST.MODE == 'top':
rois, _ = self._proposal_top_layer(rpn_cls_prob, rpn_bbox_pred, "rois")
else:
raise NotImplementedError
self._predictions["rois"] = rois
self._predictions["rpn_cls_score"] = rpn_cls_score
self._predictions["rpn_cls_score_reshape"] = rpn_cls_score_reshape
self._predictions["rpn_cls_prob"] = rpn_cls_prob_reshape
self._predictions["rpn_bbox_pred"] = rpn_bbox_pred