š¬ Visualize attention layers from Stable Diffusion
92
stars
12
commits
TypeScript
primary language
Apr 1, 2025
updated
Visualize every attention layer in the UNet for each word in the prompt.
https://github.com/user-attachments/assets/45af9de1-035d-4af5-8946-8740cd0daed3
Supported models
Make sure you have the following prerequisites installed on your system:
The following steps will include commands you can run in your terminal. The commands are written for UNIX based systems like MacOS and Linux.
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:
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:
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
Next set up the Python server. In the root of the repository:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Now you can run the Python server with Uvicorn
uvicorn server:app --host 0.0.0.0 --port 8000
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
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!
12 commits
TypeScript
81.7%
Python
16.6%
CSS
1.6%
š¬ Visualize attention layers from Stable Diffusion
92
stars
12
commits
TypeScript
primary language
Apr 1, 2025
updated
Visualize every attention layer in the UNet for each word in the prompt.
https://github.com/user-attachments/assets/45af9de1-035d-4af5-8946-8740cd0daed3
Supported models
Make sure you have the following prerequisites installed on your system:
The following steps will include commands you can run in your terminal. The commands are written for UNIX based systems like MacOS and Linux.
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:
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:
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
Next set up the Python server. In the root of the repository:
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Now you can run the Python server with Uvicorn
uvicorn server:app --host 0.0.0.0 --port 8000
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
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!
12 commits
TypeScript
81.7%
Python
16.6%
CSS
1.6%