{"record":{"id":"6ab5595ce09bde8d","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"not-support-iou-type-self-iou-type-6ab559","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_object_detection/mask_rcnn/train_utils/coco_eval.py","lineNumber":130,"sourceCode":"\n                class_idx = int(label)\n                if self.classes_mapping is not None:\n                    class_idx = int(self.classes_mapping[str(class_idx)])\n\n                res = {\"image_id\": img_id,\n                       \"category_id\": class_idx,\n                       \"segmentation\": rle,\n                       \"score\": round(score, 3)}\n                res_list.append(res)\n            self.results.append(res_list)\n\n    def update(self, targets, outputs):\n        if self.iou_type == \"bbox\":\n            self.prepare_for_coco_detection(targets, outputs)\n        elif self.iou_type == \"segm\":\n            self.prepare_for_coco_segmentation(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.img_ids, self.results)\n        self.aggregation_results = {\"img_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(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":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/mask_rcnn/train_utils/coco_eval.py#L112-L148","documentation":"CocoEvaluator.update only supports the iou_types 'bbox' and 'segm'; anything else (e.g. 'keypoints') has no prepare method wired up and raises KeyError. Note the message says 'not support' despite being a KeyError.","triggerScenarios":"Constructing CocoEvaluator(coco_gt, iou_types=[\"keypoints\"]) or any unsupported type, then calling update(targets, outputs).","commonSituations":"Copying detection code to a pose-estimation task; typo in iou_type like 'bboxs' or 'segmentation'; passing a list element from torchvision defaults that this vendored copy doesn't implement.","solutions":["Restrict iou_types to 'bbox' or 'segm' when building CocoEvaluator","Fix the typo in the iou_type string","Add a prepare_for_coco_keypoints-style branch in coco_eval.py if you need keypoints"],"exampleFix":"// before\nevaluator = CocoEvaluator(coco_gt, iou_types=[\"keypoints\"])\n// after\nevaluator = CocoEvaluator(coco_gt, iou_types=[\"bbox\", \"segm\"])","handlingStrategy":"validation","validationCode":"SUPPORTED = {'bbox', 'segm'}\nassert set(iou_types).issubset(SUPPORTED), f\"iou_types must be subset of {SUPPORTED}\"\nevaluator = CocoEvaluator(coco_gt, iou_types=iou_types)","typeGuard":"def supported_iou_types(types):\n    return all(t in ('bbox', 'segm') for t in types)","tryCatchPattern":"try:\n    evaluator.update(targets, outputs)\nexcept KeyError as e:\n    if 'iou_type' in str(e): logger.error('unsupported iou_type; use bbox or segm')\n    raise","preventionTips":["Only pass 'bbox' or 'segm' iou_types with this vendored evaluator","Add tests that instantiate the evaluator with your configured types","Patch in keypoints support upstream before using it"],"tags":["python","coco","evaluation"],"backgroundTag":"unsupported-value","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}