Skip to main content

A lightweight pipeline using StreamDiffusion, aimming to support streaming IO operations.

Project description

StreamDiiffusionIO

StreamDiiffusionIO's pipeline design is based on StreamDiffusion, but especially allows using different text prompt on different samples in the denoising batch respectively but consistently.

A natural application of StreamDiiffusionIO is to render text streams into image streams, as in Streaming Kanji.

Features

  • Streaming with LDM
  • Streaming with LCM

Installation

Create the Env

conda create -n StreamDiffusionIO python=3.10
conda activate StreamDiffusionIO

Install StreamDiffusionIO

For Users

ppip install StreamDiffusionIO

For Developers

git clone https://github.com/AgainstEntropy/StreamDiffusionIO.git
pip install --editable ./StreamDiffusionIO/

(Optional) Accelaration with xformers

# For user
pip install StreamDiffusionIO[xformers]

# For dev
pip install -e '.[xformers]'

Quick Start

StreamDiffusionIO is very similar to StreamDiffusion, but even more lightweight. One can use the pipeline with only a few lines of codes.

import torch
from StreamDiffusionIO import LatentConsistencyModelStreamIO

device = "cuda" if torch.cuda.is_available() else "cpu"

model_id_or_path = "/path/to/stable-diffusion-v1-5"
lora_path = "/path/to/lora/pytorch_lora_weights.safetensors"
lcm_lora_path = "/path/to/lcm-lora/pytorch_lora_weights.safetensors"

stream = LatentConsistencyModelStreamIO(
    model_id_or_path=model_id_or_path,
    lcm_lora_path=lcm_lora_path,
    lora_dict={lora_path: 1},
    resolution=128,
    device=device,
)

text = "Today I saw a beautiful sunset and it made me feel so happy."
prompt_list = text.split()

# to simulate a text stream
for prompt in prompt_list:
    image, text = stream(prompt)  # stream returns None during warmup
    if image is not None:
        print(text)
        display(image)

# Continue to display the remaining images in the stream 
while True:
    image, text = stream(prompt)
    print(text)
    display(image)
    if stream.stop():
        break

Note the text returnded from the stream is the corresponding text prompt used to generating the returned image. Please follow the Jupyter notebooks in examples to see details.

Acknowledgements & References

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

StreamDiffusionIO-0.0.3.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

StreamDiffusionIO-0.0.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file StreamDiffusionIO-0.0.3.tar.gz.

File metadata

  • Download URL: StreamDiffusionIO-0.0.3.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.13

File hashes

Hashes for StreamDiffusionIO-0.0.3.tar.gz
Algorithm Hash digest
SHA256 a3ada834b6a4c46b229b2af54101bd35c817c009aa41958a25e767380f4fd18f
MD5 9a1b8e87d35768f131c3381299ef7fb7
BLAKE2b-256 a00cb2e6de312bd142c32c12cf4b300f6f54af444e39ea6db5c36087529daba3

See more details on using hashes here.

File details

Details for the file StreamDiffusionIO-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for StreamDiffusionIO-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9280ad4c96b55b8c9bb6a8cbf7381809555cbbf3a8e8371cc1914e8a0576407e
MD5 e7041037903f45d77f0dbebeadc11ede
BLAKE2b-256 fed5471f3cd34bd9ceee5b07379e4f1929507b42d1f5391ba8d429ea222f6440

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