{"record":{"id":"12214528b7569564","repo":"open-mmlab/mmdetection","slug":"dataset-meta-or-class-names-are-not-saved-in-the-c","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/det_inferencer.py","lineNumber":130,"sourceCode":"            cfg (Config or ConfigDict, optional): The loaded config.\n        \"\"\"\n\n        if checkpoint is not None:\n            _load_checkpoint_to_model(model, checkpoint)\n            checkpoint_meta = checkpoint.get('meta', {})\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.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        else:\n            warnings.warn('Checkpoint is not loaded, and the inference '\n                          'result is calculated by the randomly initialized '\n                          'model!')\n            warnings.warn('weights is None, use COCO classes by default.')\n            model.dataset_meta = {'classes': get_classes('coco')}\n\n        # Priority:  args.palette -> config -> checkpoint\n        if self.palette != 'none':\n            model.dataset_meta['palette'] = self.palette\n        else:\n            test_dataset_cfg = copy.deepcopy(cfg.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","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/apis/det_inferencer.py#L112-L148","documentation":"Warning emitted by DetInferencer._load_weights_to_model when the loaded checkpoint's meta contains neither 'dataset_meta' nor legacy 'CLASSES', so COCO class names are assumed for labeling predictions.","triggerScenarios":"Running DetInferencer with a weights checkpoint whose meta dict lacks class info — typically checkpoints converted from other frameworks or from pre-3.x mmdet without meta fields.","commonSituations":"Using converted/foreign weights (e.g. torchvision or original-author released checkpoints) with DetInferencer; results still work but class labels may be wrong for non-COCO models.","solutions":["Pass classes explicitly: DetInferencer(model, weights, classes=[...]) or set dataset_meta in the config","Use a checkpoint saved by mmdet >= 3.0 training (it embeds dataset_meta)","If the model really is COCO, ignore the warning"],"exampleFix":"// before\ninferencer = DetInferencer(model=cfg, weights='converted.pth')\n// after\ninferencer = DetInferencer(model=cfg, weights='converted.pth', classes=['a','b','c'])","handlingStrategy":"validation","validationCode":"import torch\nckpt = torch.load('weights.pth', map_location='cpu')\nmeta = ckpt.get('meta', {})\nif 'dataset_meta' not in meta and 'CLASSES' not in meta:\n    print('checkpoint lacks class names; pass classes explicitly')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect checkpoint meta before inferring","Pass classes explicitly for converted weights"],"tags":["python","warning","checkpoint","class-names","inferencer"],"backgroundTag":"missing-metadata-in-checkpoint","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}