{"record":{"id":"40f8d275dea538c1","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"unknown-iou-type-40f8d2","errorCode":null,"errorMessage":"Unknown iou type {}","messagePattern":"Unknown iou type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/yolov3_spp/train_utils/coco_eval.py","lineNumber":66,"sourceCode":"\n    def accumulate(self):\n        for coco_eval in self.coco_eval.values():\n            coco_eval.accumulate()\n\n    def summarize(self):\n        for iou_type, coco_eval in self.coco_eval.items():\n            print(\"IoU metric: {}\".format(iou_type))\n            coco_eval.summarize()\n\n    def prepare(self, predictions, iou_type):\n        if iou_type == \"bbox\":\n            return self.prepare_for_coco_detection(predictions)\n        elif iou_type == \"segm\":\n            return self.prepare_for_coco_segmentation(predictions)\n        elif iou_type == \"keypoints\":\n            return self.prepare_for_coco_keypoint(predictions)\n        else:\n            raise ValueError(\"Unknown iou type {}\".format(iou_type))\n\n    def prepare_for_coco_detection(self, predictions):\n        coco_results = []\n        for original_id, prediction in predictions.items():\n            if len(prediction) == 0:\n                continue\n\n            boxes = prediction[\"boxes\"]\n            boxes = convert_to_xywh(boxes).tolist()\n            scores = prediction[\"scores\"].tolist()\n            labels = prediction[\"labels\"].tolist()\n\n            coco_results.extend(\n                [\n                    {\n                        \"image_id\": original_id,\n                        \"category_id\": labels[k],\n                        \"bbox\": box,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/WZMIAOMIAO/deep-learning-for-image-processing/blob/1ec3fe6f374fc9969973a61f819de25658595afa/pytorch_object_detection/yolov3_spp/train_utils/coco_eval.py#L48-L84","documentation":"CocoEvaluator.prepare() dispatches prediction-preparation based on the COCO iou_type ('bbox', 'segm', 'keypoints'). If iou_type is anything else, it raises ValueError because there is no prepare_for_coco_* method for it. This guards against typos or unsupported task types passed when constructing/using CocoEvaluator.","triggerScenarios":"Calling prepare() (indirectly via update()) on a CocoEvaluator that was constructed with an iou_type string other than 'bbox', 'segm', or 'keypoints' — e.g. a typo like 'box' or 'segmentation'.","commonSituations":"Typo in the iou_type list passed to CocoEvaluator; copying evaluation code from a detection example into a segmentation or keypoint project and editing the string incorrectly; using a custom task type the evaluator doesn't support.","solutions":["Use one of the supported iou_type values: 'bbox', 'segm', or 'keypoints'.","Check the exact strings passed in the iou_types list when constructing CocoEvaluator and fix typos.","If you need a new task type, add a prepare_for_coco_<type> method and extend the dispatch chain in prepare()."],"exampleFix":"// before\niou_types = ['box']\ncoco_evaluator = CocoEvaluator(base_dataset, iou_types=iou_types)\n// after\niou_types = ['bbox']\ncoco_evaluator = CocoEvaluator(base_dataset, iou_types=iou_types)","handlingStrategy":"validation","validationCode":"SUPPORTED = {'bbox', 'segm', 'keypoints'}\nassert set(iou_types).issubset(SUPPORTED), f\"bad iou_type: {iou_types}\"","typeGuard":"def is_supported_iou_type(t) -> bool:\n    return isinstance(t, str) and t in ('bbox', 'segm', 'keypoints')","tryCatchPattern":"try:\n    evaluator.update(predictions)\nexcept ValueError as e:\n    logging.error(f\"COCO eval misconfigured: {e}\"); raise","preventionTips":["Keep iou_types as a module-level constant with only the three supported strings","Derive iou_types from the task type rather than hand-editing strings","Unit-test CocoEvaluator construction for each supported task"],"tags":["value-error","coco","configuration","typo"],"backgroundTag":"unsupported-iou-type","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}