open-mmlab/mmdetection · warning
checkpoint is None, use COCO classes by default.
Error message
checkpoint is None, use COCO classes by default.
What it means
Warning from init_detector: checkpoint is None so no weights are loaded (random init) and COCO class names are used for dataset_meta.
Source
Thrown at mmdet/apis/inference.py:70
if isinstance(config, (str, Path)):
config = Config.fromfile(config)
elif not isinstance(config, Config):
raise TypeError('config must be a filename or Config object, '
f'but got {type(config)}')
if cfg_options is not None:
config.merge_from_dict(cfg_options)
elif 'init_cfg' in config.model.backbone:
config.model.backbone.init_cfg = None
scope = config.get('default_scope', 'mmdet')
if scope is not None:
init_default_scope(config.get('default_scope', 'mmdet'))
model = MODELS.build(config.model)
model = revert_sync_batchnorm(model)
if checkpoint is None:
warnings.simplefilter('once')
warnings.warn('checkpoint is None, use COCO classes by default.')
model.dataset_meta = {'classes': get_classes('coco')}
else:
checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')
# Weights converted from elsewhere may not have meta fields.
checkpoint_meta = checkpoint.get('meta', {})
# save the dataset_meta in the model for convenience
if 'dataset_meta' in checkpoint_meta:
# mmdet 3.x, all keys should be lowercase
model.dataset_meta = {
k.lower(): v
for k, v in checkpoint_meta['dataset_meta'].items()
}
elif 'CLASSES' in checkpoint_meta:
# < mmdet 3.x
classes = checkpoint_meta['CLASSES']
model.dataset_meta = {'classes': classes}
else:View on GitHub (pinned to cfd5d3a985)
Solutions
- Pass a checkpoint path or URL: init_detector(cfg, 'faster_rcnn.pth')
- If intentional (structure testing), ignore — inference results will be garbage
Example fix
// before model = init_detector(cfg, None) // after model = init_detector(cfg, 'checkpoints/faster_rcnn_r50.pth')
Defensive patterns
Strategy: validation
Validate before calling
assert checkpoint is not None, 'init_detector without checkpoint yields random weights'
Prevention
- Always supply checkpoint path/URL for real inference
When it happens
Trigger: Calling mmdet.apis.init_detector(config, checkpoint=None) (or omitting checkpoint).
Common situations: Building a model for config debugging / latency benchmarking and forgetting weights; also passing an empty-string checkpoint path.
Related errors
- Checkpoint is not loaded, and the inference result is calcul
- dataset_meta or class names are not saved in the checkpoint'
- dataset_meta or class names are not saved in the checkpoint'
- palette does not exist, random is used by default. You can a
- weights is None, use COCO classes by default.
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/77170a7210c7306e.
Report an issue: GitHub.