WZMIAOMIAO/deep-learning-for-image-processing · error · ValueError
Unknown iou type {}
Error message
Unknown iou type {} What it means
COCO results preparation in coco_eval.py dispatches on the iou_type of the COCO evaluator (bbox/segm/keypoints). If the evaluator's iou_type is any other string, prepare() raises ValueError. Detection-only RetinaNet training normally uses 'bbox', so this indicates a misconfigured evaluator.
Source
Thrown at pytorch_object_detection/retinaNet/train_utils/coco_eval.py:66
def accumulate(self):
for coco_eval in self.coco_eval.values():
coco_eval.accumulate()
def summarize(self):
for iou_type, coco_eval in self.coco_eval.items():
print("IoU metric: {}".format(iou_type))
coco_eval.summarize()
def prepare(self, predictions, iou_type):
if iou_type == "bbox":
return self.prepare_for_coco_detection(predictions)
elif iou_type == "segm":
return self.prepare_for_coco_segmentation(predictions)
elif iou_type == "keypoints":
return self.prepare_for_coco_keypoint(predictions)
else:
raise ValueError("Unknown iou type {}".format(iou_type))
def prepare_for_coco_detection(self, predictions):
coco_results = []
for original_id, prediction in predictions.items():
if len(prediction) == 0:
continue
boxes = prediction["boxes"]
boxes = convert_to_xywh(boxes).tolist()
scores = prediction["scores"].tolist()
labels = prediction["labels"].tolist()
coco_results.extend(
[
{
"image_id": original_id,
"category_id": labels[k],
"bbox": box,View on GitHub (pinned to 1ec3fe6f37)
Solutions
- Check the iouType on the base COCO evaluator before wrapping it in CocoEvaluator; use 'bbox' for detection
- Pass the base coco_evaluator only after it was created with COCO(..., ) and evaluate(imgs) with iouType='bbox'
- Add a guard that only builds CocoEvaluator when iou_type in ('bbox','segm','keypoints')
Example fix
// before coco_evaluator = COCO(...) coco_evaluator.params.iouType = 'stuff' // after coco_evaluator.params.iouType = 'bbox' coco_evaluator = CocoEvaluator(coco_evaluator, iou_types=['bbox'])
Defensive patterns
Strategy: validation
Validate before calling
iou_type = coco_evaluator.coco_eval['bbox'].params.iouType if 'bbox' in coco_evaluator.coco_eval else 'unknown'
assert iou_type in ('bbox', 'segm', 'keypoints'), f'unsupported iouType: {iou_type}' Type guard
def has_supported_iou_type(evaluator) -> bool:
return getattr(getattr(evaluator, 'params', None), 'iouType', None) in ('bbox', 'segm', 'keypoints') Try / catch
try:
coco_evaluator.update(predictions)
except ValueError as e:
print(f'iouType misconfigured: {e}; defaulting to bbox') Prevention
- Never modify params.iouType after creating the evaluator
- Only wrap evaluators created with standard iouTypes
- Pin to this repo's CocoEvaluator API expectations (bbox for detection)
When it happens
Trigger: Constructing a CocoEvaluator whose base coco_evaluator has iouType set to something other than 'bbox', 'segm', or 'keypoints', then calling update() which invokes prepare().
Common situations: Copying evaluation code for instance segmentation and setting iouType='stuff' or leaving a typo in iouType; mixing evaluation classes from other repos.
Related errors
- not support iou_type: {self.iou_type}
- Unknown iou type {}
- illegal stride value.
- The inverted_residual_setting should not be empty.
- expected stages_repeats as list of 3 positive ints
AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30).
Data as JSON: /api/errors/da78b84086ba486a.
Report an issue: GitHub.