nofilsiddiqui-2000/videollama2-attention

0

stars

296

commits

Python

primary language

Aug 11, 2025

updated

README

VideoLLaMA2 Attention Visualizer

This project builds on top of DAMO-NLP-SG/VideoLLaMA2 to visualize spatial and temporal attention maps across video frames, generate captions, and overlay both using custom rendering pipelines.

πŸ”¬ Designed for research and debugging in video-language models (VLMs).

πŸš€ Features

  • πŸ” Extract attention heatmaps from LLaMA-based video models
  • 🧠 Generate video captions using LLaMA2 + CLIP + Q-Former
  • 🎞 Overlay attention on original video
  • πŸ§ͺ Support for spatial + temporal attention layers
  • πŸ›  Modular pipeline for extending to RAG or clinical VLM use cases

πŸ“¦ Project Structure

videollama2/
β”œβ”€β”€ VideoLLaMA2/                # Cloned official model (DAMO-NLP-SG)
β”œβ”€β”€ scripts/                    # Setup/download automation
β”œβ”€β”€ assets/                     # Logos, icons, visuals
β”œβ”€β”€ frames*/                    # Intermediate extracted frames
β”œβ”€β”€ outputs/                    # Generated overlays and videos
β”œβ”€β”€ *.py                        # Core scripts (visualization, overlay, etc.)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── requirements.txt

πŸ›  Setup Instructions

βœ… 1. Clone This Repo

git clone https://github.com/nofilsiddiqui-2000/videollama2.git
cd videollama2

πŸ“₯ 2. Clone VideoLLaMA2 Core

git clone https://github.com/DAMO-NLP-SG/VideoLLaMA2.git
cd VideoLLaMA2
git checkout audio_visual
cd ..

πŸ“¦ 3. Set Up Environment

python -m venv .venv
source .venv/bin/activate       # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install flash-attn==2.5.8 --no-build-isolation

πŸ“Έ Example Commands

🎞 Generate Heatmaps and Captions

python videollama_attention_heatmap.py --config configs/videollama.yaml

πŸ“Ή Overlay Attention on Video

python caption_video.py --input frames_v2/ --heatmap attention2.mp4 --output overlay.mp4

πŸ“‹ Dependencies

pip install -r requirements.txt
sudo apt install ffmpeg   # Linux
choco install ffmpeg      # Windows (via Chocolatey)

πŸ“ Download Models (Optional Script)

bash scripts/download_weights.sh

🧠 Notes

  • This repo excludes large binaries like .pt, .npy, .mp4 using .gitignore
  • For reproduction, please download models and provide required configs

πŸ™‹ Author

Muhammad Nofil Siddiqui
πŸ“ Master’s Student @ Concordia University
πŸ”— LinkedIn
πŸ“« nofilsiddiqui2000@gmail.com

🧾 License

This repo is for research and academic purposes. See VideoLLaMA2’s license for original model usage.

Contributors

Copilot

1 commits

nofilsiddiqui-2000/videollama2-attention

0

stars

296

commits

Python

primary language

Aug 11, 2025

updated

README

VideoLLaMA2 Attention Visualizer

This project builds on top of DAMO-NLP-SG/VideoLLaMA2 to visualize spatial and temporal attention maps across video frames, generate captions, and overlay both using custom rendering pipelines.

πŸ”¬ Designed for research and debugging in video-language models (VLMs).

πŸš€ Features

  • πŸ” Extract attention heatmaps from LLaMA-based video models
  • 🧠 Generate video captions using LLaMA2 + CLIP + Q-Former
  • 🎞 Overlay attention on original video
  • πŸ§ͺ Support for spatial + temporal attention layers
  • πŸ›  Modular pipeline for extending to RAG or clinical VLM use cases

πŸ“¦ Project Structure

videollama2/
β”œβ”€β”€ VideoLLaMA2/                # Cloned official model (DAMO-NLP-SG)
β”œβ”€β”€ scripts/                    # Setup/download automation
β”œβ”€β”€ assets/                     # Logos, icons, visuals
β”œβ”€β”€ frames*/                    # Intermediate extracted frames
β”œβ”€β”€ outputs/                    # Generated overlays and videos
β”œβ”€β”€ *.py                        # Core scripts (visualization, overlay, etc.)
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── requirements.txt

πŸ›  Setup Instructions

βœ… 1. Clone This Repo

git clone https://github.com/nofilsiddiqui-2000/videollama2.git
cd videollama2

πŸ“₯ 2. Clone VideoLLaMA2 Core

git clone https://github.com/DAMO-NLP-SG/VideoLLaMA2.git
cd VideoLLaMA2
git checkout audio_visual
cd ..

πŸ“¦ 3. Set Up Environment

python -m venv .venv
source .venv/bin/activate       # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install flash-attn==2.5.8 --no-build-isolation

πŸ“Έ Example Commands

🎞 Generate Heatmaps and Captions

python videollama_attention_heatmap.py --config configs/videollama.yaml

πŸ“Ή Overlay Attention on Video

python caption_video.py --input frames_v2/ --heatmap attention2.mp4 --output overlay.mp4

πŸ“‹ Dependencies

pip install -r requirements.txt
sudo apt install ffmpeg   # Linux
choco install ffmpeg      # Windows (via Chocolatey)

πŸ“ Download Models (Optional Script)

bash scripts/download_weights.sh

🧠 Notes

  • This repo excludes large binaries like .pt, .npy, .mp4 using .gitignore
  • For reproduction, please download models and provide required configs

πŸ™‹ Author

Muhammad Nofil Siddiqui
πŸ“ Master’s Student @ Concordia University
πŸ”— LinkedIn
πŸ“« nofilsiddiqui2000@gmail.com

🧾 License

This repo is for research and academic purposes. See VideoLLaMA2’s license for original model usage.

Contributors

Copilot

1 commits

Languages

Python

99.1%