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 b2295a25.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: v0.8.1
Versions
latest
stable
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
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.