{"record":{"id":"f21ba34ef69093ed","repo":"tensorflow/models","slug":"if-masks-are-included-you-cannot-convert-coco-from","errorCode":null,"errorMessage":"If masks are included you cannot convert coco from the91 class format to the 80 class format.","messagePattern":"If masks are included you cannot convert coco from the91 class format to the 80 class format\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/yolo/dataloaders/tf_example_decoder.py","lineNumber":79,"sourceCode":"\n  def __init__(self,\n               coco91_to_80=None,\n               include_mask=False,\n               regenerate_source_id=False,\n               mask_binarize_threshold=None):\n    \"\"\"Initialize the example decoder.\n\n    Args:\n      coco91_to_80: `bool` indicating whether to convert coco from its 91 class\n        format to the 80 class format.\n      include_mask: `bool` indicating if the decoder should also decode instance\n        masks for instance segmentation.\n      regenerate_source_id: `bool` indicating if the source id needs to be\n        recreated for each image sample.\n      mask_binarize_threshold: `float` for binarizing mask values.\n    \"\"\"\n    if coco91_to_80 and include_mask:\n      raise ValueError('If masks are included you cannot convert coco from the'\n                       '91 class format to the 80 class format.')\n\n    self._coco91_to_80 = coco91_to_80\n    super().__init__(\n        include_mask=include_mask,\n        regenerate_source_id=regenerate_source_id,\n        mask_binarize_threshold=mask_binarize_threshold)\n\n  def decode(self, serialized_example):\n    \"\"\"Decode the serialized example.\n\n    Args:\n      serialized_example: a single serialized tf.Example string.\n\n    Returns:\n      decoded_tensors: a dictionary of tensors with the following fields:\n        - source_id: a string scalar tensor.\n        - image: a uint8 tensor of shape [None, None, 3].","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/yolo/dataloaders/tf_example_decoder.py#L61-L97","documentation":"Option-combination guard in TfExampleDecoder.__init__: include_mask=True requests instance-mask decoding while coco91_to_80 requests remapping the 91-class COCO label space down to 80 classes. The decoder has no implementation that both decodes masks and reindexes their class ids, so enabling both is rejected at construction time rather than producing mislabeled masks later.","triggerScenarios":"Thrown at official/projects/yolo/dataloaders/tf_example_decoder.py:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set coco91_to_80=False and keep the 91-class format when masks are needed","Set include_mask=False if the 80-class conversion is required","Pre-convert the dataset offline so the decoder does not need both options simultaneously"],"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"}