Sobes.tech
Senior

How does bounding box matching work in YOLO and DETR models?

sobes.tech AI

Answer from AI

In object detection models such as YOLO and DETR, bounding box matching is the process of associating predicted boxes with ground truth boxes for training and evaluation.

YOLO:

  • Uses a predefined grid and anchor boxes.
  • For each anchor box, the ground truth with the maximum IoU (Intersection over Union) is selected.
  • Matching is based on an IoU threshold: if the IoU between the predicted and true box exceeds the threshold, they are considered a match.
  • This allows the model to learn to predict object coordinates and classes accurately.

DETR:

  • Uses a transformer and a set of predicted objects without anchors.
  • Matching is performed using the Hungarian matching algorithm.
  • For each pair (prediction, ground truth), a cost is computed considering:
    • Distance between box coordinates (e.g., L1 loss)
    • IoU (or generalized IoU)
    • Class error
  • The Hungarian algorithm finds the optimal matching that minimizes the total cost.
  • This approach allows efficient matching of predictions to objects, even when their numbers differ.

Thus, YOLO relies on strict rules and anchors, while DETR relies on an optimization algorithm for dynamic matching without anchors.