{"record":{"id":"7f1a3ea6df39288c","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"not-support-iou-type-self-iou-type","errorCode":null,"errorMessage":"not support iou_type: {self.iou_type}","messagePattern":"not support iou_type: (.+?)","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"pytorch_keypoint/HRNet/train_utils/coco_eval.py","lineNumber":99,"sourceCode":"            keypoints = np.concatenate([keypoints, scores], axis=1)\n            keypoints = np.reshape(keypoints, -1)\n\n            # We recommend rounding coordinates to the nearest tenth of a pixel\n            # to reduce resulting JSON file size.\n            keypoints = [round(k, 2) for k in keypoints.tolist()]\n\n            res = {\"image_id\": target[\"image_id\"],\n                   \"category_id\": 1,  # person\n                   \"keypoints\": keypoints,\n                   \"score\": target[\"score\"] * k_score}\n\n            self.results.append(res)\n\n    def update(self, targets, outputs):\n        if self.iou_type == \"keypoints\":\n            self.prepare_for_coco_keypoints(targets, outputs)\n        else:\n            raise KeyError(f\"not support iou_type: {self.iou_type}\")\n\n    def synchronize_results(self):\n        # 同步所有进程中的数据\n        eval_ids, eval_results = merge(self.obj_ids, self.results)\n        self.aggregation_results = {\"obj_ids\": eval_ids, \"results\": eval_results}\n\n        # 主进程上保存即可\n        if is_main_process():\n            # results = []\n            # [results.extend(i) for i in eval_results]\n            # write predict results into json file\n            json_str = json.dumps(eval_results, indent=4)\n            with open(self.results_file_name, 'w') as json_file:\n                json_file.write(json_str)\n\n    def evaluate(self):\n        # 只在主进程上评估即可\n        if is_main_process():","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_keypoint/HRNet/train_utils/coco_eval.py#L81-L117","documentation":"CocoEval.update() only implements result preparation for iou_type == 'keypoints'; any other configured iou_type (e.g. 'bbox' or 'segm') hits the else branch and raises KeyError with the unsupported type. The wrapper class is a keypoint-specific adaptation of pycocotools' COCOeval, so it deliberately rejects other evaluation types.","triggerScenarios":"Constructing the evaluator (or passing a config) with iou_type set to anything other than \"keypoints\", then calling update(targets, outputs) during validation.","commonSituations":"Copying the HRNet eval utils into a detection project and leaving/setting iou_type='bbox'; a config file shared between bbox and keypoint tasks; refactoring where the default iou_type changed.","solutions":["Set iou_type=\"keypoints\" where the evaluator is constructed for human-pose validation.","If you need bbox/segm eval, use pycocotools COCOeval directly or the torchvision coco_eval wrapper that supports those types.","Use the generic coco_eval.py from pytorch_object_detection/ references (supports bbox/segm) for detection tasks.","Guard the construction site to assert the supported value before training starts."],"exampleFix":"# before\ncoco_evaluator = CocoEvaluator(base_dataset, iou_type=\"bbox\")\n# after\ncoco_evaluator = CocoEvaluator(base_dataset, iou_type=\"keypoints\")","handlingStrategy":"validation","validationCode":"SUPPORTED_IOU_TYPES = {\"keypoints\"}\nassert iou_type in SUPPORTED_IOU_TYPES, f\"HRNet CocoEval only supports {SUPPORTED_IOU_TYPES}, got {iou_type}\"","typeGuard":"def is_keypoint_eval(iou_type: str) -> bool:\n    return iou_type == \"keypoints\"","tryCatchPattern":"try:\n    coco_evaluator.update(targets, outputs)\nexcept KeyError as e:\n    logging.error(\"Unsupported iou_type configured: %s\", e)\n    raise SystemExit(\"Set iou_type='keypoints' for pose evaluation\")","preventionTips":["Keep task-specific configs (bbox vs keypoints) separate.","Assert iou_type at evaluator construction time.","Use pycocotools COCOeval directly for bbox/segm tasks."],"tags":["pytorch","coco","evaluation","keypoints","config"],"backgroundTag":"unsupported-eval-type","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}