open-mmlab/mmdetection · error · ValueError

Unrecognized dataset: {dataset}

Error message

Unrecognized dataset: {dataset}

What it means

get_classes resolves dataset names (including aliases like 'voc', 'coco') to their class-name lists; an unknown string that is not in alias2name raises ValueError 'Unrecognized dataset'.

Source

Thrown at mmdet/evaluation/functional/class_names.py:759

    'oid_v6': ['oid_v6', 'openimages_v6'],
    'objects365v1': ['objects365v1', 'obj365v1'],
    'objects365v2': ['objects365v2', 'obj365v2'],
    'lvis': ['lvis', 'lvis_v1'],
}


def get_classes(dataset) -> list:
    """Get class names of a dataset."""
    alias2name = {}
    for name, aliases in dataset_aliases.items():
        for alias in aliases:
            alias2name[alias] = name

    if is_str(dataset):
        if dataset in alias2name:
            labels = eval(alias2name[dataset] + '_classes()')
        else:
            raise ValueError(f'Unrecognized dataset: {dataset}')
    else:
        raise TypeError(f'dataset must a str, but got {type(dataset)}')
    return labels

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Check mmdet/evaluation/functional/class_names.py for supported names/aliases and use one of them
  2. For custom datasets, pass the explicit list of class names instead of a string
  3. Fix typos such as 'COCO' vs 'coco' (aliases are case-sensitive)
  4. Upgrade/downgrade mmdet if the config targets a different version's dataset registry

Example fix

# before
labels = get_classes('coco2017')
# after
labels = get_classes('coco')
# or for custom data
labels = ['person', 'car', 'dog']
Defensive patterns

Strategy: validation

Validate before calling

from mmdet.evaluation.functional.class_names import get_classes
try:
    labels = get_classes(dataset_name)
except ValueError:
    labels = list(custom_classes)  # explicit fallback

Type guard

def is_known_dataset(name) -> bool:
    from mmdet.evaluation.functional import class_names as cn
    import inspect
    return name in cn.dataset_aliases or name in dir(cn)

Try / catch

try:
    labels = get_classes(name)
except ValueError as e:
    raise ConfigError(f'Bad dataset name: {name}') from e

Prevention

When it happens

Trigger: Passing a misspelled or unsupported dataset name to get_classes, dataset CLASSES, or metric classes (e.g. get_classes('coco2017'), get_classes('mydata')).

Common situations: Custom dataset configs that pass a random dataset string; typo in config class_names; renamed dataset in newer mmdet versions.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/787c276b905741fd. Report an issue: GitHub.