Matching Logic

src.pipeline.prelabelling.matching.compute_iou(box1: List[float], box2: List[float]) float[source]

Compute IoU between two bounding boxes in [x1, y1, x2, y2] format.

src.pipeline.prelabelling.matching.match_and_filter(yolo_dir: Path, dino_dir: Path, labeled_dir: Path, pending_dir: Path, config: Dict) None[source]

Compare YOLO and DINO predictions for each image. Save YOLO prediction files to labeled_dir if they match DINO confidently. Save unmatched/mismatched files to pending_dir for review.

Thresholds and behavior are controlled via config dictionary.

src.pipeline.prelabelling.matching.match_predictions(yolo_preds: List[Dict], dino_preds: List[Dict], iou_thresh: float) List[bool][source]

Match YOLO boxes with DINO boxes using both class name and IOU. Returns a list of booleans indicating whether each YOLO box was matched.

src.pipeline.prelabelling.matching.normalize_class(c: str) str[source]

Normalize class names by removing BSI suffixes and lowercasing. Used for matching between YOLO and DINO predictions.