diff --git a/ppdet/modeling/post_process.py b/ppdet/modeling/post_process.py index 78aeacf1c74..a66ba76a8e7 100644 --- a/ppdet/modeling/post_process.py +++ b/ppdet/modeling/post_process.py @@ -160,6 +160,9 @@ def get_pred(self, bboxes, bbox_num, im_shape, scale_factor): else: # simplify the computation for bs=1 when exporting onnx scale_y, scale_x = scale_factor[0][0], scale_factor[0][1] + # TODO(PIR): indexing yields 0-d tensors which concat rejects. + scale_y = paddle.unsqueeze(scale_y, 0) + scale_x = paddle.unsqueeze(scale_x, 0) scale = paddle.concat( [scale_x, scale_y, scale_x, scale_y]).unsqueeze(0) self.origin_shape_list = paddle.expand(origin_shape, diff --git a/ppdet/modeling/proposal_generator/rpn_head.py b/ppdet/modeling/proposal_generator/rpn_head.py index 456a9322fcd..b334437f046 100644 --- a/ppdet/modeling/proposal_generator/rpn_head.py +++ b/ppdet/modeling/proposal_generator/rpn_head.py @@ -242,7 +242,7 @@ def _gen_proposal(self, scores, bbox_deltas, anchors, inputs): if self.export_onnx: output_rois = [onnx_topk_rois] - output_rois_num = paddle.shape(onnx_topk_rois)[0] + output_rois_num = paddle.shape(onnx_topk_rois)[0:1] else: output_rois = bs_rois_collect output_rois_num = bs_rois_num_collect