Skip to content

find-above-iou-threshold: Find Overlapping Bounding Boxes

The find-above-iou-threshold command identifies Pascal VOC annotation files that contain overlapping bounding boxes with an Intersection over Union (IoU) value above a specified threshold. This is useful for finding potential duplicate annotations or objects that significantly overlap each other.

Usage

m3-download find-above-iou-threshold VOC_DIR THRESHOLD [--label-match]

Parameters

  • VOC_DIR: Directory containing Pascal VOC XML annotation files
  • THRESHOLD: IoU threshold value (0.0 - 1.0) above which overlaps are reported
  • --label-match: (Optional) Only consider boxes with the same class label as potential duplicates

IoU Explanation

The Intersection over Union (IoU) metric measures the overlap between two bounding boxes:

  • IoU = (Area of Intersection) / (Area of Union)
  • Values range from 0.0 (no overlap) to 1.0 (perfect overlap)
  • Higher values indicate more significant overlap

IoU Thresholds

  • Values around 0.5 are good for finding significant overlaps
  • Values below 0.3 may flag normal adjacent objects
  • Values above 0.8 will only detect nearly identical boxes

How It Works

  1. The command scans all XML files in the specified directory
  2. For each file, it:
    • Parses the bounding boxes from the Pascal VOC format
    • Computes IoU between each pair of boxes
    • Flags the file if any IoU exceeds the threshold
  3. Paths to files containing overlapping boxes are output to the console

Output

The command simply prints the paths of files with overlapping boxes to stdout. This output can be redirected to a file or piped to another command for further processing.

Processing Results

Since this command outputs only filenames, you can easily pipe the results to other tools:

# Create a list for manual review
m3-download find-above-iou-threshold annotations/ 0.5 > overlapping_files.txt

# Copy identified files to a separate directory
m3-download find-above-iou-threshold annotations/ 0.5 | xargs -I{} cp {} review_dir/

Examples

Find annotations with any overlapping boxes above 0.5 IoU:

m3-download find-above-iou-threshold annotations/ 0.5

Find only same-class overlapping boxes above 0.7 IoU:

m3-download find-above-iou-threshold annotations/ 0.7 --label-match

Save list of files with overlapping boxes to review later:

m3-download find-above-iou-threshold annotations/ 0.5 > overlapping_files.txt