code: def prepare_for_coco_keypoints(self, targets, outputs):
      # 遍历每个person的预测结果(注意这里不是每张，一张图片里可能有多个person)
      for target, keypoints, scores in zip(
          targets, outputs[0], outputs[1]
      ):
          if len(keypoints) == 0:
              continue
  
          obj_idx = int(target["obj_index"])
          if obj_idx in self.obj_ids:
              # 防止出现重复的数据
              continue
  
          self.obj_ids.append(obj_idx)
          # self.plot_img(target["image_path"], keypoints)
  
          mask = np.greater(scores, 0.2)
          if mask.sum() == 0:
              k_score = 0
          else:
              k_score = np.mean(scores[mask])
  
          keypoints = np.concatenate([keypoints, scores], axis=1)
          keypoints = np.reshape(keypoints, -1)
  
          # We recommend rounding coordinates to the nearest tenth of a pixel
          # to reduce resulting JSON file size.
          keypoints = [round(k, 2) for k in keypoints.tolist()]
  
          res = {
              "image_id": target["image_id"],
              "category_id": 1,  # person
              "keypoints": keypoints,
              "score": target["score"] * k_score,
          }
  
          self.results.append(res)
  
file_path: deep-learning-for-image-processing/pytorch_keypoint/HRNet/train_utils/coco_eval.py
imports: import json
  import copy
  from PIL import Image, ImageDraw
  import numpy
  from pycocotools.coco import COCO
  from pycocotools.cocoeval import COCOeval
  from .distributed_utils import all_gather, is_main_process
  from transforms import affine_points
label_desc: Use image node_id 3 for calling the EvalCOCOMetric obj's underlying member method code with example usage: obj.prepare_for_coco_keypoints(targets, outputs) without return types