roboflow/supervision · error · ValueError
Targets must contain class_id values.
Error message
Targets must contain class_id values.
What it means
Error "Targets must contain class_id values." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/detection.py:260
Args:
predictions: Predicted detections for a single image.
targets: Ground-truth detections for a single image.
conf_threshold: Confidence threshold; predictions below this are excluded.
iou_threshold: IoU threshold; candidate pairs below this are not matched.
metric_target: Coordinate representation to use for IoU computation.
Use ``MetricTarget.ORIENTED_BOUNDING_BOXES`` for rotated-box datasets.
Returns:
A 3-tuple ``(true_positives, false_positives, false_negatives)`` where
each element is a ``Detections`` instance sliced from the input arrays.
"""
if predictions.class_id is None:
raise ValueError("Predictions must contain class_id values.")
if targets.class_id is None:
raise ValueError("Targets must contain class_id values.")
target_class_ids = targets.class_id
if predictions.confidence is None:
filtered_predictions = predictions
else:
prediction_confidence = np.asarray(predictions.confidence, dtype=np.float32)
filtered_predictions = predictions.select(
prediction_confidence >= conf_threshold
)
filtered_prediction_class_ids = filtered_predictions.class_id
if filtered_prediction_class_ids is None:
raise ValueError("Predictions must contain class_id values.")
prediction_count = len(filtered_predictions)
target_count = len(targets)
View on GitHub (pinned to 7f254d9784)
Solutions
- Ensure target arrays/Detections include class_id values.
- Append the class id column to your target arrays before evaluation.
When it happens
Trigger: Thrown at src/supervision/metrics/detection.py:260 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/21946a569a9410eb.
Report an issue: GitHub.