facebookresearch/detectron2 · error · ValueError
No built-in metadata for dataset {}
Error message
No built-in metadata for dataset {} What it means
get_lvis_instances_meta resolves metadata by substring matching on the dataset name: names containing 'cocofied' get COCO metadata, 'v0.5' and 'v1' get LVIS versions. Any other LVIS-like name raises ValueError because no builtin metadata matches.
Source
Thrown at detectron2/data/datasets/lvis.py:184
def get_lvis_instances_meta(dataset_name):
"""
Load LVIS metadata.
Args:
dataset_name (str): LVIS dataset name without the split name (e.g., "lvis_v0.5").
Returns:
dict: LVIS metadata with keys: thing_classes
"""
if "cocofied" in dataset_name:
return _get_coco_instances_meta()
if "v0.5" in dataset_name:
return _get_lvis_instances_meta_v0_5()
elif "v1" in dataset_name:
return _get_lvis_instances_meta_v1()
raise ValueError("No built-in metadata for dataset {}".format(dataset_name))
def _get_lvis_instances_meta_v0_5():
assert len(LVIS_V0_5_CATEGORIES) == 1230
cat_ids = [k["id"] for k in LVIS_V0_5_CATEGORIES]
assert min(cat_ids) == 1 and max(cat_ids) == len(
cat_ids
), "Category ids are not in [1, #categories], as expected"
# Ensure that the category list is sorted by id
lvis_categories = sorted(LVIS_V0_5_CATEGORIES, key=lambda x: x["id"])
thing_classes = [k["synonyms"][0] for k in lvis_categories]
meta = {"thing_classes": thing_classes}
return meta
def _get_lvis_instances_meta_v1():
assert len(LVIS_V1_CATEGORIES) == 1203
cat_ids = [k["id"] for k in LVIS_V1_CATEGORIES]View on GitHub (pinned to a2f4a8771a)
Solutions
- Include a recognized substring in the name ('v0.5' or 'v1'), or better, register metadata explicitly
- For custom LVIS-format data call register_lvis_instances and set MetadataCatalog with your thing_classes/dataset_names
- Upgrade detectron2 if you need a newer LVIS split
Example fix
# before
meta = get_lvis_instances_meta('lvis_val')
# after
MetadataCatalog.set('lvis_val', thing_classes=my_classes, dataset_name='lvis-val')
meta = MetadataCatalog.get('lvis_val') Defensive patterns
Strategy: validation
Validate before calling
from detectron2.data import MetadataCatalog
if not MetadataCatalog.contains(dataset_name):
raise ValueError(f'register metadata for {dataset_name} before use') Type guard
def lvis_meta_available(name: str) -> bool:
return any(s in name for s in ('cocofied', 'v0.5', 'v1')) Try / catch
try:
meta = get_lvis_instances_meta(name)
except ValueError:
MetadataCatalog.set(name, thing_classes=my_classes, dataset_name='lvis-val')
meta = MetadataCatalog.get(name) Prevention
- For custom LVIS data always use register_lvis_instances plus explicit MetadataCatalog.set
- Name splits to include the version substring when reusing builtins
- Pin detectron2 version matching your LVIS release
When it happens
Trigger: Calling get_lvis_instances_meta('lvis_val') (no version substring) or a renamed LVIS dataset like 'lvis_v2_val'; also any call chain through register_all_lvis or load_lvis_json with an unrecognized name.
Common situations: Registering a custom LVIS variant with register_lvis_instances without setting MetadataCatalog yourself; dataset-name typos; newer LVIS versions unsupported by the installed detectron2.
Related errors
- No built-in metadata for dataset {}
- Attribute '{}' does not exist in the metadata of dataset '{}
- Attribute '{key}' does not exist in the metadata of dataset
- Cannot match one checkpoint key to multiple keys in the mode
- Class with @configurable must have a 'from_config' classmeth
AI-assisted analysis of facebookresearch/detectron2@a2f4a8771a (2026-08-27).
Data as JSON: /api/errors/44483ab81957e535.
Report an issue: GitHub.