tensorflow/models · error · ValueError

If masks are included you cannot convert coco from the91…

Error message

If masks are included you cannot convert coco from the91 class format to the 80 class format.

What it means

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.

Solutions

  1. Set coco91_to_80=False and keep the 91-class format when masks are needed
  2. Set include_mask=False if the 80-class conversion is required
  3. Pre-convert the dataset offline so the decoder does not need both options simultaneously
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/yolo/dataloaders/tf_example_decoder.py:79 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/f21ba34ef69093ed. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/yolo/dataloaders/tf_example_decoder.py:79

  def __init__(self,
               coco91_to_80=None,
               include_mask=False,
               regenerate_source_id=False,
               mask_binarize_threshold=None):
    """Initialize the example decoder.

    Args:
      coco91_to_80: `bool` indicating whether to convert coco from its 91 class
        format to the 80 class format.
      include_mask: `bool` indicating if the decoder should also decode instance
        masks for instance segmentation.
      regenerate_source_id: `bool` indicating if the source id needs to be
        recreated for each image sample.
      mask_binarize_threshold: `float` for binarizing mask values.
    """
    if coco91_to_80 and include_mask:
      raise ValueError('If masks are included you cannot convert coco from the'
                       '91 class format to the 80 class format.')

    self._coco91_to_80 = coco91_to_80
    super().__init__(
        include_mask=include_mask,
        regenerate_source_id=regenerate_source_id,
        mask_binarize_threshold=mask_binarize_threshold)

  def decode(self, serialized_example):
    """Decode the serialized example.

    Args:
      serialized_example: a single serialized tf.Example string.

    Returns:
      decoded_tensors: a dictionary of tensors with the following fields:
        - source_id: a string scalar tensor.
        - image: a uint8 tensor of shape [None, None, 3].

View on GitHub (pinned to e006f5f0d5)