{"record":{"id":"61f68b6d32db6b4d","repo":"WZMIAOMIAO/deep-learning-for-image-processing","slug":"unknown-iou-type","errorCode":null,"errorMessage":"Unknown iou type {}","messagePattern":"Unknown iou type (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pytorch_object_detection/faster_rcnn/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/faster_rcnn/train_utils/coco_eval.py#L48-L84","documentation":"CocoEval.prepare dispatches on iou_type (bbox/segm/keypoints); any other value falls through to ValueError 'Unknown iou type'. The iou_type usually comes from the COCO dataset's annotation file or is set on the evaluator.","triggerScenarios":"Constructing COCOResults/CocoEval with iou_type outside {bbox, segm, keypoints}, e.g. a typo like 'bboxes' or a task-specific string like 'tracking'.","commonSituations":"Hand-edited COCO annotation 'info' fields, custom datasets with unusual iou_type, version drift between pycocotools-style evaluators and this vendored copy.","solutions":["Set iou_type to one of \"bbox\", \"segm\", or \"keypoints\"","Check the COCO annotation JSON (jsonInfo['info'] / dataset task type) for a nonstandard iou_type value","If evaluating a new task type, extend prepare() with a prepare_for_<type> branch instead of reusing the existing one"],"exampleFix":"// before\nevaluator = CocoEval(coco_gt, iou_type=\"bboxes\")\n// after\nevaluator = CocoEval(coco_gt, iou_type=\"bbox\")","handlingStrategy":"validation","validationCode":"VALID_IOU_TYPES = {\"bbox\", \"segm\", \"keypoints\"}\nassert iou_type in VALID_IOU_TYPES, f\"iou_type must be one of {VALID_IOU_TYPES}, got {iou_type}\"","typeGuard":"def is_valid_iou_type(t) -> bool:\n    return t in (\"bbox\", \"segm\", \"keypoints\")","tryCatchPattern":"try:\n    results = evaluator.prepare(predictions)\nexcept ValueError as e:\n    if \"Unknown iou type\" in str(e):\n        iou_type = \"bbox\"\n        results = evaluator.prepare(predictions)","preventionTips":["Only use iou_type values: bbox, segm, keypoints","Validate iou_type from external annotation files before passing it in","For new task types, add a corresponding prepare_for_* branch"],"tags":["python","valueerror","coco","evaluation"],"backgroundTag":"unsupported-enum-value","analyzedSha":"1ec3fe6f374fc9969973a61f819de25658595afa","analyzedAt":"2026-08-30T09:19:11.901Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}