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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sdhelper-0.1.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.10.6

File hashes

Hashes for sdhelper-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b68127cee04b3d72a24e61119fd0065df9e29baf6fd77d0068141e96fededf52
MD5 5e2fb1718ee02d0bd55eddc572cd2249
BLAKE2b-256 c7090dbcf29331e54337bd9296a8bcfa277a4b10474b61ac99384079610e130c

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