attention-map-diffusers  by wooyeolbaek

Attention map tool for Hugging Face Diffusers

created 1 year ago
324 stars

Top 85.2% on sourcepulse

GitHubView on GitHub
Project Summary

This repository provides tools for extracting and visualizing cross-attention maps from Hugging Face Diffusers pipelines, targeting researchers and developers working with diffusion models. It enables deeper understanding of how models interpret prompts by highlighting spatial relationships between text tokens and image features.

How It Works

The library injects hooks into compatible Diffusers pipelines to capture cross-attention map data during the generation process. It then processes these maps, allowing for saving and visualization based on specific timesteps and layers, offering granular insight into the diffusion model's internal workings.

Quick Start & Requirements

  • Install via pip: pip install attention_map_diffusers or pip install -e .
  • Requires Python and PyTorch.
  • GPU with CUDA is recommended for performance.
  • Compatible with Hugging Face Diffusers v0.32.0 and later.
  • Supports models like Stable Diffusion 3.5, Flux-dev, Flux-schnell, Stable Diffusion 3, Stable Diffusion XL, and Stable Diffusion 2.1.
  • Official documentation and examples are available in the repository.

Highlighted Details

  • Compatible with recent models including Stable Diffusion 3.5 and Flux variants.
  • Supports batch operations for Stable Diffusion 3 (with caveats on CPU memory).
  • Allows saving attention maps based on specific timesteps and layers.
  • Enables CPU offloading to save VRAM.

Maintenance & Community

  • Actively updated, with recent compatibility additions for SD3.5 and Flux models.
  • Issue tracker available on GitHub for bug reports and feature requests.

Licensing & Compatibility

  • The repository does not explicitly state a license in the provided README.

Limitations & Caveats

  • Batch operations are not recommended for SD3 due to potential CPU memory exhaustion.
  • Compatibility with "Sana" models is planned for a future update.
Health Check
Last commit

6 months ago

Responsiveness

Inactive

Pull Requests (30d)
0
Issues (30d)
1
Star History
51 stars in the last 90 days

Explore Similar Projects

Starred by Dan Abramov Dan Abramov(Core Contributor to React), Patrick von Platen Patrick von Platen(Core Contributor to Hugging Face Transformers and Diffusers), and
28 more.

stable-diffusion by CompVis

0.1%
71k
Latent text-to-image diffusion model
created 3 years ago
updated 1 year ago
Feedback? Help us improve.