部署与运行
https://hub.docker.com/r/siutin/stable-diffusion-webui-docker
mkdir -p /MY-DATA-DIR && cd /MY-DATA-DIR
mkdir models outputs
sudo chown 10000:$UID -R models outputs
sudo chmod 775 -R models outputs
docker run -it --name sdw --gpus all -p 7860:7860 --network host \
-v $(pwd)/models:/app/stable-diffusion-webui/models \
-v $(pwd)/outputs:/app/stable-diffusion-webui/outputs \
--rm siutin/stable-diffusion-webui-docker:latest-cuda \
bash webui.sh --share
https://github.com/AbdBarho/stable-diffusion-webui-docker/wiki/Setup
docker compose --profile download up --build
# wait until its done, then:
docker compose --profile [ui] up --build
# where [ui] is one of: invoke | auto | auto-cpu | comfy | comfy-cpu
历史文章
stable diffusion 参数解析大全,一文掌握高质量生成。
谈及AIGC,最近最火的工具莫过于stable diffusion和midjourney。相较于midjourney,stable diffusion因其更可本地部署,以及开源的特性,吸引了较大基数的用户。通过各类提示词以及参数,叠加上不通的模型,得到了不同风格的结果。不少人戏称其为抽卡,随机性意味十足。在正式开始前,不得不说:这类参数搜寻的工作,也正是stable diffusion火起来的原因之一。因为这类工作,没有明确的死板的过程,充满了随机性并附加了一定的可控性。嗯,没错,远古时打猎也是如此。
对于一个数据挖掘工程师来说,也就是业内自嘲的调参工程师,不得不说这题我会。参数搜索与分享固然有用,但是仅仅调参+调包,是难以接受的。而近期流行的stable diffusion,又偏偏暴露了很多参数给用户。很多人凭借seed撞大运,抽到了想要的图片。
本文着重介绍各种调参页面中的参数含义,以及可能的原理。以及我们的调整是如何影响模型的。并尝试给出一些参数建议,并阐明为何这个参数更合适,而不是别的参数。部分参数的理解需要一些基本的模型原理介绍。至于更多的模型原理,不在此展开介绍,已经有很多同类文章了。如有需要还请移步搜索 Stable Diffusion 原理。此外,本文不对安装和操作次序做详细介绍。
有更多想法欢迎联系我。联系方式见aboutme。
共性参数
基本概念
通过文本,向图片空间扩散,得到目标图。
提示词 Prompt and Negative Prompt
顾名思义,你想要啥结果,就用英语描绘出来。不想出现的结果就在负面提示里面描述。
负面词的作用原理,是过滤,还是啥?如何实现的呢?
如果英语说不溜,可以考虑任何一个翻译软件/chatgpt进行中译英;或者用看图说话模型,生成参考图片的描述,再进行微调。
近义词对于模型的影响有限,在文本映射中,相似文本具备相似的空间向量。但是也有一定的扰动作用。
这里的图片采样是在干啥,什么是图片采样
https://stable-diffusion-art.com/samplers/
采样步骤 Sampling steps
某些软件里称之为推理步骤。
图片的质量会随着这个数字的变大而变好,随后边际效益递减,参数增大时间变长,但改进有限,最后过度。
对于DPM 采样器,20-25步可取得较好结果。
采样器 Sampler
待补充:各类采样器对比
Different samplers can converge at different steps and may result different visual styles.
Euler A is known to generate more “dreamy” images
while DPM++ 2M Karras can generate high quality images in no more than 30 steps.
长宽
顾名思义,想要生成图片的长宽。大部分软件默认为512x512,是因为Stable Diffusion有在该尺寸上做过微调。
为何能生成任意尺寸的图片?
https://stable-diffusion-art.com/how-stable-diffusion-work/
Hi, the image size is reflected in the size of the latent image tensor. Eg. the size of the latent image is 4x64x64 for a 512×512 image but is 4x96x64 for a 768×512 image. The noise predictor U-Net can consume latent states of different sizes, much like CNN for images.
CFG Scale / Guidance Scale
Indicates how much the image should resemble the prompt.
Low values produce more varied results, while excessively high ones may result in image artifacts such as posterization.
Values between 7 and 10 are usually good choices, but they affect differently to different models.
Feel free to experiment!
这段话是关于使用AI生成图像的时候,要如何设置生成结果的“相似度”参数。在这里,“相似度”是指生成的图像与给定的提示(prompt)之间的相似程度。
具体来说,如果你将相似度参数设置为较低的值,生成结果会更加多样化,但可能会出现图像色彩的分层现象(posterization)等问题。https://svi.nl/PosterizationArtifacts
相反,如果你将相似度参数设置为过高的值,生成结果可能会过于接近给定的提示,导致缺乏创造性。
作者建议将相似度参数设置在7到10之间,这通常可以得到较好的生成结果,但不同的模型对相似度参数的影响可能会有所不同。因此,建议根据具体情况进行实验和调整。
Text guidance
How “literally” the text input should be treated. Higher would be more faithful to the text while lower would have more artistic liberty.
这个参数描述了模型在处理文本输入时,对文本的“严格程度”的处理方式。设置较高的值将更忠实地呈现文本的含义,而设置较低的值将更具有艺术性的自由度。
具体来说,如果将该参数设置为较高的值,模型将尽可能地遵循输入文本的字面含义,生成与文本输入直接相关的结果。相反,如果将该参数设置为较低的值,模型将有更大的自由度来解释和改变输入文本的含义,生成更具创造性和艺术性的结果。
提示词符号
提示词符号
https://stable-diffusion-art.com/prompt-guide/#Prompting_techniques
LoRA
图生图
Mac
Control
Additive models can provide additional control to guide the image generation process. They often take inputs in the form of scribble, poses, depth map or edge map. These additive models are only compatible with their designated versions of Stable Diffusion. “Weight” determines how much influence the control has over the image generation process. “No Prompt” can generate image without prompt. “Start” and
“End” determines during the denoising process, when the additional control kicks in.
Strength
When generating from an image, high value would give more artistic freedom from the original. 100% means no influence from the existing image (a.k.a. text to image).
模型选择
Stable Diffusion 1.4
This is the original Stable Diffusion model that changed the landscape of Al image generation. For more details, visit the model card or click on the title above.
Stable Diffusion 1.5
Same architecture as 1.4, but trained on additional images with a focus on aesthetics.
Stable Diffusion 2
Improved model, heavily retrained on millions of additional images. This version corresponds to the stable-diffusion-2-base version of the model (trained on 512 × 512 images).
Stable Diffusion 2.1
The last reference in the Stable Diffusion family. Works great with negative prompts.
模型训练
LoRA (Low-order Rank Adaptation) is a technique to apply separately trained small additive models to Stable Diffusion base model. These are typically trained faster than full model fine-tuning.
Clip skip
“CLIP Skip” controls how many lavers from the last in the text encoder are skipped. Text encoder translates your text to vectors the computer understands. Skipping more layers in the text encoder will force computer to focus more on individual words than their combined meanings. This might be useful for models that fine-tuned on tag-like text inputs.
diffusers
其他信息
Stable Diffusion 可以跑在python环境
参考资料
- Stable Diffusion Web UI 界面和主要参数介绍
- AI绘画入门:扩散模型,Stable Diffusion,LoRA,ControlNet相关技术原理
- https://github.com/CompVis/stable-diffusion
- https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features
- https://github.com/VinsonLaro/stable-diffusion-webui-chinese
- https://getimg.ai/guides/stable-diffusion-parameters
- https://stable-diffusion-art.com/how-stable-diffusion-work/
- https://diffusion-news.org/stable-diffusion-settings-parameters
- https://blog.openart.ai/2023/02/13/the-most-complete-guide-to-stable-diffusion-parameters/
- https://stable-diffusion-art.com/prompt-guide/#Prompting_techniques