1. 依赖安装
sh
# git : 用于下载源码
https://git-scm.com/downloads/win
# Python 作为基础编译环境
https://www.python.org/downloads/
# Nvidia 驱动,用于编译使用GPU显卡硬件
https://www.nvidia.com/en-us/drivers/
# Cuda 用于编译运行GPU的程序软件
https://developer.nvidia.com/cuda-toolkit-archive
# cuDNN 用于深度神经网络相关大模型的GPU加速库
https://developer.nvidia.com/cudnn-downloads
# Pytorch 用于构建和训练深度学习模型
# pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128
https://pytorch.org/get-started/locally/


2. Stable Diffusion安装
bash
# 下载本地网页
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
# 下载模型 Stable-diffusion
https://huggingface.co/stabilityai/stable-diffusion-3.5-large
# 模型放入:stable-diffusion-webui\models\Stable-diffusion
# stable-diffusion-webui 目录下双击 webui.bat 启动
3. 使用体验
浏览器打开 http://127.0.0.1:7860
3.1 基础使用
-
正向提示词:描述你想要的画面,如:(best quality), 1girl, in a garden, sunlight, flowers, smiling
-
反向提示词:排除不想要的内容,如:(worst quality, low quality), deformed hands, extra fingers
-
参数设置:
- 采样步数(Steps):20~30
- 图片尺寸(Width/Height):512x512 或 768x768
- 生成数量(Batch count):1
-
点击"Generate"生成, 图片保存在 outputs\txt2img-images 文件夹。
3.2 进阶调试
- 如果显存不足(报错 CUDA out of memory):
- 降低图片尺寸(如 512x512 → 480x640)
- 在启动器 → "高级选项" → 勾选 xformers 和 低显存模式
- 使用优化模型(如 RealisticVision)
- 在启动命令中添加 --medvram 参数:python launch.py --medvram
- 安装插件
在 WebUI 的 Extensions 选项卡 → Available → 点击"Load from URL" → 输入插件 GitHub 地址 → 安装:- ControlNet:控制人物姿势/构图
- Additional Networks:融合多个模型风格
- 中文汉化
启动器 → "扩展" → 搜索 zh_CN → 安装汉化包 → 重启 WebUI。