Shortcuts

mmengine.evaluator.utils 源代码

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


[文档]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 66fb81f7.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: latest
Versions
latest
stable
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.