tensorflow/models · error · ConfigurationError

collapsed_categories.enable is true but 'mapping' is empty…

Error message

collapsed_categories.enable is true but 'mapping' is empty or missing.

What it means

Validation in build_collapsed_categories_config: the YAML set collapsed_categories.enable: true but the mapping entry is absent, empty, or not a dict-like Mapping. Since collapsing is enabled every class needs a target category; with no mapping there is nothing to collapse into, so from_yaml aborts. Typically a user enables the flag but forgets the mapping block, or indents it as a list or scalar instead of a map.

Solutions

  1. Add a 'mapping:' block under collapsed_categories mapping category names to lists of classes
  2. If collapsing is not wanted, set enable: false or remove the collapsed_categories section
  3. Ensure mapping is a YAML mapping (key: [class, ...]), not a list or scalar
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/config_loader.py:274 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/8e82ba7b940c3b9a. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/config_loader.py:274

      - Every class in the mapping must be present in `classes`.

  Args:
    raw_section: The raw `collapsed_categories` dict from YAML, or None if the
      section was omitted entirely.
    classes: The full list of class names from the config.

  Returns:
    A validated CollapsedCategoriesConfig instance.

  Raises:
    ConfigurationError: If validation fails.
  """
  if raw_section is None or not raw_section.get("enable", False):
    return CollapsedCategoriesConfig(enable=False, mapping={})

  raw_mapping = raw_section.get("mapping") or {}
  if not isinstance(raw_mapping, Mapping) or not raw_mapping:
    raise ConfigurationError(
        "collapsed_categories.enable is true but 'mapping' is empty or "
        "missing."
    )

  seen_classes: dict[str, str] = {}
  mapping_dict: dict[str, list[str]] = {}
  class_names = set(classes)
  for category_name, class_list in raw_mapping.items():
    if not isinstance(class_list, Sequence) or isinstance(class_list, str):
      raise ConfigurationError(
          f"Category '{category_name}' must map to a list of class names."
      )
    if not class_list:
      raise ConfigurationError(
          f"Category '{category_name}' must map to a non-empty list of class "
          "names."
      )
    mapping_dict[str(category_name)] = list(class_list)

View on GitHub (pinned to e006f5f0d5)