{"record":{"id":"93a25829c5de02c5","repo":"open-mmlab/mmdetection","slug":"deprecationwarning-setting-linear-true-in-iou-l","errorCode":null,"errorMessage":"DeprecationWarning: Setting \"linear=True\" in iou_loss is deprecated, please use \"mode=`linear`\" instead.","messagePattern":"DeprecationWarning: Setting \"linear=True\" in iou_loss is deprecated, please use \"mode=`linear`\" instead\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/models/losses/iou_loss.py","lineNumber":42,"sourceCode":"    The loss is calculated as negative log of IoU.\n\n    Args:\n        pred (Tensor): Predicted bboxes of format (x1, y1, x2, y2),\n            shape (n, 4).\n        target (Tensor): Corresponding gt bboxes, shape (n, 4).\n        linear (bool, optional): If True, use linear scale of loss instead of\n            log scale. Default: False.\n        mode (str): Loss scaling mode, including \"linear\", \"square\", and \"log\".\n            Default: 'log'\n        eps (float): Epsilon to avoid log(0).\n\n    Return:\n        Tensor: Loss tensor.\n    \"\"\"\n    assert mode in ['linear', 'square', 'log']\n    if linear:\n        mode = 'linear'\n        warnings.warn('DeprecationWarning: Setting \"linear=True\" in '\n                      'iou_loss is deprecated, please use \"mode=`linear`\" '\n                      'instead.')\n    # avoid fp16 overflow\n    if pred.dtype == torch.float16:\n        fp16 = True\n        pred = pred.to(torch.float32)\n    else:\n        fp16 = False\n\n    ious = bbox_overlaps(pred, target, is_aligned=True).clamp(min=eps)\n\n    if fp16:\n        ious = ious.to(torch.float16)\n\n    if mode == 'linear':\n        loss = 1 - ious\n    elif mode == 'square':\n        loss = 1 - ious**2","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/losses/iou_loss.py#L24-L60","documentation":"Deprecation warning from IoULoss.forward: the legacy `linear=True` constructor/forward argument is deprecated in favor of the unified `mode` parameter (mode must be one of 'linear', 'square', 'log'). When linear=True is passed, the code silently coerces mode='linear' and warns; the linear flag will be removed in a future release.","triggerScenarios":"Calling iou_loss(...) / training a detector whose cfg uses loss_iou=dict(type='IoULoss', linear=True), or calling IoULoss.forward with linear=True. Any config carried over from older mmdet versions that still specifies linear=True.","commonSituations":"Upgrading mmdet (2.x era configs) to newer versions where the loss API was consolidated around `mode`; stale custom configs or third-party config repos.","solutions":["Replace linear=True with mode='linear' in the loss_iou / IoULoss config dict","Remove any linear= key entirely if 'linear' behavior is not intended","Search configs for 'linear=True' and update all occurrences"],"exampleFix":"# before\nloss_iou=dict(type='IoULoss', linear=True)\n# after\nloss_iou=dict(type='IoULoss', mode='linear')","handlingStrategy":"validation","validationCode":"assert 'linear' not in loss_cfg, 'use mode=\\'linear\\' instead of linear=True'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the mmdet version your configs were written for","Run configs through mmdet's config checker / diff against current zoo configs on upgrade"],"tags":["mmdet","deprecation","iou-loss","config"],"backgroundTag":"deprecated-argument-migrated","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}