tensorflow/models · error · ValueError
Results do not correspond to the current dataset!
Error message
Results do not correspond to the current dataset!
What it means
Consistency guard in the COCO loadRes path: the prediction results contain image ids that are not present in the ground-truth dataset's image set, so the predictions cannot correspond to the loaded annotations. It fires when predictions come from a different dataset/ split than the annotation file or gt_dataset used for evaluation.
Solutions
- Regenerate predictions on the same dataset/ split as the ground-truth annotations
- Verify image id mapping and that no predictions reference excluded images
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at official/legacy/detection/evaluation/coco_utils.py:93 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/4275819049633bfa.
Report an issue: GitHub.
Appendix: source
Thrown at official/legacy/detection/evaluation/coco_utils.py:93
Args:
predictions: a list of dictionary each representing an annotation in COCO
format. The required fields are `image_id`, `category_id`, `score`,
`bbox`, `segmentation`.
Returns:
res: result COCO api object.
Raises:
ValueError: if the set of image id from predctions is not the subset of
the set of image id of the groundtruth dataset.
"""
res = coco.COCO()
res.dataset['images'] = copy.deepcopy(self.dataset['images'])
res.dataset['categories'] = copy.deepcopy(self.dataset['categories'])
image_ids = [ann['image_id'] for ann in predictions]
if set(image_ids) != (set(image_ids) & set(self.getImgIds())):
raise ValueError('Results do not correspond to the current dataset!')
for ann in predictions:
x1, x2, y1, y2 = [ann['bbox'][0], ann['bbox'][0] + ann['bbox'][2],
ann['bbox'][1], ann['bbox'][1] + ann['bbox'][3]]
if self._eval_type == 'box':
ann['area'] = ann['bbox'][2] * ann['bbox'][3]
ann['segmentation'] = [
[x1, y1, x1, y2, x2, y2, x2, y1]]
elif self._eval_type == 'mask':
ann['area'] = mask_api.area(ann['segmentation'])
res.dataset['annotations'] = copy.deepcopy(predictions)
res.createIndex()
return res
def convert_predictions_to_coco_annotations(predictions):
"""Converts a batch of predictions to annotations in COCO format.
View on GitHub (pinned to e006f5f0d5)