tensorflow/models · error · ConfigurationError

Class ' ' in category ' ' is not present in the top-level…

Error message

Class '{class_name}' in category '{category_name}' is not present in the top-level 'classes' list.

What it means

Cross-reference validation in build_collapsed_categories_config: a class listed under a collapsed category does not appear in the top-level 'classes' list of the same YAML. The classifier and detector are configured from that top-level list, so a mapped-but-undeclared class would never be predicted yet occupies a category slot; the loader rejects the inconsistency, naming both class and category.

Solutions

  1. Add the class name to the top-level 'classes' list in the config
  2. Fix typos or naming mismatches between the mapping entries and the classes list
  3. Remove the class from the category mapping if it should not be part of the pipeline
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:295 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/58ca993be950d840. Report an issue: GitHub.

Appendix: source

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

    )

  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)
    for class_name in class_list:
      if class_name not in class_names:
        raise ConfigurationError(
            f"Class '{class_name}' in category '{category_name}' is not "
            "present in the top-level 'classes' list."
        )
      if class_name in seen_classes:
        raise ConfigurationError(
            f"Class '{class_name}' is assigned to both "
            f"'{seen_classes[class_name]}' and '{category_name}'."
        )
      seen_classes[class_name] = category_name

  unmapped_classes = [c for c in classes if c not in seen_classes]
  if unmapped_classes:
    raise ConfigurationError(
        "The following classes are not assigned to any collapsed category: "
        f"{unmapped_classes}"
    )

  return CollapsedCategoriesConfig(enable=True, mapping=mapping_dict)

View on GitHub (pinned to e006f5f0d5)