Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Understand how a detector represents, scores and filters object predictions

1. Motivation

Every detection architecture in the next page, whether Faster R-CNN, YOLO, or DETR, is built around these same five ideas. Once you understand them here, comparing architectures and reading geoai output (training curves, evaluation tables, visualized detections) becomes far easier, because you will recognize what each number and each colored box actually represents.


2. Core idea

A detection model does not output a single answer. For one input image, it outputs a set of predictions, each one a bounding box (a rectangle marking where an object is), a class label, and a confidence score (how sure the model is). Two supporting mechanisms, IoU and non-maximum suppression, decide which of the model’s raw, often overlapping, box proposals actually survive into the final output. Anchor boxes are a design choice some architectures use to make that raw prediction problem easier to learn in the first place.


3. Building blocks

A. Bounding boxes

A bounding box is defined by four numbers. The two common conventions are:

Both describe the same rectangle. Different annotation formats and libraries use different conventions, so always check the expected representation. In a geospatial workflow, these coordinates start out in pixel space, and are only meaningful for GIS work once converted to geographic coordinates using the image’s affine transform, the same transform you already used in L03 and L04 to relate pixel positions to real-world locations.

B. Confidence scores & thresholds

Each box also carries a Confidence Score, a value between 0 and 1. A higher score means that the model assigns greater confidence to that prediction. It does not guarantee that the detection is correct.

During inference, you normally choose a confidence threshold to filter out low-quality predictions: a high threshold keeps only the model’s most certain detections (fewer false positives, but you may miss some real objects), while a low threshold keeps more detections (higher recall, but more clutter). You will tune this threshold directly when running inference in a later page.

For example:

threshold = 0.80 → keep only high-confidence predictions
threshold = 0.50 → keep more predictions
threshold = 0.30 → keep many uncertain predictions

The choice creates a trade-off:

ThresholdLikely effect
HigherFewer predictions, usually fewer false positives, potentially more missed objects
LowerMore predictions, potentially higher recall, but usually more false positives

There is no universally correct threshold. The appropriate value depends on the cost of different errors in your project.

C. Intersection over Union (IoU)

How can we measure whether two boxes describe approximately the same location? Intersection over Union (IoU) compares their overlap: the area where they intersect, divided by the area they cover together (their union). An IoU of 1.0 means the boxes align perfectly; an IoU of 0 means they do not overlap at all.

IoU has two jobs in this lesson: during training, it helps the model decide which raw predictions correspond to which ground-truth objects, and during evaluation (the mAP page), it helps removing duplicate predictions. Keep their roles separate when documenting your workflow.

D. Non-maximum suppression (NMS)

Detection models often produce several overlapping boxes for the same physical object, especially in dense scenes like a parking lot or a shipping harbor. Non-Maximum Suppression (NMS) removes this redundancy: for each class, it keeps the highest-confidence box and removes any other box that overlaps it beyond an IoU threshold, typically applied per class so a car and an overlapping tree box are not accidentally merged.

The result should contain fewer redundant boxes.

before NMS                         after NMS

┌──────────┐                      ┌───────────┐
│ ┌──────────┐                    │           │
│ │ object │ │  two boxes   →     │  object   │  one box
└─│────────┘ │                    │           │
  └──────────┘                    └───────────┘

E. Anchor boxes

Many detectors use Anchor Boxes templates as starting points for predicting object locations. Instead of learning every box from scratch, the model begins with boxes of different sizes, aspect ratios, and positions. It then predicts adjustments to these templates. This is useful because objects in imagery occur at different shapes and scales.

But not all modern detectors use anchors. Anchor-free approaches such as FCOS and transformer-based approaches such as DETR use different strategies. You therefore need to understand anchor boxes conceptually, but you will not manually configure them in the main practical workflow.

4. Common pitfalls


5. Mini task

Using the iou() function above, compute the IoU for predicted_box = (0, 0, 100, 100) and ground_truth_box = (50, 0, 150, 100) (two boxes of equal size, overlapping by half their width). Before running it, predict whether the IoU will be above or below 0.5.

Sample solution

The two boxes overlap in a 50 by 100 region (area 5,000), while their union covers 15,000 square units, giving an IoU of about 0.33. This is a useful benchmark to remember: two same-sized boxes overlapping by half their width already fall below the common 0.5 IoU threshold used in evaluation, which shows how strict that threshold really is.


6. Key takeaways


7. Further reading