From be4269fbaace8f2dad5a23e60a1451e82b12b946 Mon Sep 17 00:00:00 2001 From: Guanghua Yu <742925032@qq.com> Date: Tue, 2 Mar 2021 20:05:01 +0800 Subject: [PATCH] fix RCNN model deploy infer (#2276) --- dygraph/ppdet/modeling/heads/roi_extractor.py | 3 +-- dygraph/ppdet/modeling/post_process.py | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/dygraph/ppdet/modeling/heads/roi_extractor.py b/dygraph/ppdet/modeling/heads/roi_extractor.py index abdeb0163..1e2f658a7 100644 --- a/dygraph/ppdet/modeling/heads/roi_extractor.py +++ b/dygraph/ppdet/modeling/heads/roi_extractor.py @@ -79,8 +79,7 @@ class RoIAlign(object): sampling_ratio=self.sampling_ratio, rois_num=rois_num_dist[lvl], aligned=self.aligned) - if roi_feat.shape[0] > 0: - rois_feat_list.append(roi_feat) + rois_feat_list.append(roi_feat) rois_feat_shuffle = paddle.concat(rois_feat_list) rois_feat = paddle.gather(rois_feat_shuffle, restore_index) diff --git a/dygraph/ppdet/modeling/post_process.py b/dygraph/ppdet/modeling/post_process.py index 7e1e961bc..2b2fc4483 100644 --- a/dygraph/ppdet/modeling/post_process.py +++ b/dygraph/ppdet/modeling/post_process.py @@ -85,9 +85,6 @@ class BBoxPostProcess(object): scale_y, scale_x = scale_factor[i][0], scale_factor[i][1] scale = paddle.concat([scale_x, scale_y, scale_x, scale_y]) expand_scale = paddle.expand(scale, [bbox_num[i], 4]) - # TODO: Because paddle.expand transform error when dygraph - # to static, use reshape to avoid mistakes. - expand_scale = paddle.reshape(expand_scale, [bbox_num[i], 4]) origin_shape_list.append(expand_shape) scale_factor_list.append(expand_scale) @@ -158,7 +155,7 @@ class MaskPostProcess(object): # TODO: support bs > 1 and mask output dtype is bool pred_result = paddle.zeros( [num_mask, origin_shape[0][0], origin_shape[0][1]], dtype='int32') - if bboxes.shape[0] == 0: + if bbox_num == 1 and bboxes[0][0] == -1: return pred_result # TODO: optimize chunk paste -- GitLab