THU-MIG / yolov10

YOLOv10: Real-Time End-to-End Object Detection [NeurIPS 2024]
https://arxiv.org/abs/2405.14458
GNU Affero General Public License v3.0
9.9k stars 978 forks source link

question about mAP one2one vs one2many #214

Closed power0341 closed 5 months ago

power0341 commented 5 months ago

i made a dirt modification to see the difference btw one2one and one2many predictions, i thought one2one is at its best as good as one2many, but i got this for one2one

yolo val task=detect model=yolov10n.pt imgsz=640 conf=0.25 iou=0.7 data=coco.yaml name=one2one

image

and this for one2many

yolo val task=detect model=yolov10n.pt imgsz=640 conf=0.25 iou=0.7 data=coco.yaml name=one2many

image

below is my changes

from ultralytics.models.yolo.detect import DetectionValidator
from ultralytics.utils import ops
import torch

class YOLOv10DetectionValidator(DetectionValidator):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.args.save_json |= self.is_coco

    def postprocess(self, preds):
        # if isinstance(preds, dict):
        #     preds = preds["one2one"]

        # if isinstance(preds, (list, tuple)):
        #     preds = preds[0]

        # # Acknowledgement: Thanks to sanha9999 in #190 and #181!
        # if preds.shape[-1] == 6:
        #     return preds
        # else:
        #     preds = preds.transpose(-1, -2)
        #     boxes, scores, labels = ops.v10postprocess(preds, self.args.max_det, self.nc)
        #     bboxes = ops.xywh2xyxy(boxes)
        #     return torch.cat([bboxes, scores.unsqueeze(-1), labels.unsqueeze(-1)], dim=-1)
        return ops.non_max_suppression(
            preds["one2many"],
            self.args.conf,
            self.args.iou,
            labels=self.lb,
            multi_label=True,
            agnostic=self.args.single_cls,
            max_det=self.args.max_det,
        )
leonnil commented 5 months ago

Thank you for your interest! During the validation, it’s common to set conf=0.001 (default) rather thanconf=0.25.

power0341 commented 5 months ago

yeah yeah, my bad, i tried several conf thres values, at 0.001, it looked perfectly fine, then i started increasing the conf value, saw the map of one2many' went down quickly, but one2one's stood still

thx you mention that, now i just realize the v10postprocess function doesnt care conf at all