roboflow/supervision · error · ValueError

No edges defined for class_id={class_id}.

Error message

No edges defined for class_id={class_id}.

What it means

When an image has both predictions and targets, Precision needs prediction confidence to rank predictions along the PR curve. If predictions.confidence is None at this point, compute() raises. class_id on both sides is validated just before, so this error specifically means the confidence attribute is missing.

Source

Thrown at src/supervision/key_points/annotators.py:239

            ```
        """
        if len(key_points) == 0:
            return scene

        for detection_index, xy in enumerate(key_points.xy):
            if isinstance(self.edges, dict):
                class_id = (
                    int(key_points.class_id[detection_index])
                    if key_points.class_id is not None
                    else None
                )
                if class_id is None:
                    raise ValueError(
                        "edges is a dict but class_id is None; "
                        "KeyPoints must have class_id set."
                    )
                if class_id not in self.edges:
                    raise ValueError(f"No edges defined for class_id={class_id}.")
                edges = self.edges[class_id]
            elif self.edges:
                edges = self.edges
            else:
                _looked_up = SKELETONS_BY_VERTEX_COUNT.get(len(xy))
                if not _looked_up:
                    logger.warning("No skeleton found with %d vertices", len(xy))
                    continue
                edges = _looked_up

            for edge in edges:
                idx_a, idx_b = _validate_edge_indices(edge=edge, vertex_count=len(xy))
                xy_a = xy[idx_a]
                xy_b = xy[idx_b]
                if np.allclose(xy_a, 0) or np.allclose(xy_b, 0):
                    continue
                if key_points.visible is not None:
                    if (

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Attach confidence: sv.Detections(..., confidence=np.array([...], dtype=np.float32))
  2. If no real scores exist, use np.ones(N) (constant) while noting PR ordering becomes meaningless
  3. Regenerate predictions with a model connector (from_ultralytics etc.) that populates confidence

Example fix

# before
preds = sv.Detections(
    xyxy=np.array([[30.0, 30.0, 100.0, 100.0]]),
    class_id=np.array([0]),
)  # no confidence
precision.update(predictions=[preds], targets=[targets])
precision.compute()  # -> ValueError

# after
preds = sv.Detections(
    xyxy=np.array([[30.0, 30.0, 100.0, 100.0]]),
    class_id=np.array([0]),
    confidence=np.array([0.9], dtype=np.float32),
)
Defensive patterns

Strategy: validation

Validate before calling

for d in predictions_list:
    assert d.confidence is not None, 'predictions must carry confidence'

Type guard

def has_confidence(detections: sv.Detections) -> bool:
    """True when Detections carry per-box confidence scores."""
    return detections.confidence is not None

Prevention

When it happens

Trigger: prediction Detections built without confidence (manual construction, GT-format arrays reused as predictions, connectors that do not emit scores) combined with non-empty targets, then compute().

Common situations: Hand-rolled Detections in unit tests; evaluating tracker outputs that were stripped of confidence; parsing prediction files that omit the score column.

Related errors


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/0c92e673aca5d5b5. Report an issue: GitHub.