develop分支中deploy预测保存coco_results存在错误
rsj123 opened this issue · 0 comments
问题确认 Search before asking
Bug组件 Bug Component
Deploy
Bug描述 Describe the Bug
分支为develop分支
运行预测时save_coco_results出现错误
在Rotate任务下错误:
Traceback (most recent call last):
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 1246, in
main()
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 1214, in main
detector.predict_image(
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 431, in predict_image
self.save_coco_results(
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 499, in save_coco_results
box[2], box[3], box[4], box[5], box[6], box[7], box[8],
UnboundLocalError: local variable 'box' referenced before assignment
在默认的检测任务下:
Traceback (most recent call last):
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 1243, in
main()
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 1211, in main
detector.predict_image(
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 431, in predict_image
self.save_coco_results(
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 505, in save_coco_results
bbox_results.extend([{
File "/root/PaddleDetection-develop/deploy/python/infer.py", line 510, in
'bbox': bbox,
NameError: free variable 'bbox' referenced before assignment in enclosing scope. Did you mean: 'box'?
if 'boxes' in results:
boxes = results['boxes'][idx:idx + box_num].tolist()
if task_type == 'Rotate':
bbox = [
box[2], box[3], box[4], box[5], box[6], box[7], box[8],
box[9]
] # x1, y1, x2, y2, x3, y3, x4, y4
else: # default is 'Detection'
bbox: [box[2], box[3], box[4] - box[2],
box[5] - box[3]] # xyxy -> xywh
bbox_results.extend([{
'image_id': img_id,
'category_id': coco_clsid2catid[int(box[0])] \
if use_coco_category else int(box[0]),
'file_name': file_name,
'bbox': bbox,
'score': box[1]} for box in boxes])
其中 bbox: [box[2], box[3], box[4] - box[2], box[5] - box[3]] # xyxy -> xywh
表达式错误
且对bbox 进行赋值应遍历boxes获取单个box
参考原始代码:
bbox_results.extend([{
'image_id': img_id,
'category_id': coco_clsid2catid[int(box[0])] \
if use_coco_category else int(box[0]),
'file_name': file_name,
'bbox': [box[2], box[3], box[4] - box[2],
box[5] - box[3]], # xyxy -> xywh
'score': box[1]} for box in boxes])
复现环境 Environment
- OS: Linux
- PaddleDetection: develop
Bug描述确认 Bug description confirmation
- 我确认已经提供了Bug复现步骤、代码改动说明、以及环境信息,确认问题是可以复现的。I confirm that the bug replication steps, code change instructions, and environment information have been provided, and the problem can be reproduced.
是否愿意提交PR? Are you willing to submit a PR?
- 我愿意提交PR!I'd like to help by submitting a PR!