Skip to content

Unexpected Class Swap in AblationCAM with Hugging Face ResNet-50 #555

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

Open
UnsupportedOperation opened this issue Feb 12, 2025 · 0 comments

Comments

@UnsupportedOperation
Copy link

Hi,

I am experiencing an issue when applying AblationCAM to the Hugging Face ResNet-50. I followed this guide to apply Grad-CAM methods to Hugging Face models, and everything works as expected.

However, when I use AblationCAM with this specific model, I notice an unusual behavior. For example, when setting the target category to "bull mastiff", I obtain the following result:

Image

But if I set the target category to "tabby, tabby cat", I get this:

Image

It looks like the two classes are swapped. Using other CAM methods on the same model or using AblationCAM on other models produces the expected results.

Additionally, when I apply AblationCAM to the torchvision ResNet-50 (as shown in the cam.py file), I get this correct result (for "bull mastiff"):

Image

Question:

What could be causing this issue? Could it be related to the Hugging Face ResNet-50 implementation?

Details:

  • The target layer used for the Hugging Face model is:
    model.resnet.encoder.stages[-1].layers[-1]
  • Other CAM methods work as expected.
  • AblationCAM on other Hugging Face models (like DeIT or Swin Transfomer) works well.
  • The issue does not occur when using the torchvision ResNet-50.

Any insights would be greatly appreciated!

Thanks in advance.

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