diff --git a/ppdet/modeling/architecture/cascade_rcnn.py b/ppdet/modeling/architecture/cascade_rcnn.py index bdcb6cb51230a606a4b267ff5a61a8272d1ca881..ccc1ef4abda26a5bf61f92055038269eb4ee19aa 100644 --- a/ppdet/modeling/architecture/cascade_rcnn.py +++ b/ppdet/modeling/architecture/cascade_rcnn.py @@ -122,6 +122,5 @@ class CascadeRCNN(BaseArch): 'bbox_nums': self.gbd['predicted_bbox_nums'].numpy(), 'mask': self.gbd['predicted_mask'].numpy(), 'im_id': self.gbd['im_id'].numpy(), - 'im_shape': self.gbd['im_shape'].numpy() } return inputs diff --git a/ppdet/modeling/architecture/faster_rcnn.py b/ppdet/modeling/architecture/faster_rcnn.py index 33c6945f1420ef0cde55c9a0740191516e836328..50faec0213379fd23434b1a68c73cc2e9a7a76dc 100644 --- a/ppdet/modeling/architecture/faster_rcnn.py +++ b/ppdet/modeling/architecture/faster_rcnn.py @@ -73,7 +73,6 @@ class FasterRCNN(BaseArch): outs = { "bbox": self.gbd['predicted_bbox'].numpy(), "bbox_nums": self.gbd['predicted_bbox_nums'].numpy(), - 'im_id': self.gbd['im_id'].numpy(), - 'im_shape': self.gbd['im_shape'].numpy() + 'im_id': self.gbd['im_id'].numpy() } return outs diff --git a/ppdet/modeling/architecture/mask_rcnn.py b/ppdet/modeling/architecture/mask_rcnn.py index 1b462c2e40e4bf3cbbb0f5f88750696365c251e5..640fdd6f44199bee65008cb5beef431147467362 100644 --- a/ppdet/modeling/architecture/mask_rcnn.py +++ b/ppdet/modeling/architecture/mask_rcnn.py @@ -96,7 +96,6 @@ class MaskRCNN(BaseArch): 'bbox': self.gbd['predicted_bbox'].numpy(), 'bbox_nums': self.gbd['predicted_bbox_nums'].numpy(), 'mask': self.gbd['predicted_mask'].numpy(), - 'im_id': self.gbd['im_id'].numpy(), - 'im_shape': self.gbd['im_shape'].numpy() + 'im_id': self.gbd['im_id'].numpy() } return inputs diff --git a/ppdet/modeling/architecture/yolo.py b/ppdet/modeling/architecture/yolo.py index 8235604a15a7af7315d8be015ccde134cb9e9ce8..c26ba8f5b2bd67d8ae6ffe2bcf549c570e5341d3 100644 --- a/ppdet/modeling/architecture/yolo.py +++ b/ppdet/modeling/architecture/yolo.py @@ -48,6 +48,7 @@ class YOLOv3(BaseArch): def infer(self, ): outs = { "bbox": self.gbd['predicted_bbox'].numpy(), - "bbox_nums": self.gbd['predicted_bbox_nums'] + "bbox_nums": self.gbd['predicted_bbox_nums'], + 'im_id': self.gbd['im_id'].numpy() } return outs diff --git a/ppdet/py_op/post_process.py b/ppdet/py_op/post_process.py index bcbb027caac6d460c395942b0154a487f50e3d12..80538923676163440d2c6f42fbf4a49fc241ccb6 100755 --- a/ppdet/py_op/post_process.py +++ b/ppdet/py_op/post_process.py @@ -120,12 +120,7 @@ def mask_post_process(bbox_nums, bboxes, masks, im_info): @jit -def get_det_res(bbox_nums, - bbox, - image_id, - image_shape, - num_id_to_cat_id_map, - batch_size=1): +def get_det_res(bbox_nums, bbox, image_id, num_id_to_cat_id_map, batch_size=1): det_res = [] bbox_v = np.array(bbox) if bbox_v.shape == ( @@ -139,8 +134,6 @@ def get_det_res(bbox_nums, for i in range(batch_size): dt_num_this_img = bbox_nums[i + 1] - bbox_nums[i] image_id = int(image_id[i][0]) - image_width = int(image_shape[i][1]) #int(data[i][-1][1]) - image_height = int(image_shape[i][2]) #int(data[i][-1][2]) for j in range(dt_num_this_img): dt = bbox_v[k] k = k + 1 diff --git a/ppdet/utils/eval_utils.py b/ppdet/utils/eval_utils.py index b06accad194482477ba3085ae65721492d658694..4dfddbf7f98f8085677a3c4129714d1763e67ac1 100644 --- a/ppdet/utils/eval_utils.py +++ b/ppdet/utils/eval_utils.py @@ -2,6 +2,8 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import os + def json_eval_results(metric, json_directory=None, dataset=None): """ @@ -39,14 +41,16 @@ def coco_eval_results(outs_res=None, from ppdet.py_op.post_process import get_det_res, get_seg_res anno_file = os.path.join(dataset.dataset_dir, dataset.anno_path) cocoGt = COCO(anno_file) - catid = {i + 1: v for i, v in enumerate(cocoGt.getCatIds())} + catid = { + i + dataset.with_background: v + for i, v in enumerate(cocoGt.getCatIds()) + } if outs_res is not None and len(outs_res) > 0: det_res = [] for outs in outs_res: det_res += get_det_res(outs['bbox_nums'], outs['bbox'], - outs['im_id'], outs['im_shape'], catid, - batch_size) + outs['im_id'], catid, batch_size) with io.open("bbox_eval.json", 'w') as outfile: encode_func = unicode if six.PY2 else str