stable diffusion webui ubuntu 安装和教程

日作诗歌三千首 2024-06-15 12:03:03 阅读 63

0.环境:

cuda:11.8

gpu:p40

torch:2.2.0+cu118

python:3.10.12

1.git clone  下来

GitHub - AUTOMATIC1111/stable-diffusion-webui: Stable Diffusion web UIStable Diffusion web UI. Contribute to AUTOMATIC1111/stable-diffusion-webui development by creating an account on GitHub.

icon-default.png?t=N7T8

https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

2.conda create -n sd python=3.10.12

3. cd stable-diffusion-webui & bash webui.sh

出现错误

(1)RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check

解决方法:GPU用不了,可能是驱动的问题,可以在stable-diffusion-webui/modules/launch_utils.py

317行:prepare_enviroment():

修改torch和torchvision版本

(2)Command: "git" clone --config core.filemode=false "https://github.com/Stability-AI/generative-models.git" "............/stable-diffusion-webui/repositories/generative-models"

解决方法:服务器无法连接github服务器,先在本地下载git clone https://github.com/Stability-AI/generative-models.git,然后放入stable-diffusion-webui/repositories/generative-models/文件中

(3)Installing requirements卡住不动:耐心等待,在pip装相关库。

(4)Downloading: "https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors" to stable-diffusion-webui/models/Stable-diffusion/v1-5-pruned-emaonly.safetensors:可能没有科学上网下不了,必须科学上网,直接把https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.safetensors下载,然后放入相应的位置;

(5).openai/clip-vit-large-patch14下载不了:

直接在https://huggingface.co/openai/clip-vit-large-patch14/tree/main

下载,然后在stable-diffusion-webui,mkdir openai/clip-vit-large-patch14文件,把huggingface下载的文件放进入

(6) 安装xformer要注意版本,不能让其重装torch,不然,整个环境可能会崩掉:

 pip3 install -U xformers==0.0.24 --index-url https://download.pytorch.org/whl/cu118

4.安装完成后:source venv/bin/activate 激活python虚拟环境,然后bash webui.sh --xformers

5.使用教程

(1).prompt相关,可以参考以下教程:

Stable Diffusion 关键词 tag 语法如何使用? - 知乎

(2).sd1.5和sdxl区别:

深入浅出完整解析Stable Diffusion(SD)核心基础知识 - 知乎

sdxl是两阶段生成器,加了个refiner,效果比sd1.5好,并且c站几乎把sdxl作为base model

以下为base model和refiner模型链接:

https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/tree/main

https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/tree/main

SDXL Base模型由U-Net、VAE以及CLIP Text Encoder(两个)三个模块组成,在FP16精度下Base模型大小6.94G(FP32:13.88G),其中U-Net占5.14G、VAE模型占167M以及两个CLIP Text Encoder一大一小(OpenCLIP ViT-bigG和OpenAI CLIP ViT-L)分别是1.39G和246M。

SDXL Refiner模型同样由U-Net、VAE和CLIP Text Encoder(一个)三个模块组成,在FP16精度下Refiner模型大小6.08G,其中U-Net占4.52G、VAE模型占167M(与Base模型共用)以及CLIP Text Encoder模型(OpenCLIP ViT-bigG)大小1.39G(与Base模型共用)。

(3) .stable diffusion webui 四种模型:

Stable Diffusion——Textual Inversion(TI)文本翻转和 Embedding 嵌入 - 知乎

textual inversion ----- embedding modelhypernetworkloradreambooth

 (4).插件:

采用代理下载:

stable diffusion webui国内无法安装扩展插件或者速度慢的解决 - 哔哩哔哩

插件会自动下载放在stable-diffusion-webui/extensions,重启webui.sh

(5)修改 ModelScope 默认缓存路径:

可能遇到home/.cache空间不够:

os.environ['MODELSCOPE_CACHE']='models/models_cache/' 

(6)stable diffusion webui controlnet官方下载:

GitHub - Mikubill/sd-webui-controlnet: WebUI extension for ControlNet

(7)prompt:

场景模板 (Scene Templates)

自然风光 (Natural Scenery)

山脉 (Mountain Range)

海滩 (Beach)

乡村 (Countryside)

城市景观 (Urban Landscape)

现代都市 (Modern City)

历史古城 (Historic Town)

工业区 (Industrial Area)

室内环境 (Indoor Environment)

家居 (Home Interior)

办公空间 (Office Space)

餐厅 (Restaurant)

光线模板 (Lighting Templates)

自然光线 (Natural Light)

晨光 (Morning Light)

午后阳光 (Afternoon Sunlight)

黄昏 (Dusk)

人造光线 (Artificial Light)

室内照明 (Indoor Lighting)

城市霓虹 (Urban Neon)

镜头模板 (Lens Templates)

视角 (Viewpoint)

鸟瞰 (Bird's Eye View)

眼平视角 (Eye Level View)

低角度 (Low Angle)

焦距 (Focal Length)

广角镜头 (Wide-Angle Lens)

标准镜头 (Standard Lens)

长焦镜头 (Telephoto Lens)

情感模板 (Emotion Templates)

快乐 (Happiness)

明亮的色彩 (Bright Colors)

活力的场景 (Vibrant Scene)

笑容的人物 (Smiling Figures)

悲伤 (Sadness)

阴郁的色调 (Gloomy Tones)

孤独的场景 (Lonely Scene)

沉思的表情 (Contemplative Expression)

神秘 (Mystery)

暗色调 (Dark Tones)

阴影 (Shadows)

未知的环境 (Unfamiliar Environment)



声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。