编辑“︁
Stable Diffusion
”︁(章节)
跳转到导航
跳转到搜索
警告:
您没有登录。如果您进行任何编辑,您的IP地址会公开展示。如果您
登录
或
创建账号
,您的编辑会以您的用户名署名,此外还有其他益处。
反垃圾检查。
不要
加入这个!
== 用法 == Stable Diffusion模型支持通過使用提示詞來產生新的圖像,描述要包含或省略的元素,<ref name="stable-diffusion-github"/>以及重新繪製現有的圖像,其中包含提示詞中描述的新元素(該過程通常被稱為「指導性圖像合成」(guided image synthesis)<ref>{{cite journal|date=2021-08-02|first1=Chenlin|last1=Meng|first2=Yutong|last2=He|first3=Yang|last3=Song|first4=Jiaming|last4=Song|first5=Jiajun|last5=Wu|first6=Jun-Yan|last6=Zhu|first7=Stefano|last7=Ermon|title=SDEdit: Guided Image Synthesis and Editing with Stochastic Differential Equations|publisher=arXiv|journal=arXiv|url=https://arxiv.org/abs/2108.01073|doi=10.48550/arXiv.2108.01073|language=en|access-date=2022-10-10|archive-date=2022-12-09|archive-url=https://web.archive.org/web/20221209012934/https://arxiv.org/abs/2108.01073|dead-url=no}}</ref>)通過使用模型的擴散去噪機制(diffusion-denoising mechanism)。<ref name="stable-diffusion-github"/> 此外,該模型還允許通過提示詞在現有的圖中進行內補繪製和外補繪製來部分更改,當與支持這種功能的用戶界面使用時,其中存在許多不同的[[開源軟件]]。<ref name="webui_showcase">{{cite web|url=https://github.com/AUTOMATIC1111/stable-diffusion-webui-feature-showcase|title=Stable Diffusion web UI|website=GitHub|language=en|access-date=2022-10-10|archive-date=2023-01-20|archive-url=https://web.archive.org/web/20230120032734/https://github.com/AUTOMATIC1111/stable-diffusion-webui-feature-showcase|dead-url=no}}</ref> Stable Diffusion建議在10GB以上的[[显存]]下運行, 但是显存較少的用戶可以選擇以[[半精度浮點數|float16]]的精度加載權重,而不是默認的[[單精度浮點數|float32]],以降低显存使用率。<ref name="diffusers"/> === 文生圖 === {{multiple image | direction = vertical | align = right | total_width = 200 | image1 = Algorithmically-generated landscape artwork of forest with Shinto shrine.png | image2 = Algorithmically-generated landscape artwork of forest with Shinto shrine using negative prompt for green trees.png | image3 = Algorithmically-generated landscape artwork of forest with Shinto shrine using negative prompt for round stones.png | footer = 演示反向提示詞對圖像生成的影響。 *'''上''': 無反向提示詞 *'''中''': "綠樹" *'''下''': "圓形石頭" }} Stable Diffusion中的文生圖採樣腳本,稱為"txt2img",接受一個提示詞,以及包括採樣器(sampling type),圖像尺寸,和[[隨機種子]]的各種選項參數,並根據模型對提示的解釋生成一個圖像文件。<ref name="stable-diffusion-github"/> 生成的圖像帶有不可見的[[數位浮水印]]標籤,以允許用戶識別由Stable Diffusion生成的圖像,<ref name="stable-diffusion-github"/>儘管如果圖像被調整大小或旋轉,該水印將失去其有效性。<ref>{{cite web|url=https://github.com/ShieldMnt/invisible-watermark/blob/main/README.md|title=invisible-watermark README.md|website=GitHub|language=en|access-date=2022-10-10|archive-date=2022-09-29|archive-url=https://web.archive.org/web/20220929054846/https://github.com/ShieldMnt/invisible-watermark/blob/main/README.md|dead-url=no}}</ref> Stable Diffusion模型是在由512×512分辨率圖像組成的數據集上訓練出來的,<ref name="stable-diffusion-github"/>{{r|Waxy}}這意味著txt2img生成圖像的最佳配置也是以512×512的分辨率生成的,偏離這個大小會導致生成輸出質量差。<ref name="diffusers">{{cite web|date=2022-08-22|url=https://huggingface.co/blog/stable_diffusion|title=Stable Diffusion with 🧨 Diffusers|website=Hugging Face official blog|language=en|access-date=2022-10-10|archive-date=2023-01-17|archive-url=https://web.archive.org/web/20230117222142/https://huggingface.co/blog/stable_diffusion|dead-url=no}}</ref> Stable Diffusion 2.0版本後來引入了以768×768分辨率圖像生成的能力。<ref name="release2.0"/> 每一個txt2img的生成過程都會涉及到一個影響到生成圖像的隨機種子;用戶可以選擇隨機化種子以探索不同生成結果,或者使用相同的種子來獲得與之前生成的圖像相同的結果。<ref name="diffusers"/> 用戶還可以調整採樣迭代步數(inference steps);較高的值需要較長的運行時間,但較小的值可能會導致視覺缺陷。<ref name="diffusers"/> 另一個可配置的選項,即無分類指導比例值,允許用戶調整提示詞的相關性(classifier-free guidance scale value);<ref>{{cite journal|date=2022-07-26|first1=Jonathan|last1=Ho|first2=Tim|last2=Salimans|title=Classifier-Free Diffusion Guidance|publisher=arXiv|journal=arXiv|url=https://arxiv.org/abs/2207.12598|doi=10.48550/arXiv.2207.12598|language=en|access-date=2022-10-10|archive-date=2023-01-03|archive-url=https://web.archive.org/web/20230103042523/https://arxiv.org/abs/2207.12598|dead-url=no}}</ref>更具實驗性或創造性的用例可以選擇較低的值,而旨在獲得更具體輸出的用例可以使用較高的值。<ref name="diffusers"/> 反向提示詞(negative prompt)是包含在Stable Diffusion的一些用戶界面軟件中的一個功能(包括StabilityAI自己的「Dreamstudio」[[雲端運算|雲端]][[軟件即服務]]模式[[訂閱|訂閱制]]服務),它允許用戶指定模型在圖像生成過程中應該避免的提示,適用於由於用戶提供的普通提示詞,或者由於模型最初的訓練,造成圖像輸出中出現不良的圖像特徵,例如畸形手脚。<ref name="webui_showcase"/><ref name="release2.1">{{cite web|url=https://stability.ai/blog/stablediffusion2-1-release7-dec-2022|title=Stable Diffusion v2.1 and DreamStudio Updates 7-Dec 22|website=stability.ai|language=en|archive-date=2022-12-10|archive-url=https://web.archive.org/web/20221210062732/https://stability.ai/blog/stablediffusion2-1-release7-dec-2022|url-status=no|access-date=2022-12-11}}</ref> 與使用強調符(emphasis marker)相比,使用反向提示詞在降低生成不良的圖像的頻率方面具有高度統計顯著的效果;強調符是另一種為提示的部分增加權重的方法,被一些Stable Diffusion的開源實現所利用,在關鍵詞中加入括號以增加或減少強調。<ref>{{cite web|url=https://github.com/JohannesGaessler/stable-diffusion-tools/tree/master/emphasis|date=2022-09-11|author=Johannes Gaessler|title=Emphasis|website=GitHub|language=en|access-date=2022-10-10|archive-date=2022-12-09|archive-url=https://web.archive.org/web/20221209053625/https://github.com/JohannesGaessler/stable-diffusion-tools/tree/master/emphasis|dead-url=no}}</ref> {{Gallery | height = 300 | width = 640 | File:X-Y plot of algorithmically-generated AI art by different science-fiction subgenres.png|演示當指示繪製同一主題時,不同的提示詞如何影響由Stable Diffusion模型產生的圖像輸出。每一列代表輸入到模型中的不同提示詞。左到右:[[賽博朋克]],[[蒸汽朋克]],[[柴油朋克]],[[生物朋克]],{{tsl|en|Cyberpunk derivatives#Cassette futurism/Formicapunk|磁帶朋克}},[[:wikt:en:atompunk|原子朋克]],[[:wikt:en:cyberpop|賽博POP]],[[哥德次文化]],[[奇幻作品|奇幻]] }} === 圖生圖 === {{Multiple image | direction = horizontal | align = right | total_width = 400 | image1 = NightCitySphere (SD1.5).jpg | image2 = NightCitySphere (SDXL).jpg | footer = 演示img2img修改 *'''左''': 最初用Stable Diffusion 1.5制作的图像 *'''右''': 用Stable Diffusion XL 1.0修改后的图像 }} Stable Diffusion包括另一個取樣腳本,稱為"img2img",它接受一個提示詞、現有圖像的文件路徑和0.0到1.0之間的去噪強度,並在原始圖像的基礎上產生一個新的圖像,該圖像也具有提示詞中提供的元素;去噪強度表示添加到輸出圖像的噪聲量,值越大,圖像變化越多,但在語義上可能與提供的提示不一致。<ref name="stable-diffusion-github"/> 圖像升頻是img2img的一個潛在用例,除此之外。<ref name="stable-diffusion-github"/> 2022年11月24日發布的Stable Diffusion 2.0版本包含一個深度引導模型,稱為"depth2img",該模型推斷所提供的輸入圖像的{{en-link|深度貼圖|Depth map|深度}},並根據提示詞和深度信息生成新圖像,在新圖像中保持原始圖像的連貫性和深度。<ref name="release2.0"/> ==== 內補繪製與外補繪製 ==== Stable Diffusion模型的許多不同用戶界面軟件提供了通過img2img進行圖生圖的其他用例。內補繪製(inpainting)由用戶提供的{{en-link|蒙版|Layers (digital image editing)#Layer mask}}描繪的現有圖像的一部分,根據所提供的提示詞,用新生成的內容填充蒙版的空間。<ref name="webui_showcase"/> 隨著Stable Diffusion 2.0版本的發布,StabilityAI同時創建了一個專門針對內補繪製用例的專用模型。<ref name="release2.0">{{cite web|url=https://stability.ai/blog/stable-diffusion-v2-release|title=Stable Diffusion 2.0 Release|website=stability.ai|language=en|archive-date=2022-12-10|archive-url=https://web.archive.org/web/20221210062729/https://stability.ai/blog/stable-diffusion-v2-release|url-status=no|access-date=2022-12-11}}</ref> 相反,外補繪製(outpainting)將圖像擴展到其原始尺寸之外,用根據所提供的提示詞生成的內容來填補以前的空白空間。<ref name="webui_showcase"/> {{multiple image | direction = horizontal | align = none | total_width = 500 | image1 = Demonstration of inpainting and outpainting using Stable Diffusion (step 1 of 4).png | width1 = 125 | height1 = 218 | caption1 = '''第一步:''' 使用txt2img生成新圖像。巧合的是,它無意中生成了這個缺少一隻手臂的人。 | image2 = Demonstration of inpainting and outpainting using Stable Diffusion (step 2 of 4).png | width2 = 125 | caption2 = '''第二步:''' 通過外補繪製,圖像底部被擴展了512像素,並被AI生成的內容所填充。 | image3 = Demonstration of inpainting and outpainting using Stable Diffusion (step 3 of 4).png | width3 = 125 | caption3 = '''第三步:''' 在準備內補繪製時,使用[[GIMP]]中的畫筆繪製了一個臨時的手臂。 | image4 = Demonstration of inpainting and outpainting using Stable Diffusion (step 4 of 4).png | width4 = 125 | caption4 = '''第四步:''' 在臨時手臂上應用內補繪製蒙版,img2img生成一個新手臂,同時保持圖像的其餘部分保持不變。 | header = 在Stable Diffusion中使用img2img的內補繪製與外補繪製技術的演示 }}
摘要:
请注意,所有对Local Chinese Wikipedia的贡献均可能会被其他贡献者编辑、修改或删除。如果您不希望您的文字作品被随意编辑,请不要在此提交。
您同时也向我们承诺,您提交的内容为您自己所创作,或是复制自公共领域或类似自由来源(详情请见
Project:著作权
)。
未经许可,请勿提交受著作权保护的作品!
取消
编辑帮助
(在新窗口中打开)
导航菜单
个人工具
未登录
讨论
贡献
创建账号
登录
命名空间
页面
讨论
大陆简体
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
查看
阅读
编辑
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息