1. 依賴安裝
文件打包下載地址(Stable Diffusion)
# 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安裝
# 下載本地網頁
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. 使用體驗
# 啟動程序
webui.bat 或者 python webui.py
# 瀏覽器打開
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。