open-mmlab/mmdetection · warning

``build_iou_calculator`` would be deprecated soon, please us

Error message

``build_iou_calculator`` would be deprecated soon, please use ``mmdet.registry.TASK_UTILS.build()`` 

What it means

Deprecation warning from build_iou_calculator: this convenience builder just forwards to TASK_UTILS.build and will be removed. Build IoU calculators via mmdet.registry.TASK_UTILS.build(cfg, default_args) instead.

Source

Thrown at mmdet/models/task_modules/builder.py:24

PRIOR_GENERATORS = TASK_UTILS
ANCHOR_GENERATORS = TASK_UTILS
BBOX_ASSIGNERS = TASK_UTILS
BBOX_SAMPLERS = TASK_UTILS
BBOX_CODERS = TASK_UTILS
MATCH_COSTS = TASK_UTILS
IOU_CALCULATORS = TASK_UTILS


def build_bbox_coder(cfg, **default_args):
    """Builder of box coder."""
    warnings.warn('``build_sampler`` would be deprecated soon, please use '
                  '``mmdet.registry.TASK_UTILS.build()`` ')
    return TASK_UTILS.build(cfg, default_args=default_args)


def build_iou_calculator(cfg, default_args=None):
    """Builder of IoU calculator."""
    warnings.warn(
        '``build_iou_calculator`` would be deprecated soon, please use '
        '``mmdet.registry.TASK_UTILS.build()`` ')
    return TASK_UTILS.build(cfg, default_args=default_args)


def build_match_cost(cfg, default_args=None):
    """Builder of IoU calculator."""
    warnings.warn('``build_match_cost`` would be deprecated soon, please use '
                  '``mmdet.registry.TASK_UTILS.build()`` ')
    return TASK_UTILS.build(cfg, default_args=default_args)


def build_assigner(cfg, **default_args):
    """Builder of box assigner."""
    warnings.warn('``build_assigner`` would be deprecated soon, please use '
                  '``mmdet.registry.TASK_UTILS.build()`` ')
    return TASK_UTILS.build(cfg, default_args=default_args)

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Use TASK_UTILS.build(cfg, default_args=...) with the same cfg
  2. Update imports away from mmdet.models.task_modules.builder
  3. Remove usages of the deprecated helper module

Example fix

# before
from mmdet.models import build_iou_calculator
iou = build_iou_calculator(cfg)
# after
from mmdet.registry import TASK_UTILS
iou = TASK_UTILS.build(cfg)
Defensive patterns

Strategy: fallback

Validate before calling

from mmdet.registry import TASK_UTILS
iou = TASK_UTILS.build(cfg)  # avoids the deprecated shim

Try / catch

with warnings.catch_warnings():
    warnings.simplefilter('ignore', DeprecationWarning)
    iou = build_iou_calculator(cfg)

Prevention

When it happens

Trigger: Calling build_iou_calculator(cfg) directly or via the deprecated alias; configs/code referencing the old builder functions.

Common situations: Migrating detector code from old mmdet builder helpers to the TASK_UTILS registry.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/b28017ed6e8ebd73. Report an issue: GitHub.