Stable Diffusion Helper
A helper package for working with stable diffusion models. Allows for easy extraction of U-Net (and transformer) representations.
Installation
pip install sdhelper
Usage
from sdhelper import SD
# load model
sd = SD('SD-1.5')
# generate image
img = sd('a beautiful landscape').result_image
# extract representations from the `up[1]` block at time step 50
r = sd.img2repr(img, extract_positions=['up_blocks[1]'], step=50)
# compute similarity between all pairs of tokens in `r`
similarities = r.cosine_similarity(r)
Available models:
- SD1.1
- SD1.2
- SD1.3
- SD1.4
- SD1.5
- SD2.0
- SD2.1
- SD-Turbo
- SDXL
- SDXL-Turbo
- SDXL-Lightning-1step
- SDXL-Lightning-2step
- SDXL-Lightning-4step
- SDXL-Lightning-8step
- SD3
- FLUX-dev
- FLUX-schnell
Especially for FLUX models, it might make sense to quantize the weights and enable CPU offloading:
flux = SD('FLUX-schnell')
flux.quantize(['transformer', 'text_encoder_2'], model_cpu_offload=True)
Metadata
Release files for sdhelper 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sdhelper-1.0.0.tar.gz | 765.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sdhelper-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 778.7 kB
Release files / sdhelper-1.0.0.tar.gz
| Download URL | sdhelper-1.0.0.tar.gz |
|---|---|
| Size | 765.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f5fba9914a5a199fa0fd79a6daf2d6e3b0e369bd4b83f75304fff2d866ae1150
|
|
BLAKE2b-256 checksum How to use checksums |
fb8ab6c4d7ba1e8c383ffacff439dea460ab563c0a946fa160319ae269a7ec61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|
Release files / sdhelper-1.0.0-py3-none-any.whl
| Download URL | sdhelper-1.0.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3203398794e8c26e220fa5309fde273068768f0fc2baa7a37812a46a295da5b1
|
|
BLAKE2b-256 checksum How to use checksums |
8682c8b63bc0793e4eb563662e18fee5745e3bbf4693ad13ffa117ed39a548a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.9.21
|