Skip to content

Commit bb2193e

Browse files
genehwungdanjan1234
authored andcommitted
Adds a merge functionality for the COCOEvaluator for distributed workflow.
PiperOrigin-RevId: 621024221
1 parent 347fc79 commit bb2193e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: models/official/detection/evaluation/coco_evaluator.py

+14
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,20 @@ def update(self, predictions, groundtruths=None):
361361
else:
362362
self._groundtruths[k].append(v)
363363

364+
def merge(self, other):
365+
"""Merges the states from the other CocoEvaluator."""
366+
for k, v in other._predictions.items(): # pylint: disable=protected-access
367+
if k not in self._predictions:
368+
self._predictions[k] = v
369+
else:
370+
self._predictions[k].extend(v)
371+
372+
for k, v in other._groundtruths.items(): # pylint: disable=protected-access
373+
if k not in self._groundtruths:
374+
self._groundtruths[k] = v
375+
else:
376+
self._groundtruths[k].extend(v)
377+
364378

365379
class ShapeMaskCOCOEvaluator(COCOEvaluator):
366380
"""COCO evaluation metric class for ShapeMask."""

0 commit comments

Comments
 (0)