WZMIAOMIAO/deep-learning-for-image-processing · error · Exception
Please run accumulate() first
Error message
Please run accumulate() first
What it means
The COCO-style evaluator's summarize computes per-area/per-maxDets stats from self.eval, which is only populated after accumulate() runs. Calling summarize (or save_info, which calls summarize) before accumulate leaves self.eval None/empty and raises Exception('Please run accumulate() first').
Source
Thrown at pytorch_object_detection/mask_rcnn/validation.py:88
stats, print_list = [0] * 12, [""] * 12
stats[0], print_list[0] = _summarize(1)
stats[1], print_list[1] = _summarize(1, iouThr=.5, maxDets=self.params.maxDets[2])
stats[2], print_list[2] = _summarize(1, iouThr=.75, maxDets=self.params.maxDets[2])
stats[3], print_list[3] = _summarize(1, areaRng='small', maxDets=self.params.maxDets[2])
stats[4], print_list[4] = _summarize(1, areaRng='medium', maxDets=self.params.maxDets[2])
stats[5], print_list[5] = _summarize(1, areaRng='large', maxDets=self.params.maxDets[2])
stats[6], print_list[6] = _summarize(0, maxDets=self.params.maxDets[0])
stats[7], print_list[7] = _summarize(0, maxDets=self.params.maxDets[1])
stats[8], print_list[8] = _summarize(0, maxDets=self.params.maxDets[2])
stats[9], print_list[9] = _summarize(0, areaRng='small', maxDets=self.params.maxDets[2])
stats[10], print_list[10] = _summarize(0, areaRng='medium', maxDets=self.params.maxDets[2])
stats[11], print_list[11] = _summarize(0, areaRng='large', maxDets=self.params.maxDets[2])
print_info = "\n".join(print_list)
if not self.eval:
raise Exception('Please run accumulate() first')
return stats, print_info
def save_info(coco_evaluator,
category_index: dict,
save_name: str = "record_mAP.txt"):
iou_type = coco_evaluator.params.iouType
print(f"IoU metric: {iou_type}")
# calculate COCO info for all classes
coco_stats, print_coco = summarize(coco_evaluator)
# calculate voc info for every classes(IoU=0.5)
classes = [v for v in category_index.values() if v != "N/A"]
voc_map_info_list = []
for i in range(len(classes)):
stats, _ = summarize(coco_evaluator, catId=i)
voc_map_info_list.append(" {:15}: {}".format(classes[i], stats[1]))View on GitHub (pinned to 1ec3fe6f37)
Solutions
- Call evaluator.accumulate() before evaluator.summarize()
- Ensure the full sequence: evaluator.synchronize_results() (or gather) -> accumulate() -> summarize() -> save_info(...)
- Guard calls: only summarize if getattr(evaluator, 'eval', None) is not None
Example fix
// before save_info(coco_evaluator, category_index) // after coco_evaluator.accumulate() save_info(coco_evaluator, category_index)
Defensive patterns
Strategy: validation
Validate before calling
coco_evaluator.synchronize_results() if hasattr(coco_evaluator, 'synchronize_results') else None coco_evaluator.accumulate() assert getattr(coco_evaluator, 'eval', None) is not None, 'accumulate produced no eval' stats = coco_evaluator.summarize()
Type guard
def can_summarize(ev):
return getattr(ev, 'eval', None) is not None Try / catch
try:
save_info(coco_evaluator, category_index)
except Exception as e:
if 'accumulate()' in str(e):
coco_evaluator.accumulate()
save_info(coco_evaluator, category_index)
else:
raise Prevention
- Follow update -> accumulate -> summarize -> save_info order strictly
- Gate summarize on eval being populated
- In DDP, synchronize/gather results before accumulating
When it happens
Trigger: Calling evaluator.summarize() immediately after update() without evaluator.accumulate(); calling save_info(coco_evaluator, ...) before accumulating; distributed runs where one process skipped synchronize/accumulate.
Common situations: Custom validation loops reordered incorrectly; early-exit during epoch validation; forgetting accumulate in multi-GPU evaluation after merging results.
Related errors
- Unknown iou type {}
- not support iou_type: {self.iou_type}
- not support iou_type: {self.iou_type}
- Please run accumulate() first
- Please run accumulate() first
AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30).
Data as JSON: /api/errors/05349bc6a3338ccd.
Report an issue: GitHub.