本人在写一个faster rcnn的代码改进,在进行多尺度融合时,出现bug,求大神在线指导。
改进:在faster rcnn上,进行简化的ION、FPN改进,
问题在进行多个rpn时,出现bug。
若代码通过,必谢
测试下回复是否有问题
?
请问怎么通过rpn获取多层的roi?
with tf.variable_scope(self._resnet_scope, self._resnet_scope):
conv_list = [net_conv3 , net_conv4 , net_conv5]
rpn_cls_score_list = []
rpn_cls_prob_list = []
rpn_bbox_pred_lst = []
for i in range(0 , 3):
# build the anchors for the image
self._anchor_component()
# rpn
rpn = slim.conv2d(conv_list[i], 512, [3, 3], trainable=is_training, weights_initializer=initializer,scope="rpn_conv"+str(i) +"/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'+str(i))
# 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'+str(i))
rpn_cls_prob_reshape = self._softmax_layer(rpn_cls_score_reshape, "rpn_cls_prob_reshape"+str(i))
rpn_cls_prob = self._reshape_layer(rpn_cls_prob_reshape, self._num_anchors * 2, "rpn_cls_prob"+str(i))
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'+str(i))
print(rpn_cls_score.shape)
print(rpn_cls_prob)
print(rpn_bbox_pred)
rpn_cls_score_list.append(rpn_cls_score)
rpn_cls_prob_list.append(rpn_cls_prob)
rpn_bbox_pred_lst.append(rpn_bbox_pred)
rpn_cls_score = tf.concat(rpn_cls_score_list, axis=0)
rpn_cls_prob = tf.concat(rpn_cls_prob_list, axis=0)
rpn_bbox_pred = tf.concat(rpn_bbox_pred_lst, axis=0)
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 determinestic 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
https://zhuanlan.zhihu.com/p/31401237
能不能就我的代码,帮我解答一下,万分感谢