{"record":{"id":"3c9f13a059442c93","repo":"tensorflow/models","slug":"the-eval-type-can-only-be-either-box-or-mask","errorCode":null,"errorMessage":"The `eval_type` can only be either `box` or `mask`.","messagePattern":"The `eval_type` can only be either `box` or `mask`\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/evaluation/coco_utils.py","lineNumber":64,"sourceCode":"       dictionary.\n  \"\"\"\n\n  def __init__(self, eval_type='box', annotation_file=None, gt_dataset=None):\n    \"\"\"Instantiates a COCO-style API object.\n\n    Args:\n      eval_type: either 'box' or 'mask'.\n      annotation_file: a JSON file that stores annotations of the eval dataset.\n        This is required if `gt_dataset` is not provided.\n      gt_dataset: the groundtruth eval datatset in COCO API format.\n    \"\"\"\n    if ((annotation_file and gt_dataset) or\n        ((not annotation_file) and (not gt_dataset))):\n      raise ValueError('One and only one of `annotation_file` and `gt_dataset` '\n                       'needs to be specified.')\n\n    if eval_type not in ['box', 'mask']:\n      raise ValueError('The `eval_type` can only be either `box` or `mask`.')\n\n    coco.COCO.__init__(self, annotation_file=annotation_file)\n    self._eval_type = eval_type\n    if gt_dataset:\n      self.dataset = gt_dataset\n      self.createIndex()\n\n  def loadRes(self, predictions):\n    \"\"\"Loads result file and return a result api object.\n\n    Args:\n      predictions: a list of dictionary each representing an annotation in COCO\n        format. The required fields are `image_id`, `category_id`, `score`,\n        `bbox`, `segmentation`.\n\n    Returns:\n      res: result COCO api object.\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/evaluation/coco_utils.py#L46-L82","documentation":"Enum guard in the COCO wrapper constructor: eval_type must be exactly 'box' or 'mask', but another value was supplied. Any other string (or typo like 'bbox' or 'Mask') leaves the evaluator unable to decide which COCO evaluation subtype to run.","triggerScenarios":"Thrown at official/legacy/detection/evaluation/coco_utils.py:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass eval_type='box' for bounding-box evaluation","Pass eval_type='mask' for instance-segmentation evaluation"],"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"}