File size: 1,591 Bytes
14389b1
f48b9d7
 
 
14389b1
 
 
f48b9d7
 
14389b1
 
 
f48b9d7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
title: Text Embedding Explorer for SD 1.5
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 6.30.0
app_file: app.py
suggested_hardware: t4-small
short_description: Explore and edit text embeddings in Stable Diffusion 1.5
pinned: false
---

# Text Embedding Explorer for Stable Diffusion 1.5

A Gradio Space for BA creative coding students. Instead of changing the prompt text, you change
the **text embedding** (the 77 x 768 numbers that Stable Diffusion 1.5 actually receives).

Tabs:

1. **Interpolate** blends two prompts (lerp or slerp, with optional extrapolation).
2. **Arithmetic** computes A - B + C on embeddings.
3. **Edit tokens** scales or blends single tokens of a prompt and shows original and edit side by side.
4. **Map** draws a 2D PCA map and a similarity matrix of words or prompts.

All images within one run share the same noise (seed), so differences come from the embedding only.

## Hardware

Made for a dedicated GPU such as `t4-small`. Typical time on a T4 is a few seconds per image at 512 px
and 20 steps. On CPU it runs but takes minutes per image.

## Settings

Optional environment variables (Space settings, Variables):

- `MODEL_ID` loads another SD 1.5 compatible repo. Default is `stable-diffusion-v1-5/stable-diffusion-v1-5`.
- `DISABLE_SAFETY_CHECKER=1` turns off the NSFW filter. It is on by default. Odd embedding mixes can
  occasionally trigger it, which shows up as a black image.

## Run locally

```bash
pip install -r requirements.txt gradio==6.30.0
python app.py
```

The model is downloaded from the Hugging Face Hub on first start.