歡迎關注我的CSDN:https://spike.blog.csdn.net/
本文地址:https://spike.blog.csdn.net/article/details/132056980
SDXL 1.0 版本 是 Stable Diffusion 的最新版本,是基于潛在擴散模型的文本到圖像生成技術,能夠根據(jù)輸入的任何文本生成高分辨率、高質(zhì)量、高多樣性的圖像,具有以下特點:
-
更好的成像質(zhì)量:能夠以幾乎任何藝術風格生成清晰、逼真、美觀的圖像,無論是風景、人物、建筑還是動物,都能呈現(xiàn)出細節(jié)和色彩,相比于之前的版本有著巨大的提升。
-
更多的藝術風格:相比于之前的版本,能夠?qū)崿F(xiàn)更多的風格,并且對于每種風格都能駕馭。因此,可以嘗試更多的藝術家名稱和美學,比如梵高、莫奈、達利等,也可以自由創(chuàng)造出想要的風格。
-
更智能、更簡單的語言:只需少量單詞,就能創(chuàng)建復雜、詳細、美觀的圖像。不再需要調(diào)用 “杰作” 等限定詞,來獲得高質(zhì)量圖像。
-
更高的分辨率:基礎分辨率是 1024x1024,相比于之前的版本,可以產(chǎn)生更好的圖像細節(jié),同時處理寬高比的效果更好??梢愿鶕?jù)需求選擇不同的分辨率和寬高比,例如16:9、3:2、4:3等。
-
更大的開放圖像模型:在已知的開源文生圖模型中,SDXL 擁有最大的參數(shù)量,建立在一個創(chuàng)新的架構之上,即由 3.5B 參數(shù)的基礎模型和 6.6B 參數(shù)的精煉器組成。完整模型由一個專家混合管道組成,用于潛在擴散。
SDXL 進行以下優(yōu)化:
-
對于 Stable Diffusion 的U-Net、VAE、CLIP Text Encoder三大組件都做了改進。
- U-Net 增加 Transformer Blocks (自注意力 + 交叉注意力) 來增強特征提取和融合能力;
- VAE 增加條件變分自編碼器來提升潛在空間的表達能力;
- CLIP Text Encoder 增加兩個大小不同的編碼器來提升文本理解和匹配能力。
-
增加單獨基于 Latent 的 Refiner 模型,來提升圖像的精細化程度。Refiner 模型也是一個潛在擴散模型,接收基礎模型生成的圖像 Latent 特征作為輸入,進一步去噪和優(yōu)化,使得最終輸出的圖像更加清晰和銳利。
-
設計了很多訓練 Tricks,包括圖像尺寸條件化策略,圖像裁剪參數(shù)條件化以及多尺度訓練等。這些 Tricks 可以提高模型的泛化能力和穩(wěn)定性,使得模型能夠適應不同的分辨率和寬高比,以及不同的圖像內(nèi)容和風格。
-
預先發(fā)布 SDXL 0.9 測試版本,基于用戶使用體驗和生成圖片的情況,針對性增加數(shù)據(jù)集和使用 RLHF 技術優(yōu)化迭代推出 SDXL 1.0 正式版。RLHF 是一種基于強化學習的圖像質(zhì)量評估技術,可以根據(jù)人類的偏好來調(diào)整模型的參數(shù),使得生成圖像的色彩,對比度,光線以及陰影方面更加符合人類的審美。
1. 升級 WebUI
查看 Stable Diffusion WebUI 的當前版本,以及更新至最新版本,即:
git pull
git diff [your file]
git checkout [your file]
git pull
git tag
git pull origin master
升級之后,在 modules/ui_extensions.py
中修改插件更新源,實現(xiàn)更快查詢,即:
https://ghproxy.com/
stable-diffusion-webui 官網(wǎng) GitHub
當前最新版本的提交,即:
commit 68f336bd994bed5442ad95bad6b6ad5564a5409a
Merge: a3ddf46 50973ec
Author: AUTOMATIC1111 <16777216c@gmail.com>
Date: Thu Jul 27 09:02:22 2023 +0300
Merge branch 'release_candidate'
建議預先下載支持工程,工程較大,建議提前下載,即:
cd repositories
git clone https://ghproxy.com/https://github.com/Stability-AI/generative-models.git
重啟 WebUI,即可。
nohup python -u launch.py --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue > nohup.62.out &
tail -f nohup.62.out
輸出日志,啟動正確,即:
Python 3.8.16 (default, Mar 2 2023, 03:21:46)
[GCC 11.2.0]
Version: v1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Checking roop requirements
Install insightface==0.7.3
Installing sd-webui-roop requirement: insightface==0.7.3
Install onnx==1.14.0
Installing sd-webui-roop requirement: onnx==1.14.0
Install onnxruntime==1.15.0
Installing sd-webui-roop requirement: onnxruntime==1.15.0
Install opencv-python==4.7.0.72
Installing sd-webui-roop requirement: opencv-python==4.7.0.72
Launching Web UI with arguments: --listen --port 9301 --xformers --no-half-vae --enable-insecure-extension-access --theme dark --gradio-queue
[-] ADetailer initialized. version: 23.7.6, num models: 12
dirname: /nfs_baoding/chenlong/workspace_v2/stable_diffusion_webui_docker/localizations
localizations: {'zh-Hans (Stable)': 'extensions/stable-diffusion-webui-localization-zh_Hans/localizations/zh-Hans (Stable).json', 'zh-Hans (Testing)': 'extensions/stable-diffusion-webui-localization-zh_Hans/localizations/zh-Hans (Testing).json'}
2023-08-02 09:27:48,494 - ControlNet - INFO - ControlNet v1.1.233
ControlNet preprocessor location: /nfs_baoding/chenlong/workspace_v2/stable_diffusion_webui_docker/extensions/sd-webui-controlnet/annotator/downloads
2023-08-02 09:27:49,996 - ControlNet - INFO - ControlNet v1.1.233
sd-webui-prompt-all-in-one background API service started successfully.
2023-08-02 09:28:02,472 - roop - INFO - roop v0.0.2
2023-08-02 09:28:02,516 - roop - INFO - roop v0.0.2
Loading weights [ed989d673d] from models/Stable-diffusion/Dreamshaper_7.safetensors
Creating model from config: /configs/v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying attention optimization: xformers... done.
Model loaded in 4.9s (load weights from disk: 0.2s, create model: 0.6s, apply weights to model: 1.3s, apply half(): 0.6s, move model to device: 1.4s, load textual inversion embeddings: 0.6s).
Running on local URL: http://0.0.0.0:9301
To create a public link, set `share=True` in `launch()`.
Startup time: 657.7s (launcher: 356.6s, import torch: 105.7s, import gradio: 22.1s, setup paths: 27.5s, import ldm: 0.3s, other imports: 21.2s, opts onchange: 0.2s, setup codeformer: 1.7s, list SD models: 0.5s, load scripts: 92.9s, load upscalers: 0.2s, initialize extra networks: 0.2s, create ui: 7.8s, gradio launch: 18.2s, app_started_callback: 2.5s).
2. 配置環(huán)境
安裝 Refiner 支持插件,參考,即:
cd extensions
git clone https://ghproxy.com/https://github.com/wcde/sd-webui-refiner.git
最新插件源,即:
https://gitcode.net/rubble7343/sd-webui-extensions/raw/master/index.json
準備 SDXL 模型,建議下載地址 LiblibAI,即:
- Stable Diffusion SDXL 正式版
- Stable Diffusion SDXL refiner
- SDXL_offset_example-lora
即
cd models/Stable-diffusion
# Stable Diffusion SDXL 正式版
wget https://liblibai-online.liblibai.com/models/31e35c80fc4829d14f90153f4c74cd59c90b779f6afe05a74cd6120b893f7e5b.safetensors?attname=Stable%20Diffusion%20SDXL%20%E6%AD%A3%E5%BC%8F%E7%89%88_sdxl_1.0.safetensors -O SDXL_1.0.safetensors
# Stable Diffusion SDXL refiner
wget https://liblibai-online.liblibai.com/models/7440042bbdc8a24813002c09b6b69b64dc90fded4472613437b7f55f9b7d9c5f.safetensors?attname=Stable%20Diffusion%20SDXL%20refiner_1.0%20refiner.safetensors -O SDXL_refiner_1.0.safetensors
# DreamShaper XL1.0 alpha2
wget "https://liblibai-online.liblibai.com/models/0f1b80cfe81b9c3bde7fdcbf6898897b2811b27be1df684583c3d85cbc9b1fa4.safetensors?attname=DreamShaper%20XL1.0_alpha2%20(xl1.0).safetensors" -O DreamShaper_XL1.0_alpha2.safetensors
cd models/Lora
# SDXL_offset_example-lora
wget https://liblibai-online.liblibai.com/web/model/4852686128f953d0277d0793e2f0335352f96a919c9c16a09787d77f55cbdf6f.safetensors?attname=SDXL_offset_example-lora_1.0.safetensors -O SDXL_offset_lora_1.0.safetensors
顯存占用,峰值大約 25G 左右,即:
3. 測試圖像
測試:
photo, 8k portrait of beautiful cyborg with brown hair, intricate, elegant, highly detailed, majestic, digital photography, art by artgerm and ruan jia and greg rutkowski surreal painting gold butterfly filigree, broken glass, (masterpiece, sidelighting, finely detailed beautiful eyes: 1.2), hdr, realistic, high definition
Steps: 40, Sampler: DPM++ 2M SDE Karras, CFG scale: 8, Seed: 17748028598468, Face restoration: GFPGAN, Size: 1024x1024, Model hash: 31e35c80fc, Model: SDXL_1.0, Clip skip: 2, Version: v1.5.1
seed:17748028598468
注意:目前不加負向提示詞,且不要使用高清修復,效果很差。
面部修復建議使用 GFPGAN 算法,即:
原版模型與GFPGAN的效果差異,即:
DreamShaper的效果,額外添加負向提示詞 NSFW,關閉 Refiner (是否開啟差別不大),即:
photo, 8k portrait of beautiful cyborg with brown hair, intricate, elegant, highly detailed, majestic, digital photography, art by artgerm and ruan jia and greg rutkowski surreal painting gold butterfly filigree, broken glass, (masterpiece, sidelighting, finely detailed beautiful eyes: 1.2), hdr, realistic, high definition
Negative prompt: nsfw,
Steps: 40, Sampler: DPM++ 2M SDE Karras, CFG scale: 8, Seed: 17748028598468, Face restoration: GFPGAN, Size: 1024x1024, Model hash: 0f1b80cfe8, Model: DreamShaper_XL1.0_alpha2, Clip skip: 2, Version: v1.5.1文章來源:http://www.zghlxwxcb.cn/news/detail-627255.html
圖像效果:文章來源地址http://www.zghlxwxcb.cn/news/detail-627255.html
到了這里,關于Stable Diffusion - Stable Diffusion WebUI 支持 SDXL 1.0 模型的環(huán)境配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!