{"record":{"id":"e99cf761adeafeb2","repo":"open-mmlab/mmdetection","slug":"dataset-meta-or-class-names-are-not-saved-in-the-c-e99cf7","errorCode":null,"errorMessage":"dataset_meta or class names are not saved in the checkpoint's meta data, use COCO classes by default.","messagePattern":"dataset_meta or class names are not saved in the checkpoint's meta data, use COCO classes by default\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"mmdet/apis/inference.py","lineNumber":90,"sourceCode":"    else:\n        checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')\n        # Weights converted from elsewhere may not have meta fields.\n        checkpoint_meta = checkpoint.get('meta', {})\n\n        # save the dataset_meta in the model for convenience\n        if 'dataset_meta' in checkpoint_meta:\n            # mmdet 3.x, all keys should be lowercase\n            model.dataset_meta = {\n                k.lower(): v\n                for k, v in checkpoint_meta['dataset_meta'].items()\n            }\n        elif 'CLASSES' in checkpoint_meta:\n            # < mmdet 3.x\n            classes = checkpoint_meta['CLASSES']\n            model.dataset_meta = {'classes': classes}\n        else:\n            warnings.simplefilter('once')\n            warnings.warn(\n                'dataset_meta or class names are not saved in the '\n                'checkpoint\\'s meta data, use COCO classes by default.')\n            model.dataset_meta = {'classes': get_classes('coco')}\n\n    # Priority:  args.palette -> config -> checkpoint\n    if palette != 'none':\n        model.dataset_meta['palette'] = palette\n    else:\n        test_dataset_cfg = copy.deepcopy(config.test_dataloader.dataset)\n        # lazy init. We only need the metainfo.\n        test_dataset_cfg['lazy_init'] = True\n        metainfo = DATASETS.build(test_dataset_cfg).metainfo\n        cfg_palette = metainfo.get('palette', None)\n        if cfg_palette is not None:\n            model.dataset_meta['palette'] = cfg_palette\n        else:\n            if 'palette' not in model.dataset_meta:\n                warnings.warn(","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/apis/inference.py#L72-L108","documentation":"Warning from init_detector: the checkpoint loaded successfully but its meta dict has neither 'dataset_meta' nor legacy 'CLASSES', so COCO classes are the default labels.","triggerScenarios":"init_detector(cfg, 'weights.pth') where weights.pth was converted from another framework or stripped of meta.","commonSituations":"Using mmengine-converted or third-party weights; predictions are fine but class names/ids may mismatch for non-COCO-trained models.","solutions":["Prefer checkpoints from official mmdet training","Set classes via config: model.test_cfg / dataset metainfo, or manually assign model.dataset_meta after init","Patch the checkpoint meta: ckpt['meta']['dataset_meta'] = {'classes': [...]} then re-save"],"exampleFix":"// before\nmodel = init_detector(cfg, 'converted.pth')\n// after\nmodel = init_detector(cfg, 'converted.pth')\nmodel.dataset_meta = {'classes': my_class_list}","handlingStrategy":"validation","validationCode":"import torch\nmeta = torch.load(ckpt, map_location='cpu').get('meta', {})\nassert 'dataset_meta' in meta or 'CLASSES' in meta or explicit_classes, 'labels will default to COCO'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check checkpoint meta before relying on predicted labels","Set model.dataset_meta manually for converted weights"],"tags":["python","warning","checkpoint","class-names","init-detector"],"backgroundTag":"missing-metadata-in-checkpoint","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}