1. YOLOv10中添加MPDIoU, GIoU,DIoU, CIoU, SIoU等损失函数的方式
第一步: 在 ultralytics/utils/metrics.py
文件中用给出的代码替换掉
def bbox_iou(box1, box2, xywh=True, GIoU=False, DIoU=False, CIoU=False, eps=1e-7):的全部代码
class WIoU_Scale:
iou_mean = 1.
monotonous = False
_momentum = 1 - 0.5 ** (1 / 7000)
_is_train = True
def __init__(self, iou):
self.iou = iou
self._update(self)
@classmethod
def _update(cls, self):
if cls._is_train: cls.iou_mean = (1 - cls._momentum) * cls.iou_mean + \
cls._momentum * self.iou.detach().mean().item()