diff --git a/configs/_base_/datasets/h36m.py b/configs/_base_/datasets/h36m.py index 68b7e50ad3..914258d5b3 100644 --- a/configs/_base_/datasets/h36m.py +++ b/configs/_base_/datasets/h36m.py @@ -148,4 +148,5 @@ dict(link=('right_elbow', 'right_wrist'), id=15, color=[255, 128, 0]) }, joint_weights=[1.] * 17, - sigmas=[]) + sigmas=[], + stats_info=dict(bbox_center=(528., 427.), bbox_scale=400.)) diff --git a/mmpose/apis/inference_3d.py b/mmpose/apis/inference_3d.py index 4b6719dffd..ce60ab5c3d 100644 --- a/mmpose/apis/inference_3d.py +++ b/mmpose/apis/inference_3d.py @@ -204,7 +204,7 @@ def _collate_pose_sequence(pose_results, with_track_id=True, target_frame=-1): def inference_pose_lifter_model(model, pose_results_2d, - dataset, + dataset=None, dataset_info=None, with_track_id=True, image_size=None, @@ -245,8 +245,9 @@ def inference_pose_lifter_model(model, if dataset_info is not None: flip_pairs = dataset_info.flip_pairs - bbox_center = dataset_info.bbox_center - bbox_scale = dataset_info.bbox_scale + assert 'stats_info' in dataset_info._dataset_info + bbox_center = dataset_info._dataset_info['stats_info']['bbox_center'] + bbox_scale = dataset_info._dataset_info['stats_info']['bbox_scale'] else: warnings.warn( 'dataset is deprecated.' @@ -283,6 +284,7 @@ def inference_pose_lifter_model(model, else: input_2d_visible = np.ones((T, K, 1), dtype=np.float32) + # TODO: Will be removed in the later versions # Dummy 3D input # This is for compatibility with configs in mmpose<=v0.14.0, where a # 3D input is required to generate denormalization parameters. This @@ -348,11 +350,11 @@ def vis_3d_pose_result(model, result, img=None, dataset='Body3DH36MDataset', + dataset_info=None, kpt_score_thr=0.3, radius=8, thickness=2, num_instances=-1, - dataset_info=None, show=False, out_file=None): """Visualize the 3D pose estimation results. diff --git a/mmpose/datasets/dataset_info.py b/mmpose/datasets/dataset_info.py index 3b9d32a482..ea13bc5a7e 100644 --- a/mmpose/datasets/dataset_info.py +++ b/mmpose/datasets/dataset_info.py @@ -4,21 +4,21 @@ class DatasetInfo: def __init__(self, dataset_info): - self.dataset_info = dataset_info - self.dataset_name = self.dataset_info['dataset_name'] - self.paper_info = self.dataset_info['paper_info'] - self.keypoint_info = self.dataset_info['keypoint_info'] - self.skeleton_info = self.dataset_info['skeleton_info'] + self._dataset_info = dataset_info + self.dataset_name = self._dataset_info['dataset_name'] + self.paper_info = self._dataset_info['paper_info'] + self.keypoint_info = self._dataset_info['keypoint_info'] + self.skeleton_info = self._dataset_info['skeleton_info'] self.joint_weights = np.array( - self.dataset_info['joint_weights'], dtype=np.float32)[:, None] + self._dataset_info['joint_weights'], dtype=np.float32)[:, None] - self.sigmas = np.array(self.dataset_info['sigmas']) + self.sigmas = np.array(self._dataset_info['sigmas']) self._parse_keypoint_info() self._parse_skeleton_info() def _parse_skeleton_info(self): - """Parse skeleton info. + """Parse skeleton information. - link_num (int): number of links. - skeleton (list((2,))): list of links (id). @@ -42,7 +42,7 @@ def _parse_skeleton_info(self): self.pose_link_color = np.array(self.pose_link_color) def _parse_keypoint_info(self): - """Parse keypoint info. + """Parse keypoint information. - keypoint_num (int): number of keypoints. - keypoint_id2name (dict): mapping keypoint id to keypoint name. diff --git a/tests/test_apis/test_inference.py b/tests/test_apis/test_inference.py index 479d594743..b81d7f3027 100644 --- a/tests/test_apis/test_inference.py +++ b/tests/test_apis/test_inference.py @@ -1,9 +1,9 @@ import numpy as np -import pytest from mmpose.apis import (inference_bottom_up_pose_model, inference_top_down_pose_model, init_pose_model, process_mmdet_results, vis_pose_result) +from mmpose.datasets import DatasetInfo def test_top_down_demo(): @@ -15,14 +15,21 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/coco/000000000785.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) person_result = [] person_result.append({'bbox': [50, 50, 50, 100]}) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( - pose_model, image_name, person_result, format='xywh') + pose_model, + image_name, + person_result, + format='xywh', + dataset_info=dataset_info) # show the results - vis_pose_result(pose_model, image_name, pose_results) + vis_pose_result( + pose_model, image_name, pose_results, dataset_info=dataset_info) # AIC demo pose_model = init_pose_model( @@ -31,16 +38,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='TopDownAicDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='TopDownAicDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # OneHand10K demo # build the pose model from a config file and a checkpoint file @@ -50,16 +59,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/onehand10k/9.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='OneHand10KDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='OneHand10KDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # InterHand2DDataset demo # build the pose model from a config file and a checkpoint file @@ -69,16 +80,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/interhand2.6m/image2017.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='InterHand2DDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='InterHand2DDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # Face300WDataset demo # build the pose model from a config file and a checkpoint file @@ -88,16 +101,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/300w/indoor_020.png' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='Face300WDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='Face300WDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # FaceAFLWDataset demo # build the pose model from a config file and a checkpoint file @@ -107,16 +122,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/aflw/image04476.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='FaceAFLWDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='FaceAFLWDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # FaceCOFWDataset demo # build the pose model from a config file and a checkpoint file @@ -126,24 +143,18 @@ def test_top_down_demo(): None, device='cpu') image_name = 'tests/data/cofw/001766.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='FaceCOFWDataset') + dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='FaceCOFWDataset') - - with pytest.raises(NotImplementedError): - pose_results, _ = inference_top_down_pose_model( - pose_model, - image_name, - person_result, - format='xywh', - dataset='test') + pose_model, image_name, pose_results, dataset_info=dataset_info) def test_bottom_up_demo(): @@ -156,12 +167,15 @@ def test_bottom_up_demo(): device='cpu') image_name = 'tests/data/coco/000000000785.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test'].get( + 'dataset_info', None)) - pose_results, _ = inference_bottom_up_pose_model(pose_model, image_name) + pose_results, _ = inference_bottom_up_pose_model( + pose_model, image_name, dataset_info=dataset_info) # show the results vis_pose_result( - pose_model, image_name, pose_results, dataset='BottomUpCocoDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) def test_process_mmdet_results(): diff --git a/tests/test_apis/test_inference_3d.py b/tests/test_apis/test_inference_3d.py index f4ce839675..19b551d463 100644 --- a/tests/test_apis/test_inference_3d.py +++ b/tests/test_apis/test_inference_3d.py @@ -11,7 +11,7 @@ inference_mesh_model, inference_pose_lifter_model, init_pose_model, vis_3d_mesh_result, vis_3d_pose_result) -from mmpose.models import build_posenet +from mmpose.datasets.dataset_info import DatasetInfo def test_pose_lifter_demo(): @@ -31,16 +31,22 @@ def test_pose_lifter_demo(): pose_results_2d = [[pose_det_result]] - dataset = pose_model.cfg.data['test']['type'] + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) pose_results_2d = extract_pose_sequence( pose_results_2d, frame_idx=0, causal=False, seq_len=1, step=1) _ = inference_pose_lifter_model( - pose_model, pose_results_2d, dataset, with_track_id=False) + pose_model, + pose_results_2d, + dataset_info=dataset_info, + with_track_id=False) pose_lift_results = inference_pose_lifter_model( - pose_model, pose_results_2d, dataset, with_track_id=True) + pose_model, + pose_results_2d, + dataset_info=dataset_info, + with_track_id=True) for res in pose_lift_results: res['title'] = 'title' @@ -48,20 +54,19 @@ def test_pose_lifter_demo(): pose_model, pose_lift_results, img=pose_results_2d[0][0]['image_name'], - dataset=dataset) + dataset_info=dataset_info) # test special cases # Empty 2D results _ = inference_pose_lifter_model( - pose_model, [[]], dataset, with_track_id=False) + pose_model, [[]], dataset_info=dataset_info, with_track_id=False) if torch.cuda.is_available(): _ = inference_pose_lifter_model( - pose_model.cuda(), pose_results_2d, dataset, with_track_id=False) - - with pytest.raises(NotImplementedError): - _ = inference_pose_lifter_model( - pose_model, pose_results_2d, dataset='test') + pose_model.cuda(), + pose_results_2d, + dataset_info=dataset_info, + with_track_id=False) # test videopose3d pose_model = init_pose_model( @@ -92,7 +97,7 @@ def test_pose_lifter_demo(): pose_results_2d = [[pose_det_result_0], [pose_det_result_1], [pose_det_result_2]] - dataset = pose_model.cfg.data['test']['type'] + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) seq_len = pose_model.cfg.test_data_cfg.seq_len pose_results_2d_seq = extract_pose_sequence( @@ -101,7 +106,7 @@ def test_pose_lifter_demo(): pose_lift_results = inference_pose_lifter_model( pose_model, pose_results_2d_seq, - dataset, + dataset_info=dataset_info, with_track_id=True, image_size=[1000, 1000], norm_pose_2d=True) @@ -112,7 +117,8 @@ def test_pose_lifter_demo(): pose_model, pose_lift_results, img=pose_results_2d[0][0]['image_name'], - dataset=dataset) + dataset_info=dataset_info, + ) def test_interhand3d_demo(): @@ -132,6 +138,7 @@ def test_interhand3d_demo(): } det_results = [det_result] dataset = pose_model.cfg.data['test']['type'] + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) pose_results = inference_interhand_3d_model( pose_model, image_name, det_results, dataset=dataset) @@ -143,7 +150,7 @@ def test_interhand3d_demo(): pose_model, result=pose_results, img=det_results[0]['image_name'], - dataset=dataset, + dataset_info=dataset_info, ) # test special cases @@ -162,7 +169,6 @@ def test_interhand3d_demo(): def test_body_mesh_demo(): # H36M demo - device = 'cpu' config = 'configs/body/3d_mesh_sview_rgb_img/hmr' \ '/mixed/res50_mixed_224x224.py' config = mmcv.Config.fromfile(config) @@ -176,12 +182,9 @@ def test_body_mesh_demo(): tmpdir, 'test_joint_regressor.npy') # generate weight file for SMPL model. generate_smpl_weight_file(tmpdir) - pose_model = build_posenet(config.model) + pose_model = init_pose_model(config, device='cpu') assert pose_model is not None, 'Fail to build pose model' - pose_model.cfg = config - pose_model.to(device) - pose_model.eval() image_name = 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg' det_result = { diff --git a/tests/test_apis/test_inference_tracking.py b/tests/test_apis/test_inference_tracking.py index ae2a321219..8a847c5d74 100644 --- a/tests/test_apis/test_inference_tracking.py +++ b/tests/test_apis/test_inference_tracking.py @@ -1,8 +1,7 @@ -import pytest - from mmpose.apis import (get_track_id, inference_bottom_up_pose_model, inference_top_down_pose_model, init_pose_model, vis_pose_tracking_result) +from mmpose.datasets.dataset_info import DatasetInfo def test_top_down_pose_tracking_demo(): @@ -14,15 +13,20 @@ def test_top_down_pose_tracking_demo(): None, device='cpu') image_name = 'tests/data/coco/000000000785.jpg' - + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) person_result = [{'bbox': [50, 50, 50, 100]}] # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( - pose_model, image_name, person_result, format='xywh') + pose_model, + image_name, + person_result, + format='xywh', + dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, [], next_id=0) # show the results - vis_pose_tracking_result(pose_model, image_name, pose_results) + vis_pose_tracking_result( + pose_model, image_name, pose_results, dataset_info=dataset_info) pose_results_last = pose_results # AIC demo @@ -32,13 +36,14 @@ def test_top_down_pose_tracking_demo(): None, device='cpu') image_name = 'tests/data/aic/054d9ce9201beffc76e5ff2169d2af2f027002ca.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, image_name, person_result, format='xywh', - dataset='TopDownAicDataset') + dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, pose_results_last, next_id) for pose_result in pose_results: @@ -48,7 +53,7 @@ def test_top_down_pose_tracking_demo(): # show the results vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='TopDownAicDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # OneHand10K demo # build the pose model from a config file and a checkpoint file @@ -58,6 +63,7 @@ def test_top_down_pose_tracking_demo(): None, device='cpu') image_name = 'tests/data/onehand10k/9.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, @@ -65,12 +71,12 @@ def test_top_down_pose_tracking_demo(): 'bbox': [10, 10, 30, 30] }], format='xywh', - dataset='OneHand10KDataset') + dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, pose_results_last, next_id) # show the results vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='OneHand10KDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) # InterHand2D demo pose_model = init_pose_model( @@ -79,6 +85,7 @@ def test_top_down_pose_tracking_demo(): None, device='cpu') image_name = 'tests/data/interhand2.6m/image2017.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, @@ -86,11 +93,11 @@ def test_top_down_pose_tracking_demo(): 'bbox': [50, 50, 0, 0] }], format='xywh', - dataset='InterHand2DDataset') + dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, [], next_id=0) # show the results vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='InterHand2DDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) pose_results_last = pose_results # MPII demo @@ -100,6 +107,7 @@ def test_top_down_pose_tracking_demo(): None, device='cpu') image_name = 'tests/data/mpii/004645041.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) # test a single image, with a list of bboxes. pose_results, _ = inference_top_down_pose_model( pose_model, @@ -107,16 +115,12 @@ def test_top_down_pose_tracking_demo(): 'bbox': [50, 50, 0, 0] }], format='xywh', - dataset='TopDownMpiiDataset') + dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, pose_results_last, next_id) # show the results vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='TopDownMpiiDataset') - - with pytest.raises(NotImplementedError): - vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='test') + pose_model, image_name, pose_results, dataset_info=dataset_info) def test_bottom_up_pose_tracking_demo(): @@ -129,14 +133,16 @@ def test_bottom_up_pose_tracking_demo(): device='cpu') image_name = 'tests/data/coco/000000000785.jpg' + dataset_info = DatasetInfo(pose_model.cfg.data['test']['dataset_info']) - pose_results, _ = inference_bottom_up_pose_model(pose_model, image_name) + pose_results, _ = inference_bottom_up_pose_model( + pose_model, image_name, dataset_info=dataset_info) pose_results, next_id = get_track_id(pose_results, [], next_id=0) # show the results vis_pose_tracking_result( - pose_model, image_name, pose_results, dataset='BottomUpCocoDataset') + pose_model, image_name, pose_results, dataset_info=dataset_info) pose_results_last = pose_results diff --git a/tests/test_backward_compatibility/test_dataset_compatibility.py b/tests/test_backward_compatibility/test_dataset_compatibility.py deleted file mode 100644 index 94c6a4f479..0000000000 --- a/tests/test_backward_compatibility/test_dataset_compatibility.py +++ /dev/null @@ -1,25 +0,0 @@ -import pytest - -from mmpose.datasets.datasets.animal.animal_base_dataset import \ - AnimalBaseDataset -from mmpose.datasets.datasets.bottom_up.bottom_up_base_dataset import \ - BottomUpBaseDataset -from mmpose.datasets.datasets.face.face_base_dataset import FaceBaseDataset -from mmpose.datasets.datasets.fashion.fashion_fase_dataset import \ - FashionBaseDataset -from mmpose.datasets.datasets.hand.hand_base_dataset import HandBaseDataset -from mmpose.datasets.datasets.top_down.topdown_base_dataset import \ - TopDownBaseDataset - - -@pytest.mark.parametrize('BaseDataset', - (AnimalBaseDataset, BottomUpBaseDataset, - FaceBaseDataset, FashionBaseDataset, HandBaseDataset, - TopDownBaseDataset)) -def test_dataset_base_class(BaseDataset): - with pytest.raises(ImportError): - - class Dataset(BaseDataset): - pass - - _ = Dataset() diff --git a/tests/test_backward_compatibility/test_dataset_info_compatibility.py b/tests/test_backward_compatibility/test_dataset_info_compatibility.py new file mode 100644 index 0000000000..e1b8c5ebaf --- /dev/null +++ b/tests/test_backward_compatibility/test_dataset_info_compatibility.py @@ -0,0 +1,162 @@ +import numpy as np +import pytest + +from mmpose.apis import (extract_pose_sequence, get_track_id, + inference_bottom_up_pose_model, + inference_pose_lifter_model, + inference_top_down_pose_model, init_pose_model, + vis_3d_pose_result, vis_pose_result, + vis_pose_tracking_result) +from mmpose.datasets.datasets.animal.animal_base_dataset import \ + AnimalBaseDataset +from mmpose.datasets.datasets.bottom_up.bottom_up_base_dataset import \ + BottomUpBaseDataset +from mmpose.datasets.datasets.face.face_base_dataset import FaceBaseDataset +from mmpose.datasets.datasets.fashion.fashion_fase_dataset import \ + FashionBaseDataset +from mmpose.datasets.datasets.hand.hand_base_dataset import HandBaseDataset +from mmpose.datasets.datasets.top_down.topdown_base_dataset import \ + TopDownBaseDataset + + +@pytest.mark.parametrize('BaseDataset', + (AnimalBaseDataset, BottomUpBaseDataset, + FaceBaseDataset, FashionBaseDataset, HandBaseDataset, + TopDownBaseDataset)) +def test_dataset_base_class(BaseDataset): + with pytest.raises(ImportError): + + class Dataset(BaseDataset): + pass + + _ = Dataset() + + +def test_inference_without_dataset_info(): + # Top down + pose_model = init_pose_model( + 'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/' + 'coco/res50_coco_256x192.py', + None, + device='cpu') + image_name = 'tests/data/coco/000000000785.jpg' + + person_result = [] + person_result.append({'bbox': [50, 50, 50, 100]}) + + with pytest.warns(DeprecationWarning): + pose_results, _ = inference_top_down_pose_model( + pose_model, image_name, person_result, format='xywh') + + with pytest.warns(DeprecationWarning): + vis_pose_result(pose_model, image_name, pose_results) + + with pytest.raises(NotImplementedError): + with pytest.warns(DeprecationWarning): + pose_results, _ = inference_top_down_pose_model( + pose_model, + image_name, + person_result, + format='xywh', + dataset='test') + + # Bottom up + pose_model = init_pose_model( + 'configs/body/2d_kpt_sview_rgb_img/associative_embedding/' + 'coco/res50_coco_512x512.py', + None, + device='cpu') + + image_name = 'tests/data/coco/000000000785.jpg' + with pytest.warns(DeprecationWarning): + pose_results, _ = inference_bottom_up_pose_model( + pose_model, image_name) + with pytest.warns(DeprecationWarning): + vis_pose_result(pose_model, image_name, pose_results) + + # Top down tracking + pose_model = init_pose_model( + 'configs/body/2d_kpt_sview_rgb_img/topdown_heatmap/' + 'coco/res50_coco_256x192.py', + None, + device='cpu') + image_name = 'tests/data/coco/000000000785.jpg' + person_result = [{'bbox': [50, 50, 50, 100]}] + + with pytest.warns(DeprecationWarning): + pose_results, _ = inference_top_down_pose_model( + pose_model, image_name, person_result, format='xywh') + + pose_results, _ = get_track_id(pose_results, [], next_id=0) + + with pytest.warns(DeprecationWarning): + vis_pose_tracking_result(pose_model, image_name, pose_results) + + with pytest.raises(NotImplementedError): + with pytest.warns(DeprecationWarning): + vis_pose_tracking_result( + pose_model, image_name, pose_results, dataset='test') + + # Bottom up tracking + pose_model = init_pose_model( + 'configs/body/2d_kpt_sview_rgb_img/associative_embedding/' + 'coco/res50_coco_512x512.py', + None, + device='cpu') + + image_name = 'tests/data/coco/000000000785.jpg' + with pytest.warns(DeprecationWarning): + pose_results, _ = inference_bottom_up_pose_model( + pose_model, image_name) + + pose_results, next_id = get_track_id(pose_results, [], next_id=0) + + with pytest.warns(DeprecationWarning): + vis_pose_tracking_result( + pose_model, + image_name, + pose_results, + dataset='BottomUpCocoDataset') + + # Pose lifting + pose_model = init_pose_model( + 'configs/body/3d_kpt_sview_rgb_img/pose_lift/' + 'h36m/simplebaseline3d_h36m.py', + None, + device='cpu') + + pose_det_result = { + 'keypoints': np.zeros((17, 3)), + 'bbox': [50, 50, 50, 50], + 'track_id': 0, + 'image_name': 'tests/data/h36m/S1_Directions_1.54138969_000001.jpg', + } + + pose_results_2d = [[pose_det_result]] + + dataset = pose_model.cfg.data['test']['type'] + + pose_results_2d = extract_pose_sequence( + pose_results_2d, frame_idx=0, causal=False, seq_len=1, step=1) + + with pytest.warns(DeprecationWarning): + _ = inference_pose_lifter_model( + pose_model, pose_results_2d, dataset, with_track_id=False) + + with pytest.warns(DeprecationWarning): + pose_lift_results = inference_pose_lifter_model( + pose_model, pose_results_2d, dataset, with_track_id=True) + + for res in pose_lift_results: + res['title'] = 'title' + with pytest.warns(DeprecationWarning): + vis_3d_pose_result( + pose_model, + pose_lift_results, + img=pose_results_2d[0][0]['image_name'], + dataset=dataset) + + with pytest.raises(NotImplementedError): + with pytest.warns(DeprecationWarning): + _ = inference_pose_lifter_model( + pose_model, pose_results_2d, dataset='test') diff --git a/tests/test_datasets/test_animal_dataset.py b/tests/test_datasets/test_animal_dataset.py index 0c92e0f910..31057f7f03 100644 --- a/tests/test_datasets/test_animal_dataset.py +++ b/tests/test_datasets/test_animal_dataset.py @@ -3,6 +3,7 @@ import numpy as np import pytest +from mmcv import Config from numpy.testing import assert_almost_equal from mmpose.datasets import DATASETS @@ -60,6 +61,8 @@ def convert_db_to_output(db, batch_size=2, keys=None, is_3d=False): def test_animal_horse10_dataset(): dataset = 'AnimalHorse10Dataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/horse10.py').dataset_info channel_cfg = dict( num_output_channels=22, @@ -88,6 +91,7 @@ def test_animal_horse10_dataset(): ann_file='tests/data/horse10/test_horse10.json', img_prefix='tests/data/horse10/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -95,6 +99,7 @@ def test_animal_horse10_dataset(): ann_file='tests/data/horse10/test_horse10.json', img_prefix='tests/data/horse10/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -115,6 +120,8 @@ def test_animal_horse10_dataset(): def test_animal_fly_dataset(): dataset = 'AnimalFlyDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/fly.py').dataset_info channel_cfg = dict( num_output_channels=32, @@ -144,6 +151,7 @@ def test_animal_fly_dataset(): ann_file='tests/data/fly/test_fly.json', img_prefix='tests/data/fly/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -151,6 +159,7 @@ def test_animal_fly_dataset(): ann_file='tests/data/fly/test_fly.json', img_prefix='tests/data/fly/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -171,6 +180,8 @@ def test_animal_fly_dataset(): def test_animal_locust_dataset(): dataset = 'AnimalLocustDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/locust.py').dataset_info channel_cfg = dict( num_output_channels=35, @@ -201,6 +212,7 @@ def test_animal_locust_dataset(): ann_file='tests/data/locust/test_locust.json', img_prefix='tests/data/locust/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -208,6 +220,7 @@ def test_animal_locust_dataset(): ann_file='tests/data/locust/test_locust.json', img_prefix='tests/data/locust/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -228,6 +241,8 @@ def test_animal_locust_dataset(): def test_animal_zebra_dataset(): dataset = 'AnimalZebraDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/zebra.py').dataset_info channel_cfg = dict( num_output_channels=9, @@ -251,6 +266,7 @@ def test_animal_zebra_dataset(): ann_file='tests/data/zebra/test_zebra.json', img_prefix='tests/data/zebra/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -258,6 +274,7 @@ def test_animal_zebra_dataset(): ann_file='tests/data/zebra/test_zebra.json', img_prefix='tests/data/zebra/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -278,6 +295,8 @@ def test_animal_zebra_dataset(): def test_animal_ATRW_dataset(): dataset = 'AnimalATRWDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/atrw.py').dataset_info channel_cfg = dict( num_output_channels=15, @@ -309,6 +328,7 @@ def test_animal_ATRW_dataset(): ann_file='tests/data/atrw/test_atrw.json', img_prefix='tests/data/atrw/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -316,6 +336,7 @@ def test_animal_ATRW_dataset(): ann_file='tests/data/atrw/test_atrw.json', img_prefix='tests/data/atrw/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -336,6 +357,8 @@ def test_animal_ATRW_dataset(): def test_animal_Macaque_dataset(): dataset = 'AnimalMacaqueDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/macaque.py').dataset_info channel_cfg = dict( num_output_channels=17, @@ -369,6 +392,7 @@ def test_animal_Macaque_dataset(): ann_file='tests/data/macaque/test_macaque.json', img_prefix='tests/data/macaque/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -376,6 +400,7 @@ def test_animal_Macaque_dataset(): ann_file='tests/data/macaque/test_macaque.json', img_prefix='tests/data/macaque/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False) @@ -396,6 +421,8 @@ def test_animal_Macaque_dataset(): def test_animalpose_dataset(): dataset = 'AnimalPoseDataset' dataset_class = DATASETS.get(dataset) + dataset_info = Config.fromfile( + 'configs/_base_/datasets/animalpose.py').dataset_info channel_cfg = dict( num_output_channels=20, @@ -433,6 +460,7 @@ def test_animalpose_dataset(): ann_file='tests/data/animalpose/test_animalpose.json', img_prefix='tests/data/animalpose/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=True) @@ -440,6 +468,7 @@ def test_animalpose_dataset(): ann_file='tests/data/animalpose/test_animalpose.json', img_prefix='tests/data/animalpose/', data_cfg=data_cfg_copy, + dataset_info=dataset_info, pipeline=[], test_mode=False)