Skip to content

Commit

Permalink
updated experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
sMamooler committed Jan 6, 2022
1 parent ad105cf commit c90578d
Show file tree
Hide file tree
Showing 241 changed files with 1,477 additions and 3,282 deletions.
Binary file added Images/artemis.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/astronaut.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/el2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/el4.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/elephant.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/zebra.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/zebra.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 44 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,44 @@
# sem_project_IVRL
# CLIP Explainability

This repo contains the code for the [CLIP Explainability project](CLIP_Explainability.pdf).
In this project, we conduct an in-depth study of CLIP’s learned image and text representations using saliency map visualization. We propose a modification to the existing saliency visualization method that improves its performance as shown by our qualitative evaluations. We then use this method to study CLIP’s ability in capturing similarities and dissimilarities between an input image and targets belonging to different domains including image, text, and emotion.

## Setup

To install the required libraries run the following command:

```
pip install -r requirements.txt
```

## Organzation

[code](code) directory contains

- the implementation of saliency visualization methods: for [ViT] (code/vit_cam.py) and ResNet (code/rn_cam.py)-based CLIP
- Gildenblat et al.'s implementation of [GradCAM](code/pytorch-grad-cam)
- A re-implementation of CLIP taken from [Transformer-MM-Explainability](https://github.com/hila-chefer/Transformer-MM-Explainability) repo that keeps tack of attention maps and gradients: [clip_.py](code/clip_.py)
- [Notebooks](code/notebooks/) for the experiments explained in the report


[Images](Images) contains images used in the experiments.

[results](results) contains the results obtained from the experiments. Any result generated by the notebooks will be stored in this directory.


## Experiments


| Notebook Name | Experiment | Note |
| ------------- | ------------- | ------------- |
| [vit_block_vis](code/notebook/vit_block_vis.ipynb) | Layer-wise Attention Visualization | - |
| [saliency_method_compare](code/notebook/saliency_method_compare.ipynb) | ViT Explainability Method Comparison | qualitative comparison |
| [affectnet_emotions](code/notebook/affectnet_emotions.ipynb) | ViT Explainability Method Comparison | bias comparison. you need to download a sample of the AffectNet dataset [here](https://drive.google.com/drive/u/1/folders/11RusPab71wGw6LTd9pUnY1Gz3JSH-N_N) and place it in [Images](Images). |
| [pos_neg_vis](code/notebook/pos_neg_vis.ipynb) | Positive vs Negative Saliency | - |
| [artemis_emotions](code/notebook/artemis_emotions.ipynb) | Emotion-Image Similarity | you need to download the pre-processed WikiArt images [here](https://drive.google.com/drive/u/1/folders/11RusPab71wGw6LTd9pUnY1Gz3JSH-N_N) and place it in [Images](Images). Note that this notebook chooses images randomly so the results may not be the same as the ones in the report. |
| [perword_vis](code/notebook/perword_vis.ipynb) | Word-Wise Saliency Visualization |
| [global_vis](code/notebook/global_vis.ipynb) | - | can be used to visualize saliency maps for ViT and ResNet-based CLIP.
can be used to reporoduce the results for bias detection.|


6 changes: 0 additions & 6 deletions code/README.md

This file was deleted.

317 changes: 108 additions & 209 deletions code/notebooks/affectnet_emotions.ipynb

Large diffs are not rendered by default.

820 changes: 576 additions & 244 deletions code/notebooks/artemis_emotions.ipynb

Large diffs are not rendered by default.

1,469 changes: 0 additions & 1,469 deletions code/notebooks/cross_image_saliency.ipynb

This file was deleted.

122 changes: 27 additions & 95 deletions code/notebooks/global_vis.ipynb

Large diffs are not rendered by default.

253 changes: 48 additions & 205 deletions code/notebooks/perword_vis.ipynb

Large diffs are not rendered by default.

860 changes: 50 additions & 810 deletions code/notebooks/pos_neg_vis.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit c90578d

Please sign in to comment.