Skip to main content

A helper package for working with stable diffusion models.

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdhelper-1.0.0.tar.gz (765.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdhelper-1.0.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file sdhelper-1.0.0.tar.gz.

File metadata

  • Download URL: sdhelper-1.0.0.tar.gz
  • Upload date:
  • Size: 765.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for sdhelper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f5fba9914a5a199fa0fd79a6daf2d6e3b0e369bd4b83f75304fff2d866ae1150
MD5 1a47d02fe6e0db4bc19e0bf8ddeddbbf
BLAKE2b-256 fb8ab6c4d7ba1e8c383ffacff439dea460ab563c0a946fa160319ae269a7ec61

See more details on using hashes here.

File details

Details for the file sdhelper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: sdhelper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for sdhelper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3203398794e8c26e220fa5309fde273068768f0fc2baa7a37812a46a295da5b1
MD5 dde16cea967f491381968ee9a358199f
BLAKE2b-256 8682c8b63bc0793e4eb563662e18fee5745e3bbf4693ad13ffa117ed39a548a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page