ultralytics / yolov5

YOLOv5 🚀 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
50.33k stars 16.25k forks source link

apply dIOU replace gIOU #64

Closed lucasjinreal closed 4 years ago

lucasjinreal commented 4 years ago

Will dIOU obtain a better result then gIOU?

glenn-jocher commented 4 years ago

I don't know. You can use g/d/ciou in the loss function by specifying it here. To use DIoU you would pass DIoU=True in place of the current GIoU on L413.

https://github.com/ultralytics/yolov5/blob/111994956ede6964433e02bc3f64deb04b9916ac/utils/utils.py#L409-L413

aktiver commented 2 years ago

Update for Yolov5: This is now inloss.pyon line 141:

Default (CIoU): Paper iou = bbox_iou(pbox, tbox[i], CIoU=True).squeeze() # iou(prediction, target)

GIoU: Paper iou = bbox_iou(pbox, tbox[i], GIoU=True).squeeze() # iou(prediction, target)

DIoU: Paper iou = bbox_iou(pbox, tbox[i], DIoU=True).squeeze() # iou(prediction, target)

The definition of bbox_iou is on line 216 in metrics.py.

glenn-jocher commented 11 months ago

@aktiver thanks for your update! The implementation of DIoU, GIoU, and CIoU are all available in the loss.py file, and the bbox_iou definition can be found in the metrics.py file. You can now easily choose and use the desired IoU metric in your YOLOv5 implementation. If you have further questions or need assistance, feel free to reach out.