We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pylint: W0105
```bash
mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py:173:8: W0105: String statement has no effect (pointless-string-statement)
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py`
Content:
```
1 import copy as cp
2 import os
3 import os.path as osp
4 from collections import OrderedDict
5 
6 import json_tricks as json
7 import numpy as np
8 
9 from mmpose.datasets.builder import DATASETS
10 from .topdown_base_dataset import TopDownBaseDataset
11 
12 
13 @DATASETS.register_module()
14 class TopDownMpiiTrbDataset(TopDownBaseDataset):
15     """MPII-TRB Dataset dataset for top-down pose estimation.
16 
17     `TRB: A Novel Triplet Representation for Understanding 2D Human Body`
18     ICCV'2019 More details can be found in the `paper
19     <https://arxiv.org/abs/1910.11535>`__ .
20 
21     The dataset loads raw features and apply specified transforms
22     to return a dict containing the image tensors and other information.
23 
24     Args:
25         ann_file (str): Path to the annotation file.
26         img_prefix (str): Path to a directory where images are held.
27             Default: None.
28         data_cfg (dict): config
29         pipeline (list[dict | callable]): A sequence of data transforms.
30         test_mode (bool): Store True when building test or
31             validation dataset. Default: False.
32     """
33 
34     def __init__(self,
35                  ann_file,
36                  img_prefix,
37                  data_cfg,
38                  pipeline,
39                  test_mode=False):
40 
41         super().__init__(
42             ann_file, img_prefix, data_cfg, pipeline, test_mode=test_mode)
43 
44         # flip_pairs in MPII-TRB
45         self.ann_info['flip_pairs'] = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9],
46                                        [10, 11], [14, 15]]
47         for i in range(6):
48             self.ann_info['flip_pairs'].append([16 + i, 22 + i])
49             self.ann_info['flip_pairs'].append([28 + i, 34 + i])
50 
51         self.ann_info['upper_body_ids'] = [0, 1, 2, 3, 4, 5, 12, 13]
52         self.ann_info['lower_body_ids'] = [6, 7, 8, 9, 10, 11]
53         self.ann_info['upper_body_ids'].extend(list(range(14, 28)))
54         self.ann_info['lower_body_ids'].extend(list(range(28, 40)))
55 
56         self.ann_info['use_different_joint_weights'] = False
57 
58         assert self.ann_info['num_joints'] == 40
59         self.ann_info['joint_weights'] = np.ones(
60             (self.ann_info['num_joints'], 1), dtype=np.float32)
61 
62         self.db = self._get_db(ann_file)
63         self.image_set = set(x['image_file'] for x in self.db)
64         self.num_images = len(self.image_set)
65 
66         print(f'=> num_images: {self.num_images}')
67         print(f'=> load {len(self.db)} samples')
68 
69     def _get_db(self, ann_file):
70         """Load dataset."""
71         with open(ann_file, 'r') as f:
72             data = json.load(f)
73         tmpl = dict(
74             image_file=None,
75             center=None,
76             scale=None,
77             rotation=0,
78             joints_3d=None,
79             joints_3d_visible=None,
80             dataset='mpii_trb')
81 
82         imid2info = {
83             int(osp.splitext(x['file_name'])[0]): x
84             for x in data['images']
85         }
86 
87         num_joints = self.ann_info['num_joints']
88         gt_db = []
89 
90         for anno in data['annotations']:
91             newitem = cp.deepcopy(tmpl)
92             image_id = anno['image_id']
93             newitem['image_file'] = os.path.join(
94                 self.img_prefix, imid2info[image_id]['file_name'])
95 
96             if max(anno['keypoints']) == 0:
97                 continue
98 
99             joints_3d = np.zeros((num_joints, 3), dtype=np.float32)
100             joints_3d_visible = np.zeros((num_joints, 3), dtype=np.float32)
101 
102             for ipt in range(num_joints):
103                 joints_3d[ipt, 0] = anno['keypoints'][ipt * 3 + 0]
104                 joints_3d[ipt, 1] = anno['keypoints'][ipt * 3 + 1]
105                 joints_3d[ipt, 2] = 0
106                 t_vis = min(anno['keypoints'][ipt * 3 + 2], 1)
107                 joints_3d_visible[ipt, :] = (t_vis, t_vis, 0)
108 
109             center = np.array(anno['center'], dtype=np.float32)
110             scale = self.ann_info['image_size'] / anno['scale'] / 200.0
111             newitem['center'] = center
112             newitem['scale'] = scale
113             newitem['joints_3d'] = joints_3d
114             newitem['joints_3d_visible'] = joints_3d_visible
115             if 'headbox' in anno:
116                 newitem['headbox'] = anno['headbox']
117             gt_db.append(newitem)
118 
119         return gt_db
120 
121     def _evaluate_kernel(self, pred, joints_3d, joints_3d_visible, headbox):
122         """Evaluate one example."""
123         num_joints = self.ann_info['num_joints']
124         headbox = np.array(headbox)
125         threshold = np.linalg.norm(headbox[:2] - headbox[2:]) * 0.3
126         hit = np.zeros(num_joints, dtype=np.float32)
127         exist = np.zeros(num_joints, dtype=np.float32)
128 
129         for i in range(num_joints):
130             pred_pt = pred[i]
131             gt_pt = joints_3d[i]
132             vis = joints_3d_visible[i][0]
133             if vis:
134                 exist[i] = 1
135             else:
136                 continue
137             distance = np.linalg.norm(pred_pt[:2] - gt_pt[:2])
138             if distance < threshold:
139                 hit[i] = 1
140         return hit, exist
141 
142     def evaluate(self, outputs, res_folder, metric='PCKh', **kwargs):
143         """Evaluate PCKh for MPII-TRB dataset.
144 
145         Note:
146             batch_size: N
147             num_keypoints: K
148             heatmap height: H
149             heatmap width: W
150 
151         Args:
152             outputs(list(preds, boxes, image_path, heatmap)):
153 
154                 * preds(np.ndarray[1,K,3]): The first two dimensions are
155                   coordinates, score is the third dimension of the array.
156                 * boxes(np.ndarray[1,6]): [center[0], center[1], scale[0]
157                   , scale[1],area, score]
158                 * image_path(list[str]): For example, ['0', '0',
159                   '0', '0', '0', '1', '1', '6', '3', '.', 'j', 'p', 'g']
160                 * heatmap (np.ndarray[N, K, H, W]): model output heatmap.
161             res_folder(str): Path of directory to save the results.
162             metric (str | list[str]): Metrics to be performed.
163                 Defaults: 'PCKh'.
164 
165         Returns:
166             dict: PCKh for each joint
167         """
168         metrics = metric if isinstance(metric, list) else [metric]
169         allowed_metrics = ['PCKh']
170         for metric in metrics:
171             if metric not in allowed_metrics:
172                 raise KeyError(f'metric {metric} is not supported')
173         """Evaluate MPII-TRB keypoint results."""
174         res_file = os.path.join(res_folder, 'result_keypoints.json')
175 
176         kpts = []
177 
178         for preds, boxes, image_path, _ in outputs:
179             str_image_path = ''.join(image_path)
180             image_id = int(osp.basename(osp.splitext(str_image_path)[0]))
181 
182             kpts.append({
183                 'keypoints': preds[0].tolist(),
184                 'center': boxes[0][0:2].tolist(),
185                 'scale': boxes[0][2:4].tolist(),
186                 'area': float(boxes[0][4]),
187                 'score': float(boxes[0][5]),
188                 'image_id': image_id,
189             })
190 
191         self._write_keypoint_results(kpts, res_file)
192         info_str = self._report_metric(res_file)
193         name_value = OrderedDict(info_str)
194 
195         return name_value
196 
197     @staticmethod
198     def _write_keypoint_results(keypoints, res_file):
199         """Write results into a json file."""
200 
201         with open(res_file, 'w') as f:
202             json.dump(keypoints, f, sort_keys=True, indent=4)
203 
204     def _report_metric(self, res_file):
205         """Keypoint evaluation.
206 
207         Report Mean Acc of skeleton, contour and all joints.
208         """
209         num_joints = self.ann_info['num_joints']
210         hit = np.zeros(num_joints, dtype=np.float32)
211         exist = np.zeros(num_joints, dtype=np.float32)
212 
213         with open(res_file, 'r') as fin:
214             preds = json.load(fin)
215 
216         assert len(preds) == len(
217             self.db), f'len(preds)={len(preds)}, len(self.db)={len(self.db)}'
218         for pred, item in zip(preds, self.db):
219             h, e = self._evaluate_kernel(pred['keypoints'], item['joints_3d'],
220                                          item['joints_3d_visible'],
221                                          item['headbox'])
222             hit += h
223             exist += e
224         skeleton = np.sum(hit[:14]) / np.sum(exist[:14])
225         contour = np.sum(hit[14:]) / np.sum(exist[14:])
226         mean = np.sum(hit) / np.sum(exist)
227 
228         info_str = []
229         info_str.append(('Skeleton_acc', skeleton.item()))
230         info_str.append(('Contour_acc', contour.item()))
231         info_str.append(('PCKh', mean.item()))
232         return info_str
233
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py b/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py
--- a/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py
+++ b/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py
@@ -170,7 +170,7 @@
         for metric in metrics:
             if metric not in allowed_metrics:
                 raise KeyError(f'metric {metric} is not supported')
-        """Evaluate MPII-TRB keypoint results."""
+
         res_file = os.path.join(res_folder, 'result_keypoints.json')
 
         kpts = []

{"golden_diff": "diff --git a/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py b/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py\n--- a/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py\n+++ b/mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py\n@@ -170,7 +170,7 @@\n         for metric in metrics:\n             if metric not in allowed_metrics:\n                 raise KeyError(f'metric {metric} is not supported')\n-        \"\"\"Evaluate MPII-TRB keypoint results.\"\"\"\n+\n         res_file = os.path.join(res_folder, 'result_keypoints.json')\n \n         kpts = []\n", "issue": "Pylint: W0105\n```bash\r\nmmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py:173:8: W0105: String statement has no effect (pointless-string-statement)\r\n```\n", "before_files": [{"content": "import copy as cp\nimport os\nimport os.path as osp\nfrom collections import OrderedDict\n\nimport json_tricks as json\nimport numpy as np\n\nfrom mmpose.datasets.builder import DATASETS\nfrom .topdown_base_dataset import TopDownBaseDataset\n\n\n@DATASETS.register_module()\nclass TopDownMpiiTrbDataset(TopDownBaseDataset):\n    \"\"\"MPII-TRB Dataset dataset for top-down pose estimation.\n\n    `TRB: A Novel Triplet Representation for Understanding 2D Human Body`\n    ICCV'2019 More details can be found in the `paper\n    <https://arxiv.org/abs/1910.11535>`__ .\n\n    The dataset loads raw features and apply specified transforms\n    to return a dict containing the image tensors and other information.\n\n    Args:\n        ann_file (str): Path to the annotation file.\n        img_prefix (str): Path to a directory where images are held.\n            Default: None.\n        data_cfg (dict): config\n        pipeline (list[dict | callable]): A sequence of data transforms.\n        test_mode (bool): Store True when building test or\n            validation dataset. Default: False.\n    \"\"\"\n\n    def __init__(self,\n                 ann_file,\n                 img_prefix,\n                 data_cfg,\n                 pipeline,\n                 test_mode=False):\n\n        super().__init__(\n            ann_file, img_prefix, data_cfg, pipeline, test_mode=test_mode)\n\n        # flip_pairs in MPII-TRB\n        self.ann_info['flip_pairs'] = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9],\n                                       [10, 11], [14, 15]]\n        for i in range(6):\n            self.ann_info['flip_pairs'].append([16 + i, 22 + i])\n            self.ann_info['flip_pairs'].append([28 + i, 34 + i])\n\n        self.ann_info['upper_body_ids'] = [0, 1, 2, 3, 4, 5, 12, 13]\n        self.ann_info['lower_body_ids'] = [6, 7, 8, 9, 10, 11]\n        self.ann_info['upper_body_ids'].extend(list(range(14, 28)))\n        self.ann_info['lower_body_ids'].extend(list(range(28, 40)))\n\n        self.ann_info['use_different_joint_weights'] = False\n\n        assert self.ann_info['num_joints'] == 40\n        self.ann_info['joint_weights'] = np.ones(\n            (self.ann_info['num_joints'], 1), dtype=np.float32)\n\n        self.db = self._get_db(ann_file)\n        self.image_set = set(x['image_file'] for x in self.db)\n        self.num_images = len(self.image_set)\n\n        print(f'=> num_images: {self.num_images}')\n        print(f'=> load {len(self.db)} samples')\n\n    def _get_db(self, ann_file):\n        \"\"\"Load dataset.\"\"\"\n        with open(ann_file, 'r') as f:\n            data = json.load(f)\n        tmpl = dict(\n            image_file=None,\n            center=None,\n            scale=None,\n            rotation=0,\n            joints_3d=None,\n            joints_3d_visible=None,\n            dataset='mpii_trb')\n\n        imid2info = {\n            int(osp.splitext(x['file_name'])[0]): x\n            for x in data['images']\n        }\n\n        num_joints = self.ann_info['num_joints']\n        gt_db = []\n\n        for anno in data['annotations']:\n            newitem = cp.deepcopy(tmpl)\n            image_id = anno['image_id']\n            newitem['image_file'] = os.path.join(\n                self.img_prefix, imid2info[image_id]['file_name'])\n\n            if max(anno['keypoints']) == 0:\n                continue\n\n            joints_3d = np.zeros((num_joints, 3), dtype=np.float32)\n            joints_3d_visible = np.zeros((num_joints, 3), dtype=np.float32)\n\n            for ipt in range(num_joints):\n                joints_3d[ipt, 0] = anno['keypoints'][ipt * 3 + 0]\n                joints_3d[ipt, 1] = anno['keypoints'][ipt * 3 + 1]\n                joints_3d[ipt, 2] = 0\n                t_vis = min(anno['keypoints'][ipt * 3 + 2], 1)\n                joints_3d_visible[ipt, :] = (t_vis, t_vis, 0)\n\n            center = np.array(anno['center'], dtype=np.float32)\n            scale = self.ann_info['image_size'] / anno['scale'] / 200.0\n            newitem['center'] = center\n            newitem['scale'] = scale\n            newitem['joints_3d'] = joints_3d\n            newitem['joints_3d_visible'] = joints_3d_visible\n            if 'headbox' in anno:\n                newitem['headbox'] = anno['headbox']\n            gt_db.append(newitem)\n\n        return gt_db\n\n    def _evaluate_kernel(self, pred, joints_3d, joints_3d_visible, headbox):\n        \"\"\"Evaluate one example.\"\"\"\n        num_joints = self.ann_info['num_joints']\n        headbox = np.array(headbox)\n        threshold = np.linalg.norm(headbox[:2] - headbox[2:]) * 0.3\n        hit = np.zeros(num_joints, dtype=np.float32)\n        exist = np.zeros(num_joints, dtype=np.float32)\n\n        for i in range(num_joints):\n            pred_pt = pred[i]\n            gt_pt = joints_3d[i]\n            vis = joints_3d_visible[i][0]\n            if vis:\n                exist[i] = 1\n            else:\n                continue\n            distance = np.linalg.norm(pred_pt[:2] - gt_pt[:2])\n            if distance < threshold:\n                hit[i] = 1\n        return hit, exist\n\n    def evaluate(self, outputs, res_folder, metric='PCKh', **kwargs):\n        \"\"\"Evaluate PCKh for MPII-TRB dataset.\n\n        Note:\n            batch_size: N\n            num_keypoints: K\n            heatmap height: H\n            heatmap width: W\n\n        Args:\n            outputs(list(preds, boxes, image_path, heatmap)):\n\n                * preds(np.ndarray[1,K,3]): The first two dimensions are\n                  coordinates, score is the third dimension of the array.\n                * boxes(np.ndarray[1,6]): [center[0], center[1], scale[0]\n                  , scale[1],area, score]\n                * image_path(list[str]): For example, ['0', '0',\n                  '0', '0', '0', '1', '1', '6', '3', '.', 'j', 'p', 'g']\n                * heatmap (np.ndarray[N, K, H, W]): model output heatmap.\n            res_folder(str): Path of directory to save the results.\n            metric (str | list[str]): Metrics to be performed.\n                Defaults: 'PCKh'.\n\n        Returns:\n            dict: PCKh for each joint\n        \"\"\"\n        metrics = metric if isinstance(metric, list) else [metric]\n        allowed_metrics = ['PCKh']\n        for metric in metrics:\n            if metric not in allowed_metrics:\n                raise KeyError(f'metric {metric} is not supported')\n        \"\"\"Evaluate MPII-TRB keypoint results.\"\"\"\n        res_file = os.path.join(res_folder, 'result_keypoints.json')\n\n        kpts = []\n\n        for preds, boxes, image_path, _ in outputs:\n            str_image_path = ''.join(image_path)\n            image_id = int(osp.basename(osp.splitext(str_image_path)[0]))\n\n            kpts.append({\n                'keypoints': preds[0].tolist(),\n                'center': boxes[0][0:2].tolist(),\n                'scale': boxes[0][2:4].tolist(),\n                'area': float(boxes[0][4]),\n                'score': float(boxes[0][5]),\n                'image_id': image_id,\n            })\n\n        self._write_keypoint_results(kpts, res_file)\n        info_str = self._report_metric(res_file)\n        name_value = OrderedDict(info_str)\n\n        return name_value\n\n    @staticmethod\n    def _write_keypoint_results(keypoints, res_file):\n        \"\"\"Write results into a json file.\"\"\"\n\n        with open(res_file, 'w') as f:\n            json.dump(keypoints, f, sort_keys=True, indent=4)\n\n    def _report_metric(self, res_file):\n        \"\"\"Keypoint evaluation.\n\n        Report Mean Acc of skeleton, contour and all joints.\n        \"\"\"\n        num_joints = self.ann_info['num_joints']\n        hit = np.zeros(num_joints, dtype=np.float32)\n        exist = np.zeros(num_joints, dtype=np.float32)\n\n        with open(res_file, 'r') as fin:\n            preds = json.load(fin)\n\n        assert len(preds) == len(\n            self.db), f'len(preds)={len(preds)}, len(self.db)={len(self.db)}'\n        for pred, item in zip(preds, self.db):\n            h, e = self._evaluate_kernel(pred['keypoints'], item['joints_3d'],\n                                         item['joints_3d_visible'],\n                                         item['headbox'])\n            hit += h\n            exist += e\n        skeleton = np.sum(hit[:14]) / np.sum(exist[:14])\n        contour = np.sum(hit[14:]) / np.sum(exist[14:])\n        mean = np.sum(hit) / np.sum(exist)\n\n        info_str = []\n        info_str.append(('Skeleton_acc', skeleton.item()))\n        info_str.append(('Contour_acc', contour.item()))\n        info_str.append(('PCKh', mean.item()))\n        return info_str\n", "path": "mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py"}], "after_files": [{"content": "import copy as cp\nimport os\nimport os.path as osp\nfrom collections import OrderedDict\n\nimport json_tricks as json\nimport numpy as np\n\nfrom mmpose.datasets.builder import DATASETS\nfrom .topdown_base_dataset import TopDownBaseDataset\n\n\n@DATASETS.register_module()\nclass TopDownMpiiTrbDataset(TopDownBaseDataset):\n    \"\"\"MPII-TRB Dataset dataset for top-down pose estimation.\n\n    `TRB: A Novel Triplet Representation for Understanding 2D Human Body`\n    ICCV'2019 More details can be found in the `paper\n    <https://arxiv.org/abs/1910.11535>`__ .\n\n    The dataset loads raw features and apply specified transforms\n    to return a dict containing the image tensors and other information.\n\n    Args:\n        ann_file (str): Path to the annotation file.\n        img_prefix (str): Path to a directory where images are held.\n            Default: None.\n        data_cfg (dict): config\n        pipeline (list[dict | callable]): A sequence of data transforms.\n        test_mode (bool): Store True when building test or\n            validation dataset. Default: False.\n    \"\"\"\n\n    def __init__(self,\n                 ann_file,\n                 img_prefix,\n                 data_cfg,\n                 pipeline,\n                 test_mode=False):\n\n        super().__init__(\n            ann_file, img_prefix, data_cfg, pipeline, test_mode=test_mode)\n\n        # flip_pairs in MPII-TRB\n        self.ann_info['flip_pairs'] = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9],\n                                       [10, 11], [14, 15]]\n        for i in range(6):\n            self.ann_info['flip_pairs'].append([16 + i, 22 + i])\n            self.ann_info['flip_pairs'].append([28 + i, 34 + i])\n\n        self.ann_info['upper_body_ids'] = [0, 1, 2, 3, 4, 5, 12, 13]\n        self.ann_info['lower_body_ids'] = [6, 7, 8, 9, 10, 11]\n        self.ann_info['upper_body_ids'].extend(list(range(14, 28)))\n        self.ann_info['lower_body_ids'].extend(list(range(28, 40)))\n\n        self.ann_info['use_different_joint_weights'] = False\n\n        assert self.ann_info['num_joints'] == 40\n        self.ann_info['joint_weights'] = np.ones(\n            (self.ann_info['num_joints'], 1), dtype=np.float32)\n\n        self.db = self._get_db(ann_file)\n        self.image_set = set(x['image_file'] for x in self.db)\n        self.num_images = len(self.image_set)\n\n        print(f'=> num_images: {self.num_images}')\n        print(f'=> load {len(self.db)} samples')\n\n    def _get_db(self, ann_file):\n        \"\"\"Load dataset.\"\"\"\n        with open(ann_file, 'r') as f:\n            data = json.load(f)\n        tmpl = dict(\n            image_file=None,\n            center=None,\n            scale=None,\n            rotation=0,\n            joints_3d=None,\n            joints_3d_visible=None,\n            dataset='mpii_trb')\n\n        imid2info = {\n            int(osp.splitext(x['file_name'])[0]): x\n            for x in data['images']\n        }\n\n        num_joints = self.ann_info['num_joints']\n        gt_db = []\n\n        for anno in data['annotations']:\n            newitem = cp.deepcopy(tmpl)\n            image_id = anno['image_id']\n            newitem['image_file'] = os.path.join(\n                self.img_prefix, imid2info[image_id]['file_name'])\n\n            if max(anno['keypoints']) == 0:\n                continue\n\n            joints_3d = np.zeros((num_joints, 3), dtype=np.float32)\n            joints_3d_visible = np.zeros((num_joints, 3), dtype=np.float32)\n\n            for ipt in range(num_joints):\n                joints_3d[ipt, 0] = anno['keypoints'][ipt * 3 + 0]\n                joints_3d[ipt, 1] = anno['keypoints'][ipt * 3 + 1]\n                joints_3d[ipt, 2] = 0\n                t_vis = min(anno['keypoints'][ipt * 3 + 2], 1)\n                joints_3d_visible[ipt, :] = (t_vis, t_vis, 0)\n\n            center = np.array(anno['center'], dtype=np.float32)\n            scale = self.ann_info['image_size'] / anno['scale'] / 200.0\n            newitem['center'] = center\n            newitem['scale'] = scale\n            newitem['joints_3d'] = joints_3d\n            newitem['joints_3d_visible'] = joints_3d_visible\n            if 'headbox' in anno:\n                newitem['headbox'] = anno['headbox']\n            gt_db.append(newitem)\n\n        return gt_db\n\n    def _evaluate_kernel(self, pred, joints_3d, joints_3d_visible, headbox):\n        \"\"\"Evaluate one example.\"\"\"\n        num_joints = self.ann_info['num_joints']\n        headbox = np.array(headbox)\n        threshold = np.linalg.norm(headbox[:2] - headbox[2:]) * 0.3\n        hit = np.zeros(num_joints, dtype=np.float32)\n        exist = np.zeros(num_joints, dtype=np.float32)\n\n        for i in range(num_joints):\n            pred_pt = pred[i]\n            gt_pt = joints_3d[i]\n            vis = joints_3d_visible[i][0]\n            if vis:\n                exist[i] = 1\n            else:\n                continue\n            distance = np.linalg.norm(pred_pt[:2] - gt_pt[:2])\n            if distance < threshold:\n                hit[i] = 1\n        return hit, exist\n\n    def evaluate(self, outputs, res_folder, metric='PCKh', **kwargs):\n        \"\"\"Evaluate PCKh for MPII-TRB dataset.\n\n        Note:\n            batch_size: N\n            num_keypoints: K\n            heatmap height: H\n            heatmap width: W\n\n        Args:\n            outputs(list(preds, boxes, image_path, heatmap)):\n\n                * preds(np.ndarray[1,K,3]): The first two dimensions are\n                  coordinates, score is the third dimension of the array.\n                * boxes(np.ndarray[1,6]): [center[0], center[1], scale[0]\n                  , scale[1],area, score]\n                * image_path(list[str]): For example, ['0', '0',\n                  '0', '0', '0', '1', '1', '6', '3', '.', 'j', 'p', 'g']\n                * heatmap (np.ndarray[N, K, H, W]): model output heatmap.\n            res_folder(str): Path of directory to save the results.\n            metric (str | list[str]): Metrics to be performed.\n                Defaults: 'PCKh'.\n\n        Returns:\n            dict: PCKh for each joint\n        \"\"\"\n        metrics = metric if isinstance(metric, list) else [metric]\n        allowed_metrics = ['PCKh']\n        for metric in metrics:\n            if metric not in allowed_metrics:\n                raise KeyError(f'metric {metric} is not supported')\n\n        res_file = os.path.join(res_folder, 'result_keypoints.json')\n\n        kpts = []\n\n        for preds, boxes, image_path, _ in outputs:\n            str_image_path = ''.join(image_path)\n            image_id = int(osp.basename(osp.splitext(str_image_path)[0]))\n\n            kpts.append({\n                'keypoints': preds[0].tolist(),\n                'center': boxes[0][0:2].tolist(),\n                'scale': boxes[0][2:4].tolist(),\n                'area': float(boxes[0][4]),\n                'score': float(boxes[0][5]),\n                'image_id': image_id,\n            })\n\n        self._write_keypoint_results(kpts, res_file)\n        info_str = self._report_metric(res_file)\n        name_value = OrderedDict(info_str)\n\n        return name_value\n\n    @staticmethod\n    def _write_keypoint_results(keypoints, res_file):\n        \"\"\"Write results into a json file.\"\"\"\n\n        with open(res_file, 'w') as f:\n            json.dump(keypoints, f, sort_keys=True, indent=4)\n\n    def _report_metric(self, res_file):\n        \"\"\"Keypoint evaluation.\n\n        Report Mean Acc of skeleton, contour and all joints.\n        \"\"\"\n        num_joints = self.ann_info['num_joints']\n        hit = np.zeros(num_joints, dtype=np.float32)\n        exist = np.zeros(num_joints, dtype=np.float32)\n\n        with open(res_file, 'r') as fin:\n            preds = json.load(fin)\n\n        assert len(preds) == len(\n            self.db), f'len(preds)={len(preds)}, len(self.db)={len(self.db)}'\n        for pred, item in zip(preds, self.db):\n            h, e = self._evaluate_kernel(pred['keypoints'], item['joints_3d'],\n                                         item['joints_3d_visible'],\n                                         item['headbox'])\n            hit += h\n            exist += e\n        skeleton = np.sum(hit[:14]) / np.sum(exist[:14])\n        contour = np.sum(hit[14:]) / np.sum(exist[14:])\n        mean = np.sum(hit) / np.sum(exist)\n\n        info_str = []\n        info_str.append(('Skeleton_acc', skeleton.item()))\n        info_str.append(('Contour_acc', contour.item()))\n        info_str.append(('PCKh', mean.item()))\n        return info_str\n", "path": "mmpose/datasets/datasets/top_down/topdown_mpii_trb_dataset.py"}]}