File size: 1,890 Bytes
0ed6b0e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # 推理 WebUI
DiffSynth-Studio 提供推理 WebUI,帮助开发者快速验证模型效果。
> 现阶段的推理 WebUI 功能还不完善,我们会在未来优化交互逻辑。
> 推理 WebUI 是面向开发者的调试工具,而非面向创作者的设计工具。如需功能更丰富、交互更友好的创作体验,推荐使用魔搭社区 [AIGC 专区](https://modelscope.cn/aigc/home)(中国用户)或 [Civision 专区](https://modelscope.ai/civision/home)(非中国用户)。
## 启动推理 WebUI
推理 WebUI 基于 [`Streamlit`](https://streamlit.io/) 构建。除 DiffSynth-Studio 外还需安装 `Streamlit`:
```shell
git clone https://github.com/modelscope/DiffSynth-Studio.git
cd DiffSynth-Studio
pip install -e .
pip install streamlit
```
启动命令:
```shell
streamlit run examples/dev_tools/webui.py --server.fileWatcherType none
```
## 工作原理
推理 WebUI 作为独立工具,通过解析 Pipeline 的 `from_pretrained` 和 `__call__` 方法中的参数类型标注,动态生成对应 UI 控件。因此,界面交互逻辑与代码调用逻辑完全一致,可视为 DiffSynth-Studio 代码的可视化入口。
以 `diffsynth.pipelines.z_image` 中的 `ZImagePipeline.__call__` 为例:
```python
@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_id`、`origin_file_pattern` 等模型信息,简化配置流程;
- `vram_limit`、`tokenizer_config`、`lora` 等参数无法通过代码解析获取,需手动填写。
|