文生圖:介紹一個文字生成圖片的開源工具
當(dāng)前位置:點晴教程→知識管理交流
→『 技術(shù)文檔交流 』
介紹一個文字生成圖片的開源項目,我已經(jīng)在本地搭建完成了使用了。
一:下載源代碼地址:https://github.com/AUTOMATIC1111/stable-diffusion-webui 直接下載,解壓就行。
二:環(huán)境搭建使用Anaconda環(huán)境中搭建: #進(jìn)入加壓包 cd stable-diffusion-webui #創(chuàng)建環(huán)境 conda create --name stable-diff python=3.10 #激活環(huán)境: conda activate stable-diff #首次運行(會下載模型): python launch.py
三:運行運行:
python webui.py
四:添加v2新模型這里默認(rèn)下載的是v1-5-pruned-emaonly。查了下最新的有v2版本,下面就配置個v2版本。 (1):模型下載:https://huggingface.co/stabilityai/stable-diffusion-2-1/tree/main
下載 文件v2-1_768-ema-pruned.safetensors 有點大5G。放到文件夾\stable-diffusion-webui\models\Stable-diffusion 中。 然后重啟服務(wù),刷新模板,重新生成。圖片生成了,但是圖像不對。
注意如果有報錯,需要設(shè)置一下: modules.devices.NansException: A tensor with NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.
(2):解碼器下載,這里使用社區(qū)開源的解碼器 下載后存放在文件夾 \stable-diffusion-webui\models\VAE 。
(3):配置:
(4):重新啟動,注意是在cmd的 conda 環(huán)境中重新啟動服務(wù)。 選擇v2時,有一些參數(shù)可以適當(dāng)?shù)男薷囊恍缓笫褂孟嗤奶崾驹~,重新點擊生成。
搞定,收工。 最后一句:如果你的電腦還不錯,GPU16G或者更大,可以試試:stable-diffusion-xl,畫質(zhì)更高(需要注意的是使用sd_xl模型是不需要配置VAE的,在設(shè)置里面將VAE設(shè)置為NONE,不然反而會降低畫質(zhì))。 轉(zhuǎn)自https://www.cnblogs.com/cj8988/p/18976662 該文章在 2025/10/13 8:53:26 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |