Shortcuts

Source code for mmengine.evaluator.utils

# Copyright (c) OpenMMLab. All rights reserved.
from typing import Any, Dict


[docs]def get_metric_value(indicator: str, metrics: Dict) -> Any: """Get the metric value specified by an indicator, which can be either a metric name or a full name with evaluator prefix. Args: indicator (str): The metric indicator, which can be the metric name (e.g. 'AP') or the full name with prefix (e.g. 'COCO/AP') metrics (dict): The evaluation results output by the evaluator Returns: Any: The specified metric value """ if '/' in indicator: # The indicator is a full name if indicator in metrics: return metrics[indicator] else: raise ValueError( f'The indicator "{indicator}" can not match any metric in ' f'{list(metrics.keys())}') else: # The indicator is metric name without prefix matched = [k for k in metrics.keys() if k.split('/')[-1] == indicator] if not matched: raise ValueError( f'The indicator {indicator} can not match any metric in ' f'{list(metrics.keys())}') elif len(matched) > 1: raise ValueError(f'The indicator "{indicator}" matches multiple ' f'metrics {matched}') else: return metrics[matched[0]]

© Copyright 2022, mmengine contributors. Revision 6af88783.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: v0.4.0
Versions
latest
stable
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.