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

[Feature Request] Counter Factual GCAM #512

Open
MoH-assan opened this issue Jun 27, 2024 · 0 comments
Open

[Feature Request] Counter Factual GCAM #512

MoH-assan opened this issue Jun 27, 2024 · 0 comments

Comments

@MoH-assan
Copy link

Hi,
It would be nice to support counterfactual grad-cams from section 3.3 in the original paper.
https://arxiv.org/pdf/1610.02391

I guess it is a matter of changing this

cam = self.get_cam_image(input_tensor, target_layer, targets, layer_activations, layer_grads, eigen_smooth)
cam = np.maximum(cam, 0)

to this

            cam = self.get_cam_image(input_tensor, target_layer, targets, layer_activations, layer_grads, eigen_smooth)
            if counter_factual: #bkr
                cam = cam * -1

and passing counter_factual through call all the way to compute_cam_per_layer

I can do a pull request, but I am not very familiar with the entire code base.

Thanks,

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

No branches or pull requests

1 participant