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

pip install -i https://test.pypi.org/simple/ StreamDiffusionIO

For Developers

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

(Optional) Accelaration with xformers

# For user
pip install -i https://test.pypi.org/simple/ 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 = "runwayml/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.2.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.2-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: StreamDiffusionIO-0.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 5394870a148085fee7fa6c6abfd48cc0aa94a7cb1c29e71f90d94a97516596b0
MD5 7e56e19826110b48d27015ef4b3f82dd
BLAKE2b-256 781a29f52895a696bd279c264f640d4af993e373b47189bfdb9bf85b8f51d1b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for StreamDiffusionIO-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 12b496ac6925ec77823b1ab8882eddd2d270ddcee98415f9f590f2ad2e02755e
MD5 56ddf2bfbde340e94a6fdc00f1f999f3
BLAKE2b-256 921973de91b285579ee4392eefeb94ebc62bb7e67599abedff40d104367d61b4

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