在动态图下 nms 出来的 pred_boxes.shape 是 [N, 6] 但静态图就变为了 [N, 1] 导致报错
bbox_pred, bbox_num, _ = self.nms(pred_boxes, pred_scores)
if bbox_pred.shape[0] == 0:
pred_result = paddle.to_tensor(np.array([[-1, 0.0, 0.0, 0.0, 0.0, 0.0]], dtype='float32'))
bbox_num = paddle.to_tensor(np.array([1], dtype='int32'))
return pred_result, bbox_num
print("bbox_pred", bbox_pred.shape)
pred_label = bbox_pred[:, 0:1]
pred_score = bbox_pred[:, 1:2]
pred_bbox = bbox_pred[:, 2:]
keep_mask = nonempty_bbox(pred_bbox, return_mask=True)
keep_mask = paddle.unsqueeze(keep_mask, [1])
pred_label = paddle.where(keep_mask, pred_label,
paddle.ones_like(pred_label) * -1)
pred_result = paddle.concat([pred_label, pred_score, pred_bbox], axis=1)
return pred_result, bbox_num
# 部分打印如下
bbox_pred
(-1, 1)
Traceback (most recent call last):
File "tools/export_model.py", line 114, in <module>
main()
File "tools/export_model.py", line 110, in main
run(FLAGS, cfg)
File "tools/export_model.py", line 78, in run
.....
File "/home/aistudio/ppdet/modeling/architectures/meta_arch.py", line 28, in forward
out = self.get_pred()
File "/home/aistudio/ppdet/modeling/architectures/retinanet.py", line 84, in get_pred
bbox_pred, bbox_num = self._forward()
File "/home/aistudio/ppdet/modeling/architectures/retinanet.py", line 66, in _forward
self.inputs
File "/home/aistudio/ppdet/modeling/post_process.py", line 769, in __call__
pred_label = bbox_pred[:, 0:1]
pred_score = bbox_pred[:, 1:2]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
pred_bbox = bbox_pred[:, 2:]
keep_mask = nonempty_bbox(pred_bbox, return_mask=True)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 1783, in __getitem__
return _getitem_impl_(self, item)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/variable_index.py", line 463, in _getitem_impl_
attrs=attrs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3184, in append_op
attrs=kwargs.get("attrs", None))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2344, in __init__
self.desc.infer_shape(self.block.desc)
ValueError: (InvalidArgument) When step > 0, end should be greater than start, but received end = 1, start = 1.
[Hint: Expected end > start, but received end:1 <= start:1.] (at /paddle/paddle/fluid/operators/slice_utils.h:59)
[operator < slice > error]
3条答案
按热度按时间e5nszbig1#
您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档 、 常见问题 、 历史Issue 、 AI社区 来寻求解答。祝您生活愉快~
Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API , FAQ , Github Issue and AI community to get the answer.Have a nice day!
nhaq1z212#
@FL77N 您在做动转静的时候,输入的input_spec是否固定了shape呢?
ecbunoof3#
@FL77N 您在做动转静的时候,输入的input_spec是否固定了shape呢?
是变长的,已经通过修改代码的编写方式解决了