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

Insertion Deletion AUC metric #56

Merged
merged 9 commits into from
Aug 26, 2024

Conversation

GalyaZalesskaya
Copy link
Contributor

  • Added Insertion Deletion AUC metric that calculates the accuracy drop/increase during deletion/insertion of important pixels
    image

  • Added parent BasicMetric

Copy link

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 98.73418% with 1 line in your changes missing coverage. Please review.

Project coverage is 92.64%. Comparing base (1e41ff2) to head (dab6e9a).
Report is 1 commits behind head on develop.

Files Patch % Lines
openvino_xai/explainer/utils.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #56      +/-   ##
===========================================
+ Coverage    92.43%   92.64%   +0.21%     
===========================================
  Files           20       22       +2     
  Lines         1308     1373      +65     
===========================================
+ Hits          1209     1272      +63     
- Misses          99      101       +2     
Flag Coverage Δ
dev-py310 92.64% <98.73%> (+0.21%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GalyaZalesskaya GalyaZalesskaya marked this pull request as ready for review August 22, 2024 16:44
Copy link
Contributor

@goodsong81 goodsong81 left a comment

Choose a reason for hiding this comment

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

Thank you for the update. I have a few comments below.
Besides, one alternative design idea came up in my mind. Could you please consider the following idea and my comments?

class Metric(ABC):
    def __init__(
        self,
        score_fn: Callable[[np.ndarray], np.ndarray],  # image -> score vector
        # metric specific static parameters (like 'step' in AUC)
        *args,
        **kwargs,
    ):
        ...

    def __call__(  # Single image
        self,
        saliency_map: np.ndarray,
        class_idx: int,
        input_image: np.ndarray,
    ) -> Dict[str, float]:
        ...

    def evaluate(  # Dataset
        self,
        explanations: List[Explanation],
        input_images: List[np.ndarray],
    ) -> Dict[str, float]:
        ...

To me, setting model, preproc, postproc functions looks too complicated.
In above way, users could set arbitrary inference function that computes score vector from image. Explainer.model_forward() could also be reused in this way.

openvino_xai/metrics/base.py Outdated Show resolved Hide resolved
openvino_xai/metrics/base.py Outdated Show resolved Hide resolved
openvino_xai/metrics/insertion_deletion_auc.py Outdated Show resolved Hide resolved
openvino_xai/metrics/base.py Outdated Show resolved Hide resolved
@GalyaZalesskaya
Copy link
Contributor Author

Thank you for your suggestions, Songki. I implemented __call__ for a single image and evaluate for a set of images. I also return Dict[str, float] for both of functions. It helps the generality but getting the score is no more elegant:

pointing_game_score = self.pointing_game.evaluate([explanation], self.gt_bboxes)["pointing_game"]
pointing_game_score = list(self.pointing_game.evaluate([explanation], self.gt_bboxes).values())[0]

Provably, evaluate can affect the internal state of Metric class and we can get scores as property function pointing_game.score. Let's leave the optimization until the next PR.

Copy link
Contributor

@goodsong81 goodsong81 left a comment

Choose a reason for hiding this comment

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

Let's do the refactoring afterwards. Thank you for the update!

@goodsong81 goodsong81 merged commit 4e39758 into openvinotoolkit:develop Aug 26, 2024
6 checks passed
@goodsong81 goodsong81 added this to the 1.1.0 milestone Sep 2, 2024
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