未验证 提交 ed6b5e99 编写于 作者: W wangguanzhong 提交者: GitHub

fix mask rcnn, test=dygraph (#2208)

上级 926efec2
......@@ -34,7 +34,7 @@ RPNHead:
nms_thresh: 0.7
pre_nms_top_n: 12000
post_nms_top_n: 2000
topk_after_collect: True
topk_after_collect: False
test_proposal:
min_size: 0.0
nms_thresh: 0.7
......
......@@ -35,7 +35,7 @@ RPNHead:
nms_thresh: 0.7
pre_nms_top_n: 12000
post_nms_top_n: 2000
topk_after_collect: True
topk_after_collect: False
test_proposal:
min_size: 0.0
nms_thresh: 0.7
......
......@@ -555,7 +555,7 @@ class Res5Head(nn.Layer):
def out_shape(self):
return [ShapeSpec(
channels=self.feat_out,
stride=32, )]
stride=16, )]
def forward(self, roi_feat, stage=0):
y = self.res5(roi_feat)
......
......@@ -50,7 +50,7 @@ def delta2bbox(deltas, boxes, weights):
dy = deltas[:, 1::4] / wy
dw = deltas[:, 2::4] / ww
dh = deltas[:, 3::4] / wh
# Prevent sending too large values into np.exp()
# Prevent sending too large values into paddle.exp()
dw = paddle.clip(dw, max=clip_scale)
dh = paddle.clip(dh, max=clip_scale)
......@@ -64,7 +64,7 @@ def delta2bbox(deltas, boxes, weights):
pred_boxes.append(pred_ctr_y - 0.5 * pred_h)
pred_boxes.append(pred_ctr_x + 0.5 * pred_w)
pred_boxes.append(pred_ctr_y + 0.5 * pred_h)
pred_boxes = paddle.concat(pred_boxes, axis=-1)
pred_boxes = paddle.stack(pred_boxes, axis=-1)
return pred_boxes
......
......@@ -128,7 +128,7 @@ class BBoxHead(nn.Layer):
def forward(self, body_feats=None, rois=None, rois_num=None, inputs=None):
"""
body_feats (list[Tensor]): Feature maps from backbone
rois (Tensor): RoIs generated from RPN module
rois (list[Tensor]): RoIs generated from RPN module
rois_num (Tensor): The number of RoIs in each image
inputs (dict{Tensor}): The ground-truth of image
"""
......
......@@ -187,6 +187,7 @@ class CascadeHead(BBoxHead):
pred_proposals = paddle.concat(proposals) if len(
proposals) > 1 else proposals[0]
pred_bbox = delta2bbox(deltas, pred_proposals, weights)
pred_bbox = paddle.reshape(pred_bbox, [-1, deltas.shape[-1]])
num_prop = [p.shape[0] for p in proposals]
return pred_bbox.split(num_prop)
......
......@@ -116,7 +116,6 @@ class RPNHead(nn.Layer):
rois, rois_num = self._gen_proposal(scores, deltas, anchors, inputs,
batch_size)
if self.training:
loss = self.get_loss(scores, deltas, anchors, inputs)
return rois, rois_num, loss
......
......@@ -55,6 +55,8 @@ def get_seg_res(masks, bboxes, mask_nums, image_id, label_to_cat_id_map):
score = float(bboxes[k][1])
label = int(bboxes[k][0])
k = k + 1
if label == -1:
continue
cat_id = label_to_cat_id_map[label]
rle = mask_util.encode(
np.array(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册