From b3e0bd3a00cfe0040b9b43b7d0f2f189117ed0f0 Mon Sep 17 00:00:00 2001 From: wangguanzhong Date: Thu, 16 Dec 2021 22:47:03 +0800 Subject: [PATCH] fix rcnn export (#4920) --- ppdet/modeling/post_process.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py index 0c4717cb6..099765e33 100644 --- a/ppdet/modeling/post_process.py +++ b/ppdet/modeling/post_process.py @@ -42,10 +42,6 @@ class BBoxPostProcess(nn.Layer): self.num_classes = num_classes self.decode = decode self.nms = nms - self.fake_bboxes = paddle.to_tensor( - np.array( - [[-1, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype='float32')) - self.fake_bbox_num = paddle.to_tensor(np.array([1], dtype='int32')) def forward(self, head_out, rois, im_shape, scale_factor): """ @@ -94,11 +90,16 @@ class BBoxPostProcess(nn.Layer): bboxes_list = [] bbox_num_list = [] id_start = 0 + fake_bboxes = paddle.to_tensor( + np.array( + [[-1, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype='float32')) + fake_bbox_num = paddle.to_tensor(np.array([1], dtype='int32')) + # add fake bbox when output is empty for each batch for i in range(bbox_num.shape[0]): if bbox_num[i] == 0: - bboxes_i = self.fake_bboxes - bbox_num_i = self.fake_bbox_num + bboxes_i = fake_bboxes + bbox_num_i = fake_bbox_num id_start += 1 else: bboxes_i = bboxes[id_start:id_start + bbox_num[i], :] -- GitLab