Choosing a confidence threshold

With fotonet, the confidence threshold is the only setting between the model and your results. It is worth picking on purpose.

5 min read

What the number means

Each box fotonet returns has a confidence from 0 to 1. In fotonet, confidence follows how well the box fits as well as what is inside it, so a high score means a tight, correct box.

The trade-off

  • Raise it when a false alarm is expensive: an alert, a robot arm moving, a count that must not be inflated.
  • Lower it when missing something is worse: search, safety review, or when a human checks every result anyway.

Only one threshold

Detectors with NMS have a second setting, the IoU threshold, and the two interact. fotonet has no NMS, so you tune one number. Why there is no NMS.

model.predict("image.jpg", conf=0.25)   # the default
model.predict("image.jpg", conf=0.5)    # fewer, surer boxes

How to tune it

  1. Run validation on your own labeled images: fotonet val model=your_model.pt data=data.yaml.
  2. Try a few thresholds on the same images and look at precision and recall for each.
  3. Pick the threshold that fits the cost of a miss against the cost of a false alarm in your project. If both cost the same, pick the one with the best F1 score, the balance of the two.

Accuracy numbers such as mAP do not change with the threshold: they are measured across all of them. See mAP explained.