Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fixbug: use BinaryPrecisionRecallCurve instead of PrecisionRecallCurve #1956

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

rglkt
Copy link
Contributor

@rglkt rglkt commented Apr 7, 2024

📝 Description

when I try to use aupr in my program, some error happen as follow:

  File "xxx/envs/anomalib_env/lib/python3.10/site-packages/anomalib/metrics/__init__.py", line 60, in metric_collection_from_names
    metrics.add_metrics(metric_cls())
TypeError: PrecisionRecallCurve.__new__() missing 1 required positional argument: 'task'

I found that's because PrecisionRecallCurve required positional argument: 'task'. We can use use BinaryPrecisionRecallCurve instead of PrecisionRecallCurve to solve this problem

PrecisionRecallCurve
    This function is a simple wrapper to get the task specific versions of this metric, which is done by setting the
    ``task`` argument to either ``'binary'``, ``'multiclass'`` or ``multilabel``. See the documentation of
    :class:`~torchmetrics.classification.BinaryPrecisionRecallCurve`,
    :class:`~torchmetrics.classification.MulticlassPrecisionRecallCurve` and
    :class:`~torchmetrics.classification.MultilabelPrecisionRecallCurve` for the specific details of each argument
    influence and examples.

    Legacy Example:
        >>> pred = torch.tensor([0, 0.1, 0.8, 0.4])
        >>> target = torch.tensor([0, 1, 1, 0])
        >>> pr_curve = PrecisionRecallCurve(task="binary")
  • 🛠️ Fixes # (issue number)

✨ Changes

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

@rglkt rglkt requested a review from djdameln as a code owner April 7, 2024 06:26
Copy link
Contributor

@samet-akcay samet-akcay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the fix!

@samet-akcay samet-akcay merged commit 7a963e9 into openvinotoolkit:main Apr 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants