diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py index 679e09134bf28268d3112928b09b5b3c385a3c5b..30ebe80297b3caf28bb2a1b8285ebdfb23839631 100644 --- a/ppdet/modeling/post_process.py +++ b/ppdet/modeling/post_process.py @@ -91,9 +91,23 @@ class BBoxPostProcess(nn.Layer): including labels, scores and bboxes. """ - if bboxes.shape[0] == 0: - bboxes = self.fake_bboxes - bbox_num = self.fake_bbox_num + bboxes_list = [] + bbox_num_list = [] + id_start = 0 + # 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 + id_start += 1 + else: + bboxes_i = bboxes[id_start:id_start + bbox_num[i], :] + bbox_num_i = bbox_num[i] + id_start += bbox_num[i] + bboxes_list.append(bboxes_i) + bbox_num_list.append(bbox_num_i) + bboxes = paddle.concat(bboxes_list) + bbox_num = paddle.concat(bbox_num_list) origin_shape = paddle.floor(im_shape / scale_factor + 0.5) @@ -156,6 +170,7 @@ class MaskPostProcess(object): """ Paste the mask prediction to the original image. """ + x0, y0, x1, y1 = paddle.split(boxes, 4, axis=1) masks = paddle.unsqueeze(masks, [0, 1]) img_y = paddle.arange(0, im_h, dtype='float32') + 0.5