Diffusers Streamlit

Super simple MCP server and Streamlit app for playing with diffusers like Z-image and Stable Diffusion

LLM Mart 0 views 48 listing impressions

A super minimal Streamlit app for playing around with open image generation models: Z-Image Turbo, FLUX.2 [klein] and Stable Diffusion XL 1.0. (It started out as a Stable Diffusion 2 app.)

Includes:

  • Text to image (txt2img): Z-Image Turbo, FLUX.2 [klein] 4B, XL 1.0, SDXL Turbo
  • Image to image (img2img): Z-Image Turbo, FLUX.2 [klein] 4B, XL 1.0 refiner
  • Inpainting: Z-Image Turbo, FLUX.2 [klein] 4B, XL 1.0
  • Negative prompt input for all methods (ignored by the models that don't support it, e.g. FLUX.2).

Uses Z-Image Turbo by default. The steps and guidance sliders start at sensible values for each model (the turbo/distilled models want few steps, around 2-9, and guidance 0; FLUX.2 ignores guidance), the txt2img width and height start at the model's native size (1024x1024, 512x512 for SDXL Turbo), and the app shows a short hint for each.

FLUX.2 [klein] works like an image editor in img2img and inpainting: it uses the input image as a reference, so the prompt should describe the change ("replace the dog with a cat"), and the img2img strength is ignored.

Note: Stable Diffusion 2.0/2.1 were dropped because Stability AI removed those repositories from Hugging Face. Stable Diffusion 3.5 is left out because its repositories are gated behind a licence agreement.

Models and licences

Model Hugging Face repo Licence
Z-Image Turbo Tongyi-MAI/Z-Image-Turbo Apache 2.0
FLUX.2 [klein] 4B black-forest-labs/FLUX.2-klein-4B Apache 2.0
XL 1.0, XL 1.0 refiner stabilityai/stable-diffusion-xl-base-1.0, stabilityai/stable-diffusion-xl-refiner-1.0 CreativeML OpenRAIL++-M
SDXL Turbo stabilityai/sdxl-turbo Stability AI Non-Commercial Research Community License (sai-nc-community)

Requirements

  • Z-Image Turbo needs a 16GB GPU (with CPU offload, ~12GB peak), FLUX.2 [klein] 4B ~8GB with CPU offload, and the XL models run on 8GB.
  • Make sure you have the Nvidia drivers and all that.
  • The newer models are bigger. On a 16GB GPU (RTX 4070 Ti SUPER), Z-Image Turbo and FLUX.2 [klein] both need CPU offload, which the app turns on automatically for them on GPUs with less than 24GB; it brings peak GPU memory down to roughly 12GB for Z-Image Turbo and 8GB for FLUX.2 [klein] 4B. You also need plenty of system RAM for the offloaded parts (32GB+): with CPU offload the whole model lives in host RAM (~20GB for Z-Image Turbo). Switching mode (txt2img, img2img, inpaint) on the same model reuses the loaded model; switching model unloads it first. Unloading (the sidebar button, or a model switch) returns the memory to the OS on Linux. Memory is also trimmed after each image, so RSS between images stays near the model's size. The XL models run without offload on 16GB.
  • Disk: Z-Image Turbo is roughly 33GB and FLUX.2 [klein] 4B roughly 16GB.

Observations based on my own machine:

  • Using Ubuntu 22.04 with an RTX 2070 GPU (8GB memory)
  • Using Python 3.10 in a fresh conda environment.
  • The 2.1 768 model works out of the box with 768x768 images.
  • For the XL 1.0 model, I personally have to use CPU offloading. Model CPU offloading is enough so it doesn't slow down inference so much.
    • With CPU offloading, I have been able to generate 1024x1024 images using the XL model.

Install & Run

Requires Python 3.12 (pinned in .python-version and the version it's tested with; requires-python allows newer, which may work). Dependencies are managed with uv (pyproject.toml + uv.lock):

uv sync
uv run streamlit run main.py

uv sync creates a .venv with Python 3.12 (uv downloads it if needed).

From the project's README.

Related servers

Vintage analog TV/VHS image tool for macOS: ntsc-rs signal emulation + RetroArch CRT shaders (librashader), glued together with SwiftUI/Metal

47 views

Read and write RAGE Package Format archives

28 views

ゆっくりムービーメーカー4のMCPです。将来的にはゆっくり動画を全自動で作れるようにしたいです。

20 views

See how ChatGPT, Claude, Gemini and Perplexity read any website. Scored out of 100.

19 views