{"record":{"id":"6104297259f29913","repo":"tensorflow/models","slug":"missing-the-required-key-in-groundtruths","errorCode":null,"errorMessage":"Missing the required key `{}` in groundtruths!","messagePattern":"Missing the required key `(.+?)` in groundtruths!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/evaluation/coco_evaluator.py","lineNumber":485,"sourceCode":"        present in the incoming `predictions` or `groundtruths`.\n    \"\"\"\n    for k in self._required_prediction_fields:\n      if k not in predictions:\n        raise ValueError(\n            'Missing the required key `{}` in predictions!'.format(k))\n    if self._need_rescale_bboxes:\n      self._process_predictions(predictions)\n    for k, v in six.iteritems(predictions):\n      if k not in self._predictions:\n        self._predictions[k] = [v]\n      else:\n        self._predictions[k].append(v)\n\n    if not self._annotation_file:\n      assert groundtruths\n      for k in self._required_groundtruth_fields:\n        if k not in groundtruths:\n          raise ValueError(\n              'Missing the required key `{}` in groundtruths!'.format(k))\n      for k, v in six.iteritems(groundtruths):\n        if k not in self._groundtruths:\n          self._groundtruths[k] = [v]\n        else:\n          self._groundtruths[k].append(v)\n\n\nclass OlnXclassEvaluator(COCOEvaluator):\n  \"\"\"COCO evaluation metric class.\"\"\"\n\n  def __init__(self, annotation_file, include_mask, need_rescale_bboxes=True,\n               use_category=True, seen_class='all'):\n    \"\"\"Constructs COCO evaluation class.\n\n    The class provides the interface to metrics_fn in TPUEstimator. The\n    _update_op() takes detections from each image and push them to\n    self.detections. The _evaluate() loads a JSON file in COCO annotation format","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/evaluation/coco_evaluator.py#L467-L503","documentation":"Schema guard in COCOEvaluator.update when evaluating from in-memory ground truths (no annotation_file): a field in _required_groundtruth_fields (name filled into {}) is missing from the groundtruths dict. Required groundtruth keys typically include 'groundtruth_classes' and 'groundtruth_boxes' (plus 'groundtruth_masks' if mask eval is on).","triggerScenarios":"Thrown at official/legacy/detection/evaluation/coco_evaluator.py:485 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the eval input_fn yields dicts containing groundtruth_boxes and groundtruth_classes (and groundtruth_masks when include_mask=True)","Verify field names/ dtypes match the evaluator's required_groundtruth_fields"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}