{"record":{"id":"3b94af306eab8c85","repo":"tensorflow/models","slug":"can-t-evaluate-using-annotation-file-when-tfds-is-3b94af","errorCode":null,"errorMessage":"Can't evaluate using annotation file when TFDS is used.","messagePattern":"Can't evaluate using annotation file when TFDS is used\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/tasks/retinanet.py","lineNumber":281,"sourceCode":"      total_loss = model_loss + reg_loss\n\n    total_loss = params.losses.loss_weight * total_loss\n\n    return total_loss, cls_loss, box_loss, model_loss\n\n  def build_metrics(self, training: bool = True):\n    \"\"\"Build detection metrics.\"\"\"\n    metrics = []\n    metric_names = ['total_loss', 'cls_loss', 'box_loss', 'model_loss']\n    for name in metric_names:\n      metrics.append(tf_keras.metrics.Mean(name, dtype=tf.float32))\n\n    if not training:\n      if (\n          self.task_config.validation_data.tfds_name\n          and self.task_config.annotation_file\n      ):\n        raise ValueError(\n            \"Can't evaluate using annotation file when TFDS is used.\"\n        )\n      if self._task_config.use_coco_metrics:\n        self.coco_metric = coco_evaluator.COCOEvaluator(\n            annotation_file=self.task_config.annotation_file,\n            include_mask=False,\n            per_category_metrics=self.task_config.per_category_metrics,\n            max_num_eval_detections=self.task_config.max_num_eval_detections,\n        )\n      if self._task_config.use_wod_metrics:\n        # To use Waymo open dataset metrics, please install one of the pip\n        # package `waymo-open-dataset-tf-*` from\n        # https://github.com/waymo-research/waymo-open-dataset/blob/master/docs/quick_start.md#use-pre-compiled-pippip3-packages-for-linux\n        # Note that the package is built with specific tensorflow version and\n        # will produce error if it does not match the tf version that is\n        # currently used.\n        try:\n          from official.vision.evaluation import wod_detection_evaluator  # pylint: disable=g-import-not-at-top","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/tasks/retinanet.py#L263-L299","documentation":"Error \"Can't evaluate using annotation file when TFDS is used.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/tasks/retinanet.py:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Disable the annotation-file-based COCO evaluator when training from TFDS.","Use a file-based input (tfrecord) if you need evaluation against an annotation file."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}