推理 WebUI

DiffSynth-Studio 提供推理 WebUI,帮助开发者快速验证模型效果。

推理 WebUI 是面向开发者的调试工具,而非面向创作者的设计工具。如需功能更丰富、交互更友好的创作体验,推荐使用魔搭社区 AIGC 专区(中国用户)或 Civision 专区(非中国用户)。

启动推理 WebUI

推理 WebUI 基于 Streamlit 构建。建议以 [all] 模式安装 DiffSynth-Studio:

git clone https://github.com/modelscope/DiffSynth-Studio.git
cd DiffSynth-Studio
pip install -e .[all]

启动命令:

streamlit run examples/dev_tools/webui.py --server.fileWatcherType none

工作原理

推理 WebUI 作为独立工具,通过解析 Pipeline 的 from_pretrained__call__ 方法中的参数类型标注,动态生成对应 UI 控件。因此,界面交互逻辑与代码调用逻辑完全一致,可视为 DiffSynth-Studio 代码的可视化入口。

diffsynth.pipelines.z_image 中的 ZImagePipeline.__call__ 为例:

@torch.no_grad()
def __call__(
    self,
    # Prompt
    prompt: str = "",
    negative_prompt: str = "",
    cfg_scale: float = 1.0,
    # Image
    input_image: Image.Image = None,
    denoising_strength: float = 1.0,
    ...
)

WebUI 解析后将自动渲染为如下界面:

使用提示

  • 支持从 ./examples 样例代码中自动加载 model_idorigin_file_pattern 等模型信息,简化配置流程;

  • vram_limittokenizer_configlora 等参数无法通过代码解析获取,需手动填写。