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

🚚 Thresholding refactor #1064

Conversation

ashwinvaidya17
Copy link
Collaborator

Description

  • Proposes a design for allowing multiple thresholding methods.
  • Note: This is temporary till custom loops are added

Changes

  • 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)
  • This change requires a documentation update

Checklist

  • My code follows the pre-commit style and check guidelines of this project.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes
  • I have added a summary of my changes to the CHANGELOG (not for minor changes, docs and tests).

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 @ashwinvaidya17. Looking good to me.

A question though. Can we make it backward compatible? up until v1, I feel we should support backward compatibility. Otherwise, we'll break this again, which would be annoying.

Would it be possible to check threshold in config? For example, if there is method key we could instantiate AdaptiveScoreThreshold under the hood, no?

Comment on lines +142 to +143
image_threshold_class = image_threshold_config.get("class_path", None) if image_threshold_config else None
image_threshold_args = image_threshold_config.get("init_args", None) if image_threshold_config else None
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be a bit more verbose, but more accurate?

Suggested change
image_threshold_class = image_threshold_config.get("class_path", None) if image_threshold_config else None
image_threshold_args = image_threshold_config.get("init_args", None) if image_threshold_config else None
image_threshold_class_path = image_threshold_config.get("class_path", None) if image_threshold_config else None
image_threshold_init_args = image_threshold_config.get("init_args", None) if image_threshold_config else None

Comment on lines +145 to +146
pixel_threshold_class = pixel_threshold_config.get("class_path", None) if pixel_threshold_config else None
pixel_threshold_args = pixel_threshold_config.get("init_args", None) if pixel_threshold_config else None
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above?

raise NotImplementedError("Subclass of BaseAnomalyScoreThreshold must implement the update method")

def state_dict(
self, destination: Dict[str, Any], prefix: str = "", keep_vars: bool = False
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
self, destination: Dict[str, Any], prefix: str = "", keep_vars: bool = False
self, destination: dict[str, Any], prefix: str = "", keep_vars: bool = False


def state_dict(
self, destination: Dict[str, Any], prefix: str = "", keep_vars: bool = False
) -> Dict[str, Any] | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
) -> Dict[str, Any] | None:
) -> dict[str, Any] | None:

from __future__ import annotations

from abc import ABC
from typing import Any, Dict
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
from typing import Any, Dict
from typing import Any

@ashwinvaidya17
Copy link
Collaborator Author

Closing as these changes are mirrored in a PR to custom loops

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants