diff --git a/README.md b/README.md index 03f0c7650b..823324c3bd 100644 --- a/README.md +++ b/README.md @@ -130,36 +130,36 @@ MMPose v1.0.0 is a major update, including many API and config file changes. Cur
Migration Progress -| Algorithm | Status | -| :--- | :---: | -| MTUT (CVPR 2019) | | -| MSPN (ArXiv 2019)| done | -| InterNet (ECCV 2020) | | -| DEKR (CVPR 2021) | done | -| HigherHRNet (CVPR 2020) | | -| DeepPose (CVPR 2014) | done | -| RLE (ICCV 2021) | done | -| SoftWingloss (TIP 2021) | | -| VideoPose3D (CVPR 2019) | | -| Hourglass (ECCV 2016) | done | -| LiteHRNet (CVPR 2021) | done | -| AdaptiveWingloss (ICCV 2019) | done | -| SimpleBaseline2D (ECCV 2018) | done | -| PoseWarper (NeurIPS 2019) | | -| SimpleBaseline3D (ICCV 2017) | | -| HMR (CVPR 2018) | | -| UDP (CVPR 2020) | done | -| VIPNAS (CVPR 2021) | done | -| Wingloss (CVPR 2018) | | -| DarkPose (CVPR 2020) | done | +| Algorithm | Status | +| :-------------------------------- | :---------: | +| MTUT (CVPR 2019) | | +| MSPN (ArXiv 2019) | done | +| InterNet (ECCV 2020) | | +| DEKR (CVPR 2021) | done | +| HigherHRNet (CVPR 2020) | | +| DeepPose (CVPR 2014) | done | +| RLE (ICCV 2021) | done | +| SoftWingloss (TIP 2021) | | +| VideoPose3D (CVPR 2019) | | +| Hourglass (ECCV 2016) | done | +| LiteHRNet (CVPR 2021) | done | +| AdaptiveWingloss (ICCV 2019) | done | +| SimpleBaseline2D (ECCV 2018) | done | +| PoseWarper (NeurIPS 2019) | | +| SimpleBaseline3D (ICCV 2017) | | +| HMR (CVPR 2018) | | +| UDP (CVPR 2020) | done | +| VIPNAS (CVPR 2021) | done | +| Wingloss (CVPR 2018) | | +| DarkPose (CVPR 2020) | done | | Associative Embedding (NIPS 2017) | in progress | -| VoxelPose (ECCV 2020) | | -| RSN (ECCV 2020) | done | -| CID (CVPR 2022) | done | -| CPM (CVPR 2016) | done | -| HRNet (CVPR 2019) | done | -| HRNetv2 (TPAMI 2019) | done | -| SCNet (CVPR 2020) | done | +| VoxelPose (ECCV 2020) | | +| RSN (ECCV 2020) | done | +| CID (CVPR 2022) | done | +| CPM (CVPR 2016) | done | +| HRNet (CVPR 2019) | done | +| HRNetv2 (TPAMI 2019) | done | +| SCNet (CVPR 2020) | done |
diff --git a/README_CN.md b/README_CN.md index 7e28ced6e6..ff5f14c50b 100644 --- a/README_CN.md +++ b/README_CN.md @@ -128,40 +128,41 @@ MMPose v1.0.0 是一个重大更新,包括了大量的 API 和配置文件的
迁移进度 -| 算法名称 | 迁移进度 | -| :--- | :---: | -| MTUT (CVPR 2019) | | -| MSPN (ArXiv 2019)| done | -| InterNet (ECCV 2020) | | -| DEKR (CVPR 2021) | done | -| HigherHRNet (CVPR 2020) | | -| DeepPose (CVPR 2014) | done | -| RLE (ICCV 2021) | done | -| SoftWingloss (TIP 2021) | | -| VideoPose3D (CVPR 2019) | | -| Hourglass (ECCV 2016) | done | -| LiteHRNet (CVPR 2021) | done | -| AdaptiveWingloss (ICCV 2019) | done | -| SimpleBaseline2D (ECCV 2018) | done | -| PoseWarper (NeurIPS 2019) | | -| SimpleBaseline3D (ICCV 2017) | | -| HMR (CVPR 2018) | | -| UDP (CVPR 2020) | done | -| VIPNAS (CVPR 2021) | done | -| Wingloss (CVPR 2018) | | -| DarkPose (CVPR 2020) | done | +| 算法名称 | 迁移进度 | +| :-------------------------------- | :---------: | +| MTUT (CVPR 2019) | | +| MSPN (ArXiv 2019) | done | +| InterNet (ECCV 2020) | | +| DEKR (CVPR 2021) | done | +| HigherHRNet (CVPR 2020) | | +| DeepPose (CVPR 2014) | done | +| RLE (ICCV 2021) | done | +| SoftWingloss (TIP 2021) | | +| VideoPose3D (CVPR 2019) | | +| Hourglass (ECCV 2016) | done | +| LiteHRNet (CVPR 2021) | done | +| AdaptiveWingloss (ICCV 2019) | done | +| SimpleBaseline2D (ECCV 2018) | done | +| PoseWarper (NeurIPS 2019) | | +| SimpleBaseline3D (ICCV 2017) | | +| HMR (CVPR 2018) | | +| UDP (CVPR 2020) | done | +| VIPNAS (CVPR 2021) | done | +| Wingloss (CVPR 2018) | | +| DarkPose (CVPR 2020) | done | | Associative Embedding (NIPS 2017) | in progress | -| VoxelPose (ECCV 2020) | | -| RSN (ECCV 2020) | done | -| CID (CVPR 2022) | done | -| CPM (CVPR 2016) | done | -| HRNet (CVPR 2019) | done | -| HRNetv2 (TPAMI 2019) | done | -| SCNet (CVPR 2020) | done | +| VoxelPose (ECCV 2020) | | +| RSN (ECCV 2020) | done | +| CID (CVPR 2022) | done | +| CPM (CVPR 2016) | done | +| HRNet (CVPR 2019) | done | +| HRNetv2 (TPAMI 2019) | done | +| SCNet (CVPR 2020) | done |
如果您使用的算法还没有完成迁移,您也可以继续使用访问 [0.x 分支](https://github.com/open-mmlab/mmpose/tree/0.x) 和 [旧版文档](https://mmpose.readthedocs.io/zh_CN/0.x/) + ## 安装 关于安装的详细说明请参考[安装文档](https://mmpose.readthedocs.io/zh_CN/latest/installation.html)。 diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.md b/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.md index ca7c450534..f9266001d5 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.md +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.md @@ -57,6 +57,6 @@ Results on COCO val2017 with detector having human AP of 56.4 on COCO val2017 da | Arch | Input Size | AP | AP50 | AP75 | AR | AR50 | ckpt | log | | :-------------------------------------------- | :--------: | :---: | :-------------: | :-------------: | :---: | :-------------: | :-------------------------------------------: | :-------------------------------------------: | | [ViTPose-S](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-small-simple_8xb64-210e_coco-256x192.py) | 256x192 | 0.736 | 0.900 | 0.811 | 0.790 | 0.940 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-small-simple_8xb64-210e_coco-256x192-4c101a76_20230314.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-small-simple_8xb64-210e_coco-256x192-4c101a76_20230314.json) | -| [ViTPose-B](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192.py) | 256x192 | 0.756 | 0.906 | 0.826 | 0.809 | 0.946 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-fd73707d_20230314.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-fd73707d_20230314.json) | +| [ViTPose-B](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192.py) | 256x192 | 0.756 | 0.906 | 0.826 | 0.809 | 0.946 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-0b8234ea_20230407.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-0b8234ea_20230407.json) | | [ViTPose-L](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-large-simple_8xb64-210e_coco-256x192.py) | 256x192 | 0.781 | 0.914 | 0.853 | 0.833 | 0.952 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-large-simple_8xb64-210e_coco-256x192-3a7ee9e1_20230314.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-large-simple_8xb64-210e_coco-256x192-3a7ee9e1_20230314.json) | | [ViTPose-H](/configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-huge-simple_8xb64-210e_coco-256x192.py) | 256x192 | 0.789 | 0.916 | 0.856 | 0.839 | 0.953 | [ckpt](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-huge-simple_8xb64-210e_coco-256x192-ffd48c05_20230314.pth) | [log](https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-huge-simple_8xb64-210e_coco-256x192-ffd48c05_20230314.json) | diff --git a/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.yml b/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.yml index f78a930fc1..6d1cc7db15 100644 --- a/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.yml +++ b/configs/body_2d_keypoint/topdown_heatmap/coco/vitpose_coco.yml @@ -116,7 +116,7 @@ Models: AR: 0.809 AR@0.5: 0.946 Task: Body 2D Keypoint - Weights: https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-fd73707d_20230314.pth + Weights: https://download.openmmlab.com/mmpose/v1/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192-0b8234ea_20230407.pth - Config: configs/body_2d_keypoint/topdown_heatmap/coco/td-hm_ViTPose-large-simple_8xb64-210e_coco-256x192.py In Collection: ViTPose Alias: vitpose-l diff --git a/mmpose/datasets/datasets/base/base_coco_style_dataset.py b/mmpose/datasets/datasets/base/base_coco_style_dataset.py index a1c3bc2f5c..3b592813d8 100644 --- a/mmpose/datasets/datasets/base/base_coco_style_dataset.py +++ b/mmpose/datasets/datasets/base/base_coco_style_dataset.py @@ -7,8 +7,8 @@ import numpy as np from mmengine.dataset import BaseDataset, force_full_init -from mmengine.fileio import load -from mmengine.utils import check_file_exist, is_list_of +from mmengine.fileio import exists, get_local_path, load +from mmengine.utils import is_list_of from xtcocotools.coco import COCO from mmpose.registry import DATASETS @@ -195,18 +195,19 @@ def load_data_list(self) -> List[dict]: def _load_annotations(self) -> Tuple[List[dict], List[dict]]: """Load data from annotations in COCO format.""" - check_file_exist(self.ann_file) + assert exists(self.ann_file), 'Annotation file does not exist' - coco = COCO(self.ann_file) + with get_local_path(self.ann_file) as local_path: + self.coco = COCO(local_path) # set the metainfo about categories, which is a list of dict # and each dict contains the 'id', 'name', etc. about this category - self._metainfo['CLASSES'] = coco.loadCats(coco.getCatIds()) + self._metainfo['CLASSES'] = self.coco.loadCats(self.coco.getCatIds()) instance_list = [] image_list = [] - for img_id in coco.getImgIds(): - img = coco.loadImgs(img_id)[0] + for img_id in self.coco.getImgIds(): + img = self.coco.loadImgs(img_id)[0] img.update({ 'img_id': img_id, @@ -215,8 +216,8 @@ def _load_annotations(self) -> Tuple[List[dict], List[dict]]: }) image_list.append(img) - ann_ids = coco.getAnnIds(imgIds=img_id) - for ann in coco.loadAnns(ann_ids): + ann_ids = self.coco.getAnnIds(imgIds=img_id) + for ann in self.coco.loadAnns(ann_ids): instance_info = self.parse_data_info( dict(raw_ann_info=ann, raw_img_info=img)) @@ -380,18 +381,18 @@ def _get_bottomup_data_infos(self, instance_list: List[Dict], def _load_detection_results(self) -> List[dict]: """Load data from detection results with dummy keypoint annotations.""" - check_file_exist(self.ann_file) - check_file_exist(self.bbox_file) - + assert exists(self.ann_file), 'Annotation file does not exist' + assert exists(self.bbox_file), 'Bbox file does not exist' # load detection results det_results = load(self.bbox_file) assert is_list_of(det_results, dict) # load coco annotations to build image id-to-name index - coco = COCO(self.ann_file) + with get_local_path(self.ann_file) as local_path: + self.coco = COCO(local_path) # set the metainfo about categories, which is a list of dict # and each dict contains the 'id', 'name', etc. about this category - self._metainfo['CLASSES'] = coco.loadCats(coco.getCatIds()) + self._metainfo['CLASSES'] = self.coco.loadCats(self.coco.getCatIds()) num_keypoints = self.metainfo['num_keypoints'] data_list = [] @@ -401,7 +402,7 @@ def _load_detection_results(self) -> List[dict]: if det['category_id'] != 1: continue - img = coco.loadImgs(det['image_id'])[0] + img = self.coco.loadImgs(det['image_id'])[0] img_path = osp.join(self.data_prefix['img'], img['file_name']) bbox_xywh = np.array( diff --git a/mmpose/datasets/datasets/body/mpii_dataset.py b/mmpose/datasets/datasets/body/mpii_dataset.py index a1f777a10b..237f1ab2b6 100644 --- a/mmpose/datasets/datasets/body/mpii_dataset.py +++ b/mmpose/datasets/datasets/body/mpii_dataset.py @@ -4,7 +4,7 @@ from typing import Callable, List, Optional, Sequence, Tuple, Union import numpy as np -from mmengine.utils import check_file_exist +from mmengine.fileio import exists, get_local_path from scipy.io import loadmat from mmpose.registry import DATASETS @@ -137,14 +137,16 @@ def __init__(self, def _load_annotations(self) -> Tuple[List[dict], List[dict]]: """Load data from annotations in MPII format.""" - check_file_exist(self.ann_file) - with open(self.ann_file) as anno_file: - anns = json.load(anno_file) + assert exists(self.ann_file), 'Annotation file does not exist' + with get_local_path(self.ann_file) as local_path: + with open(local_path) as anno_file: + self.anns = json.load(anno_file) if self.headbox_file: - check_file_exist(self.headbox_file) - headbox_dict = loadmat(self.headbox_file) - headboxes_src = np.transpose(headbox_dict['headboxes_src'], + assert exists(self.headbox_file), 'Headbox file does not exist' + with get_local_path(self.headbox_file) as local_path: + self.headbox_dict = loadmat(local_path) + headboxes_src = np.transpose(self.headbox_dict['headboxes_src'], [2, 0, 1]) SC_BIAS = 0.6 @@ -156,7 +158,7 @@ def _load_annotations(self) -> Tuple[List[dict], List[dict]]: # mpii bbox scales are normalized with factor 200. pixel_std = 200. - for idx, ann in enumerate(anns): + for idx, ann in enumerate(self.anns): center = np.array(ann['center'], dtype=np.float32) scale = np.array([ann['scale'], ann['scale']], dtype=np.float32) * pixel_std diff --git a/mmpose/datasets/datasets/body/mpii_trb_dataset.py b/mmpose/datasets/datasets/body/mpii_trb_dataset.py index be9154ad70..bb96ad876f 100644 --- a/mmpose/datasets/datasets/body/mpii_trb_dataset.py +++ b/mmpose/datasets/datasets/body/mpii_trb_dataset.py @@ -4,7 +4,7 @@ from typing import List, Tuple import numpy as np -from mmengine.utils import check_file_exist +from mmengine.fileio import exists, get_local_path from mmpose.registry import DATASETS from mmpose.structures.bbox import bbox_cs2xyxy @@ -106,11 +106,12 @@ class MpiiTrbDataset(BaseCocoStyleDataset): def _load_annotations(self) -> Tuple[List[dict], List[dict]]: """Load data from annotations in MPII-TRB format.""" - check_file_exist(self.ann_file) - with open(self.ann_file) as anno_file: - data = json.load(anno_file) + assert exists(self.ann_file), 'Annotation file does not exist' + with get_local_path(self.ann_file) as local_path: + with open(local_path) as anno_file: + self.data = json.load(anno_file) - imgid2info = {img['id']: img for img in data['images']} + imgid2info = {img['id']: img for img in self.data['images']} instance_list = [] image_list = [] @@ -119,7 +120,7 @@ def _load_annotations(self) -> Tuple[List[dict], List[dict]]: # mpii-trb bbox scales are normalized with factor 200. pixel_std = 200. - for ann in data['annotations']: + for ann in self.data['annotations']: img_id = ann['image_id'] # center, scale in shape [1, 2] and bbox in [1, 4] diff --git a/mmpose/datasets/datasets/body/posetrack18_video_dataset.py b/mmpose/datasets/datasets/body/posetrack18_video_dataset.py index fc0b47e517..cc5fe8646c 100644 --- a/mmpose/datasets/datasets/body/posetrack18_video_dataset.py +++ b/mmpose/datasets/datasets/body/posetrack18_video_dataset.py @@ -3,8 +3,8 @@ from typing import Callable, List, Optional, Sequence, Union import numpy as np -from mmengine.fileio import load -from mmengine.utils import check_file_exist, is_list_of +from mmengine.fileio import exists, get_local_path, load +from mmengine.utils import is_list_of from xtcocotools.coco import COCO from mmpose.registry import DATASETS @@ -287,22 +287,22 @@ def parse_data_info(self, raw_data_info: dict) -> Optional[dict]: def _load_detection_results(self) -> List[dict]: """Load data from detection results with dummy keypoint annotations.""" - - check_file_exist(self.ann_file) - check_file_exist(self.bbox_file) + assert exists(self.ann_file), 'Annotation file does not exist' + assert exists(self.bbox_file), 'Bbox file does not exist' # load detection results det_results = load(self.bbox_file) assert is_list_of(det_results, dict) # load coco annotations to build image id-to-name index - coco = COCO(self.ann_file) + with get_local_path(self.ann_file) as local_path: + self.coco = COCO(local_path) # mapping image name to id name2id = {} # mapping image id to name id2name = {} - for img_id, image in coco.imgs.items(): + for img_id, image in self.coco.imgs.items(): file_name = image['file_name'] id2name[img_id] = file_name name2id[file_name] = img_id @@ -333,7 +333,7 @@ def _load_detection_results(self) -> List[dict]: img_id = name2id[det['image_name']] else: img_id = det['image_id'] - img_ann = coco.loadImgs(img_id)[0] + img_ann = self.coco.loadImgs(img_id)[0] nframes = int(img_ann['nframes']) # deal with multiple image paths diff --git a/mmpose/datasets/datasets/hand/coco_wholebody_hand_dataset.py b/mmpose/datasets/datasets/hand/coco_wholebody_hand_dataset.py index 1831c9c89d..dba0132f58 100644 --- a/mmpose/datasets/datasets/hand/coco_wholebody_hand_dataset.py +++ b/mmpose/datasets/datasets/hand/coco_wholebody_hand_dataset.py @@ -3,7 +3,7 @@ from typing import List, Tuple import numpy as np -from mmengine.utils import check_file_exist +from mmengine.fileio import exists, get_local_path from xtcocotools.coco import COCO from mmpose.registry import DATASETS @@ -87,15 +87,16 @@ class CocoWholeBodyHandDataset(BaseCocoStyleDataset): def _load_annotations(self) -> Tuple[List[dict], List[dict]]: """Load data from annotations in COCO format.""" - check_file_exist(self.ann_file) + assert exists(self.ann_file), 'Annotation file does not exist' - coco = COCO(self.ann_file) + with get_local_path(self.ann_file) as local_path: + self.coco = COCO(local_path) instance_list = [] image_list = [] id = 0 - for img_id in coco.getImgIds(): - img = coco.loadImgs(img_id)[0] + for img_id in self.coco.getImgIds(): + img = self.coco.loadImgs(img_id)[0] img.update({ 'img_id': @@ -105,8 +106,8 @@ def _load_annotations(self) -> Tuple[List[dict], List[dict]]: }) image_list.append(img) - ann_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False) - anns = coco.loadAnns(ann_ids) + ann_ids = self.coco.getAnnIds(imgIds=img_id, iscrowd=False) + anns = self.coco.loadAnns(ann_ids) for ann in anns: for type in ['left', 'right']: # filter invalid hand annotations, there might be two diff --git a/mmpose/evaluation/metrics/coco_metric.py b/mmpose/evaluation/metrics/coco_metric.py index dd059bf8fb..8327e2eca7 100644 --- a/mmpose/evaluation/metrics/coco_metric.py +++ b/mmpose/evaluation/metrics/coco_metric.py @@ -7,7 +7,7 @@ import numpy as np from mmengine.evaluator import BaseMetric -from mmengine.fileio import dump, load +from mmengine.fileio import dump, get_local_path, load from mmengine.logging import MMLogger from xtcocotools.coco import COCO from xtcocotools.cocoeval import COCOeval @@ -102,7 +102,8 @@ def __init__(self, # initialize coco helper with the annotation json file # if ann_file is not specified, initialize with the converted dataset if ann_file is not None: - self.coco = COCO(ann_file) + with get_local_path(ann_file) as local_path: + self.coco = COCO(local_path) else: self.coco = None