WZMIAOMIAO/deep-learning-for-image-processing · error · Exception
Please run accumulate() first
Error message
Please run accumulate() first
What it means
COCOEvalWrapper.summarize() raises if self.eval is unset, meaning accumulate() (the underlying COCO eval) was never run. COCO API's summarize needs evalImgs populated by accumulate(); calling summarize directly after evaluate() skips that step.
Source
Thrown at pytorch_object_detection/retinaNet/validation.py:87
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 main(parser_data):
device = torch.device(parser_data.device if torch.cuda.is_available() else "cpu")
print("Using {} device training.".format(device.type))
data_transform = {
"val": transforms.Compose([transforms.ToTensor()])
}
# read class_indict
label_json_path = './pascal_voc_classes.json'
assert os.path.exists(label_json_path), "json file {} dose not exist.".format(label_json_path)
with open(label_json_path, 'r') as f:
class_dict = json.load(f)
View on GitHub (pinned to 1ec3fe6f37)
Solutions
- Call accumulate() (or the full evaluate() method that includes it) before summarize()
- Use the wrapper's evaluate() entry point which chains evaluate->accumulate->summarize
- Guard summarize behind 'if self.eval:' check in caller code
Example fix
// before stats, info = coco_evaluator.summarize() // after coco_evaluator.evaluate() coco_evaluator.accumulate() stats, info = coco_evaluator.summarize()
Defensive patterns
Strategy: try-catch
Validate before calling
assert coco_evaluator.eval is not None, 'call accumulate() before summarize()'
Type guard
def has_accumulated(evaluator) -> bool:
return getattr(evaluator, 'eval', None) is not None Try / catch
try:
stats, info = evaluator.summarize()
except Exception as e:
print(f'Eval pipeline incomplete: {e}; run evaluate/accumulate first') Prevention
- Follow the evaluate -> accumulate -> summarize order
- Use wrapper methods that chain the pipeline
- Add asserts in eval scripts before summarize
When it happens
Trigger: Calling evaluator.summarize() in validation main() without first calling evaluator.evaluate() and evaluator.accumulate(); early-exit before accumulate() when stats are missing.
Common situations: Copying COCO eval code piecemeal (evaluate/accumulate/summarize pipeline) and dropping the accumulate step; catching an exception in evaluate and still calling summarize; running summarize twice when first run had no eval.
Related errors
- Please run accumulate() first
- not support iou_type: {self.iou_type}
- Unknown iou type {}
- Please run accumulate() first
- not support iou_type: {self.iou_type}
AI-assisted analysis of WZMIAOMIAO/deep-learning-for-image-processing@1ec3fe6f37 (2026-08-30).
Data as JSON: /api/errors/04a961792352cfb7.
Report an issue: GitHub.