Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Refactor] Rename metrics #83

Merged
merged 4 commits into from
Feb 2, 2023

Conversation

ice-tong
Copy link
Collaborator

@ice-tong ice-tong commented Jan 18, 2023

Motivation

We prefer that the names of Metric in MMEval follow the following two principles:

  • Metric name is meaningful
  • Unified Metric naming style

Modification

  • Add deprecation warning
  • SingleLabelMetric -> PrecisionRecallF1score (in PR [Refactor] Refactor single and multi label metrics #81 )
  • MultiLabelMetric -> MultiLabelPrecisionRecallF1score (in PR [Refactor] Refactor single and multi label metrics #81 )
  • COCODetectionMetric -> COCODetection
  • F1Metric -> F1Score
  • mmeval/metrics/f_metric.py -> mmeval/metrics/f1_score.py
  • tests/test_metrics/test_f_metric.py -> tests/test_metrics/test_f1_score.py
  • MAE -> MeanAbsoluteError
  • MSE -> MeanSquaredError
  • PSNR -> PeakSignalNoiseRatio
  • SNR -> SignalNoiseRatio
  • SSIM -> StructuralSimilarity
  • SAD -> SumAbsoluteDifferences
  • MattingMSE -> MattingMeanSquaredError

DeprecationWarning

Thanks to pep-0562, we can customize moudel's attribute access via __getattr__ to implement deprecation warnings.
We add a __geattr__ function into mmeval/__init__.py and mmeval/metrics/__init__.py.

_deprecated_msg = ...
__deprecated_metric_names__ = {
    'COCODetectionMetric': 'COCODetection',
    ...
}

def __getattr__(attr: str):
    if attr in __deprecated_metric_names__:
        message = _deprecated_msg.format(
            n1=attr, n2=__deprecated_metric_names__[attr])
        warnings.warn(message, DeprecationWarning, stacklevel=2)
        return globals()[__deprecated_metric_names__[attr]]
    raise AttributeError(f'module {__name__!r} has no attribute {attr!r}')

image

@ice-tong ice-tong requested a review from zhouzaida January 18, 2023 15:17
@zhouzaida zhouzaida merged commit cf34dbc into open-mmlab:main Feb 2, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants