diff --git a/ppdet/metrics/keypoint_metrics.py b/ppdet/metrics/keypoint_metrics.py index 0f5c8c973ea3d6ad05e18a20647df268438ae9e7..79c6596ae38fd1d75c442db4742b9e2e29d71e70 100644 --- a/ppdet/metrics/keypoint_metrics.py +++ b/ppdet/metrics/keypoint_metrics.py @@ -21,6 +21,7 @@ from pycocotools.cocoeval import COCOeval from ..modeling.keypoint_utils import oks_nms from scipy.io import loadmat, savemat from ppdet.utils.logger import setup_logger +import paddle logger = setup_logger(__name__) __all__ = ['KeyPointTopDownCOCOEval', 'KeyPointTopDownMPIIEval'] @@ -70,15 +71,23 @@ class KeyPointTopDownCOCOEval(object): self.results['all_preds'][self.idx:self.idx + num_images, :, 0: 3] = kpts[:, :, 0:3] self.results['all_boxes'][self.idx:self.idx + num_images, 0:2] = inputs[ - 'center'].numpy()[:, 0:2] + 'center'].numpy()[:, 0:2] if isinstance( + inputs['center'], paddle.Tensor) else inputs['center'] self.results['all_boxes'][self.idx:self.idx + num_images, 2:4] = inputs[ - 'scale'].numpy()[:, 0:2] + 'scale'].numpy()[:, 0:2] if isinstance( + inputs['scale'], paddle.Tensor) else inputs['scale'] self.results['all_boxes'][self.idx:self.idx + num_images, 4] = np.prod( - inputs['scale'].numpy() * 200, 1) - self.results['all_boxes'][self.idx:self.idx + num_images, - 5] = np.squeeze(inputs['score'].numpy()) - self.results['image_path'].extend(inputs['im_id'].numpy()) - + inputs['scale'].numpy() * 200, + 1) if isinstance(inputs['scale'], paddle.Tensor) else np.prod( + inputs['scale'] * 200, 1) + self.results['all_boxes'][ + self.idx:self.idx + num_images, + 5] = np.squeeze(inputs['score'].numpy()) if isinstance( + inputs['score'], paddle.Tensor) else np.squeeze(inputs['score']) + if isinstance(inputs['im_id'], paddle.Tensor): + self.results['image_path'].extend(inputs['im_id'].numpy()) + else: + self.results['image_path'].extend(inputs['im_id']) self.idx += num_images def _write_coco_keypoint_results(self, keypoints):