Skip to content

🔬 Visualize attention layers from Stable Diffusion

Notifications You must be signed in to change notification settings

nathannlu/aperture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable Diffusion Visualizer

Visualize every attention layer in the UNet for each word in the prompt.

attention.visualization.mov

Supported models

  • Flux Dev
  • Stable Diffusion 2.1

1. Setting up the repository

Make sure you have the following prerequisites installed on your system:

  • python version 3.10
  • nodejs

The following steps will include commands you can run in your terminal. The commands are written for UNIX based systems like MacOS and Linux.

1.1 Download the model

For Flux Dev

Download the Flux Dev repository into the /models folder. You can download the repository from Huggingface here. You should have the following files in the /models folder:

  • /models/black-forest-labs/FLUX.1-dev/flux1-dev.safetensors
  • /models/black-forest-labs/FLUX.1-dev/ae.safetensors

You also need to download OpenAI's CLIP and Google's T5 encoders to the models repository. You should have the following files in the /models folder:

  • /models/openai/clip-vit-large-patch14/model.safetensors
  • /models/google/t5-v1_1-xxl/pytorch_model.bin

For Stable Diffusion 2.1

Download the Stable Diffusion 2.1 model into the /models folder. You can download the model from Huggingface here. After you have downloaded the model, the path to the model should be /models/v2-1_512-ema-pruned.safetensors

1.2 Install Python server dependencies

Next set up the Python server. In the root of the repository:

  • Create a virtual env (optional)
    python -m venv venv
    source venv/bin/activate
    
  • Install requirements.txt
    pip install -r requirements.txt
    

Now you can run the Python server with Uvicorn

uvicorn server:app --host 0.0.0.0 --port 8000

1.3 Install frontend dependencies

To set up the frontend, we will need to enter the web directory and install packages with npm

cd web
npm install

Now we are ready to run the app

2. Running the app

Boot up the Python server if you haven't already with:

uvicorn server:app --host 0.0.0.0 --port 8000

In another terminal, enter the frontend and run the start up script like so:

cd web
npm run dev

Now you are ready to use the app!

About

🔬 Visualize attention layers from Stable Diffusion

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published