home/ atoms/ streamdiffusion-wrapper-vs-raw-api

StreamDiffusionWrapper provides a high-level production interface; the raw StreamDiffusion class gives full control

The repo provides two levels of API. StreamDiffusion (in pipeline.py) is the low-level class: it expects a pre-loaded StableDiffusionPipeline, manages the latent buffer and scheduler directly, and exposes prepare(), __call__(), encode_image(), decode_image(). StreamDiffusionWrapper (in utils/wrapper.py) is the batteries-included wrapper: it handles model loading (local or HuggingFace), LCM-LoRA fusion, TinyVAE swap, acceleration, warmup, safety checker, and mode validation. Most example scripts use the wrapper. The raw class is appropriate when integrating into an existing diffusion pipeline or when custom model loading logic is needed. The wrapper’s stream attribute exposes the underlying StreamDiffusion object for direct access.

Examples

# Raw API:
pipe = StableDiffusionPipeline.from_pretrained('KBlueLeaf/kohaku-v2.1').to('cuda', torch.float16)
stream = StreamDiffusion(pipe, t_index_list=[32,45])
stream.load_lcm_lora(); stream.fuse_lora()
stream.prepare('my prompt')

# Wrapper:
wrapper = StreamDiffusionWrapper(model_id_or_path='KBlueLeaf/kohaku-v2.1', t_index_list=[32,45])
wrapper.prepare('my prompt')

Assessment

List three decisions the wrapper makes automatically that you must handle manually with the raw StreamDiffusion class.

“model_id_or_path : str The model id or path to load.”
corpus · streamdiffusion-pipeline-for-real-time-interactive-image-gen · chunk 61