open-mmlab/mmdetection · warning

DeprecationWarning: Setting "linear=True" in IOULoss is depr

Error message

DeprecationWarning: Setting "linear=True" in IOULoss is deprecated, please use "mode=`linear`" instead.

What it means

Deprecation warning from IoULoss.__init__: constructing IoULoss with the legacy `linear=True` argument is deprecated; use mode='linear' instead. The constructor asserts mode in ['linear','square','log'] and coerces mode when linear is set, warning before the flag is removed.

Source

Thrown at mmdet/models/losses/iou_loss.py:435

            by mode. Default: False.
        eps (float): Epsilon to avoid log(0).
        reduction (str): Options are "none", "mean" and "sum".
        loss_weight (float): Weight of loss.
        mode (str): Loss scaling mode, including "linear", "square", and "log".
            Default: 'log'
    """

    def __init__(self,
                 linear: bool = False,
                 eps: float = 1e-6,
                 reduction: str = 'mean',
                 loss_weight: float = 1.0,
                 mode: str = 'log') -> None:
        super().__init__()
        assert mode in ['linear', 'square', 'log']
        if linear:
            mode = 'linear'
            warnings.warn('DeprecationWarning: Setting "linear=True" in '
                          'IOULoss is deprecated, please use "mode=`linear`" '
                          'instead.')
        self.mode = mode
        self.linear = linear
        self.eps = eps
        self.reduction = reduction
        self.loss_weight = loss_weight

    def forward(self,
                pred: Tensor,
                target: Tensor,
                weight: Optional[Tensor] = None,
                avg_factor: Optional[int] = None,
                reduction_override: Optional[str] = None,
                **kwargs) -> Tensor:
        """Forward function.

        Args:

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Change linear=True to mode='linear' in the IoULoss config
  2. Delete the linear key if default 'log' mode is desired
  3. Grep configs for 'linear=' and migrate

Example fix

# before
loss_iou=dict(type='IoULoss', linear=True, loss_weight=1.0)
# after
loss_iou=dict(type='IoULoss', mode='linear', loss_weight=1.0)
Defensive patterns

Strategy: validation

Validate before calling

assert 'linear' not in loss_iou_cfg, 'IoULoss: use mode=\'linear\' not linear=True'

Prevention

When it happens

Trigger: Instantiating IoULoss(linear=True) directly or via config builder with a linear key present; old configs written before the mode parameter existed.

Common situations: Version upgrades of mmdet where loss configs were refactored; copied configs from older model zoos or tutorials.

Related errors


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