tensorflow/models · error · ValueError
Missing the required key
Error message
Missing the required key `{}` in predictions! What it means
Schema guard in COCOEvaluator.update: a field listed in _required_prediction_fields (key name filled into {}) is absent from the incoming predictions dict for a batch. Required keys typically include 'num_detections', 'boxes' and 'classes'; their absence means the model post-processing output does not match the evaluator's expected schema.
Solutions
- Make the predict/ post-process function emit the required keys: num_detections, boxes, classes (and detection_masks if configured)
- Match key names and dtypes to the evaluator's expected_prediction_fields
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/legacy/detection/evaluation/coco_evaluator.py:471 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/885c349246c5282c.
Report an issue: GitHub.
Appendix: source
Thrown at official/legacy/detection/evaluation/coco_evaluator.py:471
- num_detections: a numpy array of int of shape [batch_size].
- boxes: a numpy array of float of shape [batch_size, K, 4].
- classes: a numpy array of int of shape [batch_size, K].
Optional fields:
- is_crowds: a numpy array of int of shape [batch_size, K]. If the
field is absent, it is assumed that this instance is not crowd.
- areas: a numy array of float of shape [batch_size, K]. If the field
is absent, the area is calculated using either boxes or masks
depending on which one is available.
- masks: a numpy array of float of shape [batch_size, K, mask_height,
mask_width],
Raises:
ValueError: if the required prediction or groundtruth fields are not
present in the incoming `predictions` or `groundtruths`.
"""
for k in self._required_prediction_fields:
if k not in predictions:
raise ValueError(
'Missing the required key `{}` in predictions!'.format(k))
if self._need_rescale_bboxes:
self._process_predictions(predictions)
for k, v in six.iteritems(predictions):
if k not in self._predictions:
self._predictions[k] = [v]
else:
self._predictions[k].append(v)
if not self._annotation_file:
assert groundtruths
for k in self._required_groundtruth_fields:
if k not in groundtruths:
raise ValueError(
'Missing the required key `{}` in groundtruths!'.format(k))
for k, v in six.iteritems(groundtruths):
if k not in self._groundtruths:
self._groundtruths[k] = [v]View on GitHub (pinned to e006f5f0d5)