Mariano Ntrougkas commited on
Add datalist and remove readme
Browse files- .gitattributes +1 -0
- README.md +2 -177
- datalist/ILSVRC/Evaluation_2000.txt +3 -0
- datalist/ILSVRC/Validation_2000.txt +3 -0
- datalist/ILSVRC/resnet50_train.txt +3 -0
- datalist/ILSVRC/val.txt +3 -0
- datalist/ILSVRC/vgg16_train.txt +3 -0
- datalist/ILSVRC/vit_b_16_train.txt +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.txt filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -2,181 +2,6 @@
|
|
| 2 |
tags:
|
| 3 |
- explainability, computer vision
|
| 4 |
---
|
| 5 |
-
# T-TAME: Trainable Attention Mechanism for
|
| 6 |
|
| 7 |
-
This repository hosts the
|
| 8 |
-
|
| 9 |
-
- This repository contains the code for training, evaluating, and applying T-TAME, using VGG-16, ResNet-50, or ViT-B-16 as the pre-trained backbone network along with the Attention Mechanism and our selected loss function. There is also a guide on applying TAME to any DNN image classifier.
|
| 10 |
-
- It also contains the trained T-TAME attention mechanism for VGG-16, ViT-B-16, and ResNet-50 and the L-CAM method for the VGG-16 and ResNet-50 classifiers, used for comparisons. The checkpoints are bundled in the repository using `git-lfs`.
|
| 11 |
-
- In `T-TAME/datalist/ILSVRC`, text files with annotations for 2000 randomly selected images to be used at the validation stage (Validation_2000.txt) and 2000 randomly selected images (exclusive of the previous 2000) for the evaluation stage (Evaluation_2000.txt) of the L-CAM methods.
|
| 12 |
-
- The ILSVRC 2012 dataset images should be downloaded by the user manually.
|
| 13 |
-
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
- [T-TAME: Trainable Attention Mechanism for Explanations, now for transformers](#t-tame-trainable-attention-mechanism-for-explanations-now-for-transformers)
|
| 17 |
-
- [Initial Setup](#initial-setup)
|
| 18 |
-
- [Available scripts](#available-scripts)
|
| 19 |
-
- [Citation](#citation)
|
| 20 |
-
- [BibTeX](#bibtex)
|
| 21 |
-
- [BibTeX](#bibtex-1)
|
| 22 |
-
- [License](#license)
|
| 23 |
-
- [Acknowledgement](#acknowledgement)
|
| 24 |
-
|
| 25 |
-
## Initial Setup
|
| 26 |
-
|
| 27 |
-
Make sure that you have a working git, git-lfs, Python 3, cuda, and poetry installation before proceeding.
|
| 28 |
-
|
| 29 |
-
- To install git, follow the instructions [here](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git).
|
| 30 |
-
|
| 31 |
-
- To install python, follow the instructions [here](https://www.python.org/downloads/).
|
| 32 |
-
|
| 33 |
-
- To install cuda, follow the instructions [here](https://developer.nvidia.com/cuda-downloads).
|
| 34 |
-
|
| 35 |
-
- To install poetry, follow the instructions [here](https://python-poetry.org/docs/).
|
| 36 |
-
|
| 37 |
-
- To install git-lfs, follow the instructions [here](https://git-lfs.com)
|
| 38 |
-
|
| 39 |
-
1. Clone this repository:
|
| 40 |
-
|
| 41 |
-
```shell
|
| 42 |
-
git lfs install
|
| 43 |
-
git clone --recurse-submodules git@github.com:marios1861/T-TAME.git
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
2. Go to the locally saved repository path:
|
| 47 |
-
|
| 48 |
-
```shell
|
| 49 |
-
cd T-TAME
|
| 50 |
-
```
|
| 51 |
-
|
| 52 |
-
3. Install:
|
| 53 |
-
|
| 54 |
-
```shell
|
| 55 |
-
poetry install
|
| 56 |
-
```
|
| 57 |
-
|
| 58 |
-
4. Create a `.env` file in `pl_scripts`. The file should contain the following key-value pair:
|
| 59 |
-
|
| 60 |
-
```shell
|
| 61 |
-
DATA=<path to imagenet dataset>
|
| 62 |
-
LIST=<path to datalist folder>
|
| 63 |
-
```
|
| 64 |
-
|
| 65 |
-
The `LIST` path should be the path to the `./datalist/ILSVRC` folder if using the ImageNet dataset.
|
| 66 |
-
|
| 67 |
-
> __Note__: You may need to modify the venv activate script in the case that cuda is already installed on your machine. If so, add this line:
|
| 68 |
-
> `export LD_LIBRARY_PATH=.../venv/lib/python3.8/site-packages/nvidia/cublas/lib/:$LD_LIBRARY_PATH`
|
| 69 |
-
|
| 70 |
-
## Available scripts
|
| 71 |
-
|
| 72 |
-
You can evaluate the compared methods, including T-TAME with the `{vgg16, resnet50, vit_b_16}` backbones using the following command:
|
| 73 |
-
using the command:
|
| 74 |
-
|
| 75 |
-
```shell
|
| 76 |
-
python pl_scripts/{vgg16, resnet50, vit_b_16}_comparisons.py
|
| 77 |
-
```
|
| 78 |
-
|
| 79 |
-
You can train the T-TAME method using the following command:
|
| 80 |
-
|
| 81 |
-
```shell
|
| 82 |
-
python pl_scripts/{vgg16, resnet50, vit}_TAME.py
|
| 83 |
-
```
|
| 84 |
-
|
| 85 |
-
You can generate explanation maps for the T-TAME method using the following command:
|
| 86 |
-
|
| 87 |
-
```shell
|
| 88 |
-
python pl_scripts/TAME_print_mask.py
|
| 89 |
-
```
|
| 90 |
-
|
| 91 |
-
You can generate explanation maps for the compared methods using the following command:
|
| 92 |
-
|
| 93 |
-
```shell
|
| 94 |
-
python pl_scripts/other_methods_print_mask.py
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
## Citation
|
| 98 |
-
|
| 99 |
-
<div align="justify">
|
| 100 |
-
|
| 101 |
-
If you find our TAME method, code, or pretrained models useful in your work, please cite the following publication:
|
| 102 |
-
|
| 103 |
-
- M. V. Ntrougkas, N. Gkalelis, and V. Mezaris, “T-TAME: Trainable Attention Mechanism for Explaining Convolutional Networks and Vision Transformers.” arXiv, Mar. 07, 2024. doi: 10.48550/arXiv.2403.04523.
|
| 104 |
-
|
| 105 |
-
</div>
|
| 106 |
-
|
| 107 |
-
### BibTeX
|
| 108 |
-
|
| 109 |
-
<span style="color:red">
|
| 110 |
-
|
| 111 |
-
```bibtex
|
| 112 |
-
@misc{ntrougkas2024ttame,
|
| 113 |
-
title={T-TAME: Trainable Attention Mechanism for Explaining Convolutional Networks and Vision Transformers},
|
| 114 |
-
author={Mariano V. Ntrougkas and Nikolaos Gkalelis and Vasileios Mezaris},
|
| 115 |
-
year={2024},
|
| 116 |
-
eprint={2403.04523},
|
| 117 |
-
archivePrefix={arXiv},
|
| 118 |
-
primaryClass={cs.CV}
|
| 119 |
-
}
|
| 120 |
-
```
|
| 121 |
-
|
| 122 |
-
</span>
|
| 123 |
-
|
| 124 |
-
<div align="justify">
|
| 125 |
-
|
| 126 |
-
You may want to also consult and, if you find it useful, also cite our earlier works on this topic (methods TAME, L-CAM-Img, L-CAM-Fm):
|
| 127 |
-
|
| 128 |
-
- M. Ntrougkas, N. Gkalelis and V. Mezaris, "TAME: Attention Mechanism Based Feature Fusion for Generating Explanation Maps of Convolutional Neural Networks," in 2022 IEEE International Symposium on Multimedia (ISM), Italy, 2022 pp. 58-65. doi: 10.1109/ISM55400.2022.00014
|
| 129 |
-
- Gkartzonika, I., Gkalelis, N., Mezaris, V. (2023). Learning Visual Explanations for DCNN-Based Image Classifiers Using an Attention Mechanism. In: Karlinsky, L., Michaeli, T., Nishino, K. (eds) Computer Vision – ECCV 2022 Workshops. ECCV 2022. Lecture Notes in Computer Science, vol 13808. Springer, Cham. <https://doi.org/10.1007/978-3-031-25085-9_23>
|
| 130 |
-
|
| 131 |
-
</div>
|
| 132 |
-
|
| 133 |
-
### BibTeX
|
| 134 |
-
|
| 135 |
-
```bibtex
|
| 136 |
-
@INPROCEEDINGS{10019620,
|
| 137 |
-
author={Ntrougkas, Mariano and Gkalelis, Nikolaos and Mezaris, Vasileios},
|
| 138 |
-
booktitle={2022 IEEE International Symposium on Multimedia (ISM)},
|
| 139 |
-
title={TAME: Attention Mechanism Based Feature Fusion for Generating Explanation Maps of Convolutional Neural Networks},
|
| 140 |
-
year={2022},
|
| 141 |
-
volume={},
|
| 142 |
-
number={},
|
| 143 |
-
pages={58-65},
|
| 144 |
-
keywords={Training;Visualization;Computational modeling;Neural networks;Computer architecture;Streaming media;Feature extraction;CNNs;Deep Learning;Explainable AI;Interpretable ML;Attention},
|
| 145 |
-
doi={10.1109/ISM55400.2022.00014}}
|
| 146 |
-
|
| 147 |
-
@InProceedings{10.1007/978-3-031-25085-9_23,
|
| 148 |
-
author="Gkartzonika, Ioanna
|
| 149 |
-
and Gkalelis, Nikolaos
|
| 150 |
-
and Mezaris, Vasileios",
|
| 151 |
-
editor="Karlinsky, Leonid
|
| 152 |
-
and Michaeli, Tomer
|
| 153 |
-
and Nishino, Ko",
|
| 154 |
-
title="Learning Visual Explanations for DCNN-Based Image Classifiers Using an Attention Mechanism",
|
| 155 |
-
booktitle="Computer Vision -- ECCV 2022 Workshops",
|
| 156 |
-
year="2023",
|
| 157 |
-
publisher="Springer Nature Switzerland",
|
| 158 |
-
address="Cham",
|
| 159 |
-
pages="396--411",
|
| 160 |
-
abstract="In this paper two new learning-based eXplainable AI (XAI) methods for deep convolutional neural network (DCNN) image classifiers, called L-CAM-Fm and L-CAM-Img, are proposed. Both methods use an attention mechanism that is inserted in the original (frozen) DCNN and is trained to derive class activation maps (CAMs) from the last convolutional layer's feature maps. During training, CAMs are applied to the feature maps (L-CAM-Fm) or the input image (L-CAM-Img) forcing the attention mechanism to learn the image regions explaining the DCNN's outcome. Experimental evaluation on ImageNet shows that the proposed methods achieve competitive results while requiring a single forward pass at the inference stage. Moreover, based on the derived explanations a comprehensive qualitative analysis is performed providing valuable insight for understanding the reasons behind classification errors, including possible dataset biases affecting the trained classifier (Source code is made publicly available at: https://github.com/bmezaris/L-CAM).",
|
| 161 |
-
isbn="978-3-031-25085-9"
|
| 162 |
-
}
|
| 163 |
-
```
|
| 164 |
-
|
| 165 |
-
## License
|
| 166 |
-
|
| 167 |
-
<div align="justify">
|
| 168 |
-
|
| 169 |
-
Copyright (c) 2024, Mariano Ntrougkas, Nikolaos Gkalelis, Vasileios Mezaris / CERTH-ITI. All rights reserved. This code is provided for academic, non-commercial use only. Please also check for any restrictions applied in the code parts and datasets used here from other sources. For the materials not covered by any such restrictions, redistribution and use in source and binary forms, with or without modification, are permitted for academic non-commercial use provided that the following conditions are met:
|
| 170 |
-
|
| 171 |
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation provided with the distribution.
|
| 172 |
-
|
| 173 |
-
This software is provided by the authors "as is" and any express or implied warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose are disclaimed. In no event shall the authors be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this software, even if advised of the possibility of such damage.
|
| 174 |
-
</div>
|
| 175 |
-
|
| 176 |
-
## Acknowledgement
|
| 177 |
-
|
| 178 |
-
The T-TAME implementation was built in part on code previously released in the [TAME](https://https://github.com/bmezaris/TAME) repository.
|
| 179 |
-
|
| 180 |
-
The code for the methods that are used for comparison is taken from the [TAME](https://github.com/bmezaris/TAME) repository for TAME, the [L-CAM](https://github.com/bmezaris/L-CAM) repository for L-CAM-Img, the [RISE](https://github.com/eclique/RISE) repository for RISE, the [IIA](https://github.com/iia-iccv23/iia) repository for IIA, the [Transformer-Explainability](https://github.com/hila-chefer/Transformer-Explainability) repository for the Transformer LRP method and the [pytorch-gradcam](https://github.com/yiskw713/ScoreCAM/blob/master/cam.py) repository for all of the remaining utilized methods.
|
| 181 |
-
|
| 182 |
-
<div align="justify"> This work was supported by the EU Horizon 2020 programme under grant agreement H2020-101021866 CRiTERIA. </div>
|
|
|
|
| 2 |
tags:
|
| 3 |
- explainability, computer vision
|
| 4 |
---
|
| 5 |
+
# T-TAME: Trainable Attention Mechanism for Explaining Convolutional Networks and Vision Transformers: Supplemtary Material
|
| 6 |
|
| 7 |
+
This repository hosts the trained T-TAME attention mechanism for VGG-16, ViT-B-16, and ResNet-50 and the L-CAM method for the VGG-16 and ResNet-50 classifiers, used for comparisons. The checkpoints are bundled in the repository using `git-lfs`. It is a submodule of the main repository, which contains the code for the T-TAME method. The main repository can be found [here](https://github.com/IDT-ITI/T-TAME).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
datalist/ILSVRC/Evaluation_2000.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fa82dd426af9b082e5eb824388387126a12196ff1e73196e1ff349b5998a6331
|
| 3 |
+
size 67769
|
datalist/ILSVRC/Validation_2000.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2434b74c218bc2a1415385946c00f2e019736df222ea1d0c463978c5e56f6c9
|
| 3 |
+
size 65774
|
datalist/ILSVRC/resnet50_train.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:385f7f0618506d25ca1f83208d6974fa54f8992e121083baa1e525cc8443b2a5
|
| 3 |
+
size 43829538
|
datalist/ILSVRC/val.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4138c0cd92d2dffea9353a9339c9f352361b7c6c267d2ff989b366f154188257
|
| 3 |
+
size 1644500
|
datalist/ILSVRC/vgg16_train.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ed2ca220becd3b9de38cb0a239968c615f482837a072af71c0c89f0649df633
|
| 3 |
+
size 43829170
|
datalist/ILSVRC/vit_b_16_train.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:54dc551e8cd7933e4d205e03714f5794310abf43ed89b099f6815552431b311c
|
| 3 |
+
size 43829398
|