{"record":{"id":"885c349246c5282c","repo":"tensorflow/models","slug":"missing-the-required-key-in-predictions","errorCode":null,"errorMessage":"Missing the required key `{}` in predictions!","messagePattern":"Missing the required key `(.+?)` in predictions!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/evaluation/coco_evaluator.py","lineNumber":471,"sourceCode":"          - num_detections: a numpy array of int of shape [batch_size].\n          - boxes: a numpy array of float of shape [batch_size, K, 4].\n          - classes: a numpy array of int of shape [batch_size, K].\n        Optional fields:\n          - is_crowds: a numpy array of int of shape [batch_size, K]. If the\n            field is absent, it is assumed that this instance is not crowd.\n          - areas: a numy array of float of shape [batch_size, K]. If the field\n            is absent, the area is calculated using either boxes or masks\n            depending on which one is available.\n          - masks: a numpy array of float of shape [batch_size, K, mask_height,\n            mask_width],\n\n    Raises:\n      ValueError: if the required prediction or groundtruth fields are not\n        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]","sourceCodeStart":453,"sourceCodeEnd":489,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/evaluation/coco_evaluator.py#L453-L489","documentation":"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.","triggerScenarios":"Thrown at official/legacy/detection/evaluation/coco_evaluator.py:471 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"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"}