open-mmlab/mmdetection · error · ValueError
No sample in split "{self.split}".
Error message
No sample in split "{self.split}". What it means
After loading all annotations for the requested split, RefCoco found zero samples, meaning no referring expressions matched the split name. This is raised at the end of load_data_list when the resulting data_list is empty, so dataset construction fails before training.
Source
Thrown at mmdet/datasets/refcoco.py:161
text = texts
else:
raise ValueError(f'Invalid text mode "{self.text_mode}".')
ins = [{
'mask': grounding_anno['segmentation'],
'ignore_flag': 0
}] * len(text)
instances.extend(ins)
sentences.extend(text)
data_info = {
'img_path': join_path(img_prefix, image['file_name']),
'img_id': img_id,
'instances': instances,
'text': sentences
}
data_list.append(data_info)
if len(data_list) == 0:
raise ValueError(f'No sample in split "{self.split}".')
return data_list
View on GitHub (pinned to cfd5d3a985)
Solutions
- Check the *refs*.p pickle with pickle/Python to list the available splits and use one of them (e.g. 'train', 'val', 'testA', 'testB' for RefCoco)
- Make sure ann_file points at the refs pickle matching your dataset class (RefCoco vs RefCocoPlus vs RefCocoReferring have different files)
- Match the split name to the official split used when the pickle was generated; re-download the correct annotations if the pickle is for a different dataset
Example fix
# before dataset = dict(type='RefCoco', ann_file='instances_refs(unc).p', split='test') # no such split in RefCoco # after dataset = dict(type='RefCoco', ann_file='instances_refs(unc).p', split='testA')
Defensive patterns
Strategy: validation
Validate before calling
import pickle
refs = pickle.load(open(ann_file, 'rb'))
splits = {r['split'] for r in refs}
assert split in splits, f'split {split!r} not in available splits: {splits}'
dataset = RefCoco(ann_file=ann_file, split=split, ...) Try / catch
try:
dataset = RefCoco(ann_file=ann_file, split=split, data_prefix=data_prefix)
except ValueError as e:
if 'No sample in split' in str(e):
raise SystemExit(f'split {split!r} empty; available: {available_splits()}') from e
raise Prevention
- Inspect the refs pickle once to enumerate valid splits before wiring configs
- Use the exact split names of the RefCoco variant you configured (testA/testB only exist for detection-style splits)
When it happens
Trigger: Passing a split that does not exist for the chosen RefCoco variant (e.g. split='testA' for RefCocoReferring which only has train/val, or split='val' for a dataset whose pickle only contains train), or a data_prefix/ann_file pointing at the wrong pickle file.
Common situations: Mixing up RefCoco/RefCocoPlus/RefCocoReferring dataset pickles (refs(unc).p vs instances BIN files), using split names from a different variant's config, or downloading a partial annotation set. The split string is also case-sensitive ('train' vs 'Train').
Related errors
- Invalid text mode "{self.text_mode}".
- The annotation file of Open Images Challenge should be a txt
- sampler should be an instance of ``Sampler``, but got {sampl
- batch_size should be a positive integer value, but got batch
- dataset metainfo must contain `classes`
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/c31b15e089053770.
Report an issue: GitHub.