Image Attention Visualizer is an interactive Gradio app that visualizes cross-modal attention between image tokens and generated text tokens in a custom multimodal model. It allows researchers and developers to see how different parts of an image influence the model’s textual output, token by token.
An interactive Gradio app to generate text from an image using a custom multimodal model and visualize attention in real time. It provides 3 synchronized views — original image, attention overlay, and heatmap — plus a word-level visualization showing how each generated word attends to visual regions.
Interactive Gradio app for visualizing image-to-text attention maps in custom vision–language models.
| Path | Description |
|---|---|
assets/ | Images, figures, or other supporting media used by the project. |
examples/ | Sample inputs, demos, or reference runs for the project. |
utils/ | Reusable helper modules and shared utility functions. |
.gitignore | Top-level file included in the repository. |
app.py | Top-level file included in the repository. |
LICENSE | Repository license information. |
README.md | Primary project documentation. |
requirements.txt | Python dependency specification for local setup. |
Clone the repository.
git clone https://github.com/devMuniz02/Image-Attention-Visualizer.git
cd Image-Attention-Visualizer
Prepare the local environment.
Install Python dependencies:
pip install -r requirements.txt
Run the main application:
python app.py
git clone https://github.com/devMuniz02/Image-Attention-Visualizer
cd Image-Attention-Visualizer
Windows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1
macOS / Linux (bash/zsh):
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.py
You should see something like:
Running on local URL: http://127.0.0.1:7860
Navigate to http://127.0.0.1:7860 to use the app.
Upload an image or load a random sample from your dataset folder.
Set generation parameters:
Click Generate — the model will produce a textual description or continuation.
Select a generated word from the list:
The top row will show:
The bottom section highlights attention strength over the generated words.
app.py — Main Gradio interface and visualization logic.utils/models/complete_model.py — Model definition and generation method.utils/processing.py — Image preprocessing utilities.requirements.txt — Dependencies.README.md — This file.output_attentions=True in .generate().img_size or the interpolation method inside _make_overlay.model.decoder.tokenizer exists and is loaded correctly.max_new_tokens or use a smaller model checkpoint.The app is compatible with any encoder–decoder or vision–language model that:
pixel_values as input.generate(..., output_attentions=True) with (gen_ids, gen_text, attentions).Uses the tokenizer from model.decoder.tokenizer.
Designed for research in vision-language interpretability, cross-modal explainability, and attention visualization.
Generates text from an image input using your custom model (create_complete_model).
Displays three synchronized views:
Word-level attention viewer: select any generated word to see how its attention is distributed across the image and previously generated words.
Works directly with your custom tokenizer (model.decoder.tokenizer).
Fixed-length 1024 image tokens (32×32 grid) projected as a visual heatmap.
Adjustable options: Layer, Head, or Mean Across Layers/Heads.
8 commits
Python
100.0%
Image Attention Visualizer is an interactive Gradio app that visualizes cross-modal attention between image tokens and generated text tokens in a custom multimodal model. It allows researchers and developers to see how different parts of an image influence the model’s textual output, token by token.
An interactive Gradio app to generate text from an image using a custom multimodal model and visualize attention in real time. It provides 3 synchronized views — original image, attention overlay, and heatmap — plus a word-level visualization showing how each generated word attends to visual regions.
Interactive Gradio app for visualizing image-to-text attention maps in custom vision–language models.
| Path | Description |
|---|---|
assets/ | Images, figures, or other supporting media used by the project. |
examples/ | Sample inputs, demos, or reference runs for the project. |
utils/ | Reusable helper modules and shared utility functions. |
.gitignore | Top-level file included in the repository. |
app.py | Top-level file included in the repository. |
LICENSE | Repository license information. |
README.md | Primary project documentation. |
requirements.txt | Python dependency specification for local setup. |
Clone the repository.
git clone https://github.com/devMuniz02/Image-Attention-Visualizer.git
cd Image-Attention-Visualizer
Prepare the local environment.
Install Python dependencies:
pip install -r requirements.txt
Run the main application:
python app.py
git clone https://github.com/devMuniz02/Image-Attention-Visualizer
cd Image-Attention-Visualizer
Windows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1
macOS / Linux (bash/zsh):
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python app.py
You should see something like:
Running on local URL: http://127.0.0.1:7860
Navigate to http://127.0.0.1:7860 to use the app.
Upload an image or load a random sample from your dataset folder.
Set generation parameters:
Click Generate — the model will produce a textual description or continuation.
Select a generated word from the list:
The top row will show:
The bottom section highlights attention strength over the generated words.
app.py — Main Gradio interface and visualization logic.utils/models/complete_model.py — Model definition and generation method.utils/processing.py — Image preprocessing utilities.requirements.txt — Dependencies.README.md — This file.output_attentions=True in .generate().img_size or the interpolation method inside _make_overlay.model.decoder.tokenizer exists and is loaded correctly.max_new_tokens or use a smaller model checkpoint.The app is compatible with any encoder–decoder or vision–language model that:
pixel_values as input.generate(..., output_attentions=True) with (gen_ids, gen_text, attentions).Uses the tokenizer from model.decoder.tokenizer.
Designed for research in vision-language interpretability, cross-modal explainability, and attention visualization.
Generates text from an image input using your custom model (create_complete_model).
Displays three synchronized views:
Word-level attention viewer: select any generated word to see how its attention is distributed across the image and previously generated words.
Works directly with your custom tokenizer (model.decoder.tokenizer).
Fixed-length 1024 image tokens (32×32 grid) projected as a visual heatmap.
Adjustable options: Layer, Head, or Mean Across Layers/Heads.
8 commits
Python
100.0%