未验证 提交 3abb6cfc 编写于 作者: J jerrywgz 提交者: GitHub

fix code in mask rcnn for py3 (#1765)

* fix code in mask rcnn for py3

* fix bug in face detection
上级 4d78bac7
...@@ -121,7 +121,7 @@ def detect_face(image, shrink): ...@@ -121,7 +121,7 @@ def detect_face(image, shrink):
return_numpy=False) return_numpy=False)
detection = np.array(detection) detection = np.array(detection)
# layout: xmin, ymin, xmax. ymax, score # layout: xmin, ymin, xmax. ymax, score
if detection.shape == (1, ): if np.prod(detection.shape) == 1:
print("No face detected") print("No face detected")
return np.array([[0, 0, 0, 0, 0]]) return np.array([[0, 0, 0, 0, 0]])
det_conf = detection[:, 1] det_conf = detection[:, 1]
......
...@@ -185,7 +185,7 @@ def get_segms_res(batch_size, lod, segms_out, data, num_id_to_cat_id_map): ...@@ -185,7 +185,7 @@ def get_segms_res(batch_size, lod, segms_out, data, num_id_to_cat_id_map):
cat_id = num_id_to_cat_id_map[num_id] cat_id = num_id_to_cat_id_map[num_id]
if six.PY3: if six.PY3:
if 'counts' in segm: if 'counts' in segm:
segm['counts'] = rle['counts'].decode("utf8") segm['counts'] = segm['counts'].decode("utf8")
segm_res = { segm_res = {
'image_id': image_id, 'image_id': image_id,
'category_id': cat_id, 'category_id': cat_id,
......
...@@ -19,8 +19,6 @@ from paddle.fluid.initializer import Normal ...@@ -19,8 +19,6 @@ from paddle.fluid.initializer import Normal
from paddle.fluid.initializer import MSRA from paddle.fluid.initializer import MSRA
from paddle.fluid.regularizer import L2Decay from paddle.fluid.regularizer import L2Decay
from config import cfg from config import cfg
import cPickle as cp
import numpy as np
class RCNN(object): class RCNN(object):
...@@ -43,6 +41,8 @@ class RCNN(object): ...@@ -43,6 +41,8 @@ class RCNN(object):
self.rpn_heads(body_conv) self.rpn_heads(body_conv)
# Fast RCNN # Fast RCNN
self.fast_rcnn_heads(body_conv) self.fast_rcnn_heads(body_conv)
if not self.is_train:
self.eval_bbox()
# Mask RCNN # Mask RCNN
if cfg.MASK_ON: if cfg.MASK_ON:
self.mask_rcnn_heads(body_conv) self.mask_rcnn_heads(body_conv)
...@@ -298,8 +298,6 @@ class RCNN(object): ...@@ -298,8 +298,6 @@ class RCNN(object):
name='bbox_pred_b', name='bbox_pred_b',
learning_rate=2., learning_rate=2.,
regularizer=L2Decay(0.))) regularizer=L2Decay(0.)))
if not self.is_train:
self.eval_bbox()
def SuffixNet(self, conv5): def SuffixNet(self, conv5):
mask_out = fluid.layers.conv2d_transpose( mask_out = fluid.layers.conv2d_transpose(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册