---python3.11
https://abc.htmltoo.com/thread-46907.htm
---Conda
https://abc.htmltoo.com/thread-46888.htm
---pip3
https://abc.htmltoo.com/thread-46890.htm
---StableDiffusion 是一种基于文本提示生成图像的工具
https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd /data/site/htmltoo.opt/
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui
apt install wget git python3.11-venv libgl1 libglib2.0-0 -y
python3 -m venv venv
vim /data/site/htmltoo.opt/stable-diffusion-webui/webui.sh
/bin/python -> /bin/python3
pip install -> pip3 install
pip3 install xformers -U --break-system-packages
conda create -n diffusionenv python=3.11
conda activate diffusionenv
apt install -y rustc cargo
pip3 install -r requirements.txt
-停用环境
conda deactivate
-Windows
./webui.bat --api --listen
-Linux
./webui.sh --api --listen
nohup sudo -u admin ./webui.sh --api --listen > webui.log 2>&1 &
nohup sudo -u admin ./webui.sh --api --listen --lowvram --api-auth ihunter:wdq54321 > webui.log 2>&1 &
nohup sudo -u admin ./webui.sh --api --listen --cors-allow-origins "*" --lowvram --api-auth ihunter:wdq54321 > webui.log 2>&1 &
http://192.168.1.6:7860
-运行时可以使用一些命令参数
--xformers 使用xformers库。极大地改善了内存消耗和速度
--force-enable-xformers 无论程序是否认为您可以运行它,都启用 xformers。不要报告你运行它的错误
--opt-split-attention 优化显着减少了内存使用,几乎没有成本(一些报告改进了性能)。黑魔法。默认情况下torch.cuda,包括 NVidia 和 AMD 卡
--lowvram 对上面更彻底的优化,将 unet 拆分成多个模块
-汉化
https://github.com/journey-ad/sd-webui-bilingual-localization
git clone https://github.com/journey-ad/sd-webui-bilingual-localization extensions/sd-webui-bilingual-localization
在Settings - Bilingual Localization中选择要启用的本地化文件,
依次点击Apply settings和Reload UI按钮
-准备模型
-huggingface - 拉取模型大文件
https://abc.htmltoo.com/thread-46886.htm
https://huggingface.co/JamesFlare/pastel-mix
cd /data/site/htmltoo.opt/stable-diffusion-webui/models
git clone https://huggingface.co/JamesFlare/pastel-mix
git clone https://hdongquane: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@huggingface.co/stabilityai/stable-diffusion-3-medium
git clone https://hdongquane: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@huggingface.co/black-forest-labs/FLUX.1-dev
git clone https://huggingface.co/runwayml/stable-diffusion-v1-5
-获取模型名称
http://your_id:port/sdapi/v1/sd-models
http://192.168.1.6:7860/sdapi/v1/sd-models
[
{
"title": "pastel-mix/pastelmix-better-vae-fp32.ckpt [943a810f75]",
"model_name": "pastel-mix_pastelmix-better-vae-fp32",
"hash": "943a810f75",
"sha256": "943a810f7538b32f9d81dc5adea3792c07219964c8a8734565931fcec90d762d",
"filename": "/home/takatost/stable-diffusion-webui/models/Stable-diffusion/pastel-mix/pastelmix-better-vae-fp32.ckpt",
"config": null
},
]model_name 就是我们需要的,这个例子中是 pastel-mix_pastelmix-better-vae-fp32
-在 Dify 中集成 Stable Diffusion
在 工具 > StableDiffusion > 去认证 中填写认证和模型配置
---SearXNG 是一个免费的互联网元搜索引擎,整合了各种搜索服务的结果。用户不会被跟踪,也不会被分析。
docker run -d --name searxng --hostname searxng --restart=always -p 9501:8080 --privileged=true --user=root --ulimit nofile=262144:262144 --network mgr --ip 172.18.0.51 -v /data/file:/data/file/ -v "/data/site/docker/data/searxng:/etc/searxng" -e "BASE_URL=http://0.0.0.0:8080/" -e "INSTANCE_NAME=searxng" searxng/searxng
-settings.yml
vim /data/site/docker/data/searxng/settings.yml
limiter: false
...
# remove format to deny access, use lower case.
# formats: [html, csv, json, rss]
formats:
- html
- json # <-- 添加这一行
-在 Dify 中集成 SearXNG
在 工具 > SearXNG > 去认证 中填写访问地址
http://g.htmltoo.com:9501
-插件列表
vim modules/ui_extensions.py
extensions_index_url = os.environ.get('WEBUI_EXTENSIONS_INDEX', "https://gitgud.io/AUTOMATIC1111/stable-diffusion-webui/-/wikis/Extensions-index.md")
...
def install_extension_from_url(dirname, url, branch_name=None):
url = "https://mirror.ghproxy.com/" + url
...
shutil.rmtree(tmpdir, True)
if not branch_name:
url = url.replace('https://github.com', 'https://kkgithub.com')重启,Load from
# 镜像替换
https://huggingface.co -> https://hf-mirror.com
vim venv/lib/python3.11/site-packages/huggingface_hub/constants.py
HUGGINGFACE_CO_URL_HOME = "https://hf-mirror.com/"
...
_HF_DEFAULT_ENDPOINT = "https://hf-mirror.com"
# 加载有效的插件清单
https://www.ipaddress.com/ip-lookup ---> raw.githubusercontent.com
vim /etc/hosts
C:\Windows\System32\drivers\etc\hosts
185.199.111.133 raw.githubusercontent.com
185.199.109.133 raw.githubusercontent.com
插件清单出现后,可以输入关键字进行筛选,点击右边的Install按钮即可安装该插件
-
1) 中文翻译插件(简体中文汉化包):
https://github.com/hanamizuki-ai/stable-diffusion-webui-localization-zh_Hans.git
2)ControlNet(人体姿势、姿态精准控制):
https://github.com/Mikubill/sd-webui-controlnet.git
3)AnimateDiff(动漫生成):
https://github.com/continue-revolution/sd-webui-animatediff.git
4)Inpaint Anything(局部重绘):
https://github.com/Uminosachi/sd-webui-inpaint-anything.git
5)Waifu Diffison 1.4 Tagger(提示词反推):
https://github.com/picobyte/stable-diffusion-webui-wd14-tagger.git
-
模型存放文件夹规划(仅供参考)
为方便维护,建议按模型名称建立文件夹存放模型
# stable-diffusion-webui\OpenAI\clip-vit-large-patch14
cd /data/site/htmltoo.opt/stable-diffusion-webui/
git clone https://hf-mirror.com/openai/clip-vit-large-patch14 OpenAI/clip-vit-large-patch14
#
cd /data/site/htmltoo.opt/stable-diffusion-webui
git clone https://github.com/hanamizuki-ai/stable-diffusion-webui-localization-zh_Hans.git
---huggingface-hub, 无错
pip3 install huggingface-hub==0.22.2 --break-system-packages
vim /data/site/htmltoo.opt/stable-diffusion-webui/requirements.txt
GitPython
Pillow
accelerate
blendmodes
clean-fid
diskcache
einops
facexlib
fastapi
inflection
jsonmerge
kornia
lark
numpy
omegaconf
open-clip-torch
piexif
protobuf==3.20.0
psutil
pytorch_lightning
requests
resize-right
safetensors
scikit-image
tomesd
torch
torchdiffeq
torchsde
transformers==4.30.2
pillow-avif-plugin==1.4.3
aiofiles==23.2.1
gradio