open-mmlab/mmdetection · warning
{metric.__class__.__name__} got empty `self.results`.Please
Error message
{metric.__class__.__name__} got empty `self.results`.Please ensure that the processed results are properly added into `self.results` in `process` method. What it means
Warning from MultiDatasetsEvaluator.evaluate: one of the per-dataset metrics has an empty self.results list at evaluate time, meaning process() never added results for that dataset — its metrics will be meaningless/zero.
Source
Thrown at mmdet/evaluation/evaluator/multi_datasets_evaluator.py:73
size (int): Length of the entire validation dataset. When batch
size > 1, the dataloader may pad some data samples to make
sure all ranks have the same length of dataset slice. The
``collect_results`` function will drop the padded data based on
this size.
Returns:
dict: Evaluation results of all metrics. The keys are the names
of the metrics, and the values are corresponding results.
"""
metrics_results = OrderedDict()
dataset_slices = self._get_cumulative_sizes()
assert len(dataset_slices) == len(self.dataset_prefixes)
for dataset_prefix, start, end, metric in zip(
self.dataset_prefixes, [0] + dataset_slices[:-1],
dataset_slices, self.metrics):
if len(metric.results) == 0:
warnings.warn(
f'{metric.__class__.__name__} got empty `self.results`.'
'Please ensure that the processed results are properly '
'added into `self.results` in `process` method.')
results = collect_results(metric.results, size,
metric.collect_device)
if is_main_process():
# cast all tensors in results list to cpu
results = _to_cpu(results)
_metrics = metric.compute_metrics(
results[start:end]) # type: ignore
if metric.prefix:
final_prefix = '/'.join((dataset_prefix, metric.prefix))
else:
final_prefix = dataset_prefix
print(f'================{final_prefix}================')View on GitHub (pinned to cfd5d3a985)
Solutions
- Check that every dataset in the multi-evaluator has data flowing through process() (dataloader not empty for that subset)
- Verify metric class implements process() appending to self.results for your datasample type
- Ensure dataset_prefixes/metrics lists in the evaluator config align with the dataloader datasets
- Log len(metric.results) per prefix before evaluate to pinpoint the empty one
Example fix
# before val_evaluator = dict(type='MultiDatasetsEvaluator', metrics=[dict(type='CocoMetric')], dataset_prefixes=['coco','voc']) # after: ensure each subset yields data, e.g. fix empty voc split / batch remainder handling
Defensive patterns
Strategy: validation
Validate before calling
for prefix, metric in zip(evaluator.dataset_prefixes, evaluator.metrics):
if len(metric.results) == 0:
print(f'warning: no results collected for {prefix}/{type(metric).__name__}') Prevention
- Sanity-check that each dataset subset yields batches
- Verify metric.process() handles your datasample type
- Align dataset_prefixes with the multi-dataset dataloader config
When it happens
Trigger: Using MultiDatasetsEvaluator where a metric bound to a dataset_prefix received no process() calls (e.g. batch size not divisible causing dropped samples, a metric whose process filters everything, or a mis-matched evaluator/dataset wiring).
Common situations: Evaluating on multiple concatenated datasets (e.g. COCO+VOC) with metrics that skip results; leads to empty mAP or divide-by-zero downstream.
Related errors
- dataset_meta or class names are not saved in the checkpoint'
- Checkpoint is not loaded, and the inference result is calcul
- weights is None, use COCO classes by default.
- palette does not exist, random is used by default. You can a
- Currently does not support saving datasample when return_dat
AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27).
Data as JSON: /api/errors/1dc540387ae973ca.
Report an issue: GitHub.