hila-chefer / Transformer-Explainability

[CVPR 2021] Official PyTorch implementation for Transformer Interpretability Beyond Attention Visualization, a novel method to visualize classifications by Transformer based networks.
MIT License
1.75k stars 232 forks source link

name 'SequenceClassifierOutput' is not defined #51

Closed songhuadan closed 1 year ago

songhuadan commented 1 year ago

Try to run in Colab the Bert-explainability

! pip install -r requirements.txt I got the following error ERROR: Could not find a version that satisfies the requirement opencv_python==3.4.2.17 (from versions: 3.4.0.14, 3.4.8.29, 3.4.9.31, 3.4.9.33, 3.4.10.35, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.1.2.30, 4.2.0.32, 4.2.0.34, 4.3.0.36, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66) ERROR: No matching distribution found for opencv_python==3.4.2.17

When run the example cells, I got the persistent error: name 'SequenceClassifierOutput' is not defined

hila-chefer commented 1 year ago

Hi @songhuadan, thanks for pointing this issue out. It seemed to be a problem with opencv versions with colab (I was able to run the notebook on my machine), and I fixed the requirements file. There seems to be another issue with visualization using captum, but now you should be able to get the relevance scores. I will try to work on resolving the captum issue as well, say tuned :)

Best, Hila.

Amirhosein2c commented 1 year ago

Hi, Thanks for the great effort. I was wondering how I can use the VIT visualization code with a fine-tuned VIT on my own custom dataset? I used a pre-trained VIT based on the "google/vit-base-patch16-224-in21k" on my own data. Now that I am trying to use your code on my own trained Vit I get errors here and there! Do you have any suggestions?

hila-chefer commented 1 year ago

Hi @Amirhosein2c, thanks for your interest!

As mentioned in this issue you can load your own weights as long as they are compatible with the implementation from timm.

does this help?

hila-chefer commented 1 year ago

@songhuadan, issue fixed, thanks for pointing this our again :)

MohieEldinMuhammad commented 11 months ago

@Amirhosein2c If you please, did you manage to visualize your google/vit model because I'm facing the same problem and it seems that the vit/model architecture is not the same as the model implemented in this repo