v1版本: 确保你至少有12G显存
git:
GitHub - CompVis/stable-diffusion: A latent text-to-image diffusion modelhttps://github.com/CompVis/stable-diffusion
git clone https://github.com/CompVis/stable-diffusion.git
进入到你下载的路径
conda env create -f environment.yaml
conda activate ldm
模型下载地址:CompVis/stable-diffusion-v-1-4-original · Hugging FaceWe’re on a journey to advance and democratize artificial intelligence through open source and open science.https://huggingface.co/CompVis/stable-diffusion-v-1-4-original
两个文件随便下载一个就可以。重命名为model.ckpt,保存到\stable-diffusion\models\ldm\stable-diffusion-v1 目录下面
运行:
python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse
提示:
Traceback (most recent call last):
File "scripts/txt2img.py", line 22, in <module>
from diffusers.pipelines.stable_diffusion.safety_checker import StableDiffusionSafetyChecker
File "C:\Users\x\.conda\envs\ldm\lib\site-packages\diffusers\__init__.py", line 27, in <module>
from .pipelines import OnnxRuntimeModel
File "C:\Users\x\.conda\envs\ldm\lib\site-packages\diffusers\pipelines\__init__.py", line 18, in <module>
from .dance_diffusion import DanceDiffusionPipeline
File "C:\Users\x\.conda\envs\ldm\lib\site-packages\diffusers\pipelines\dance_diffusion\__init__.py", line 1, in <module>
from .pipeline_dance_diffusion import DanceDiffusionPipeline
File "C:\Users\x\.conda\envs\ldm\lib\site-packages\diffusers\pipelines\dance_diffusion\pipeline_dance_diffusion.py", line 21, in <module>
from ..pipeline_utils import AudioPipelineOutput, DiffusionPipeline
File "C:\Users\x\.conda\envs\ldm\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 64, in <module>
from transformers.utils import SAFE_WEIGHTS_NAME as TRANSFORMERS_SAFE_WEIGHTS_NAME
ImportError: cannot import name 'SAFE_WEIGHTS_NAME' from 'transformers.utils' (C:\Users\x\.conda\envs\ldm\lib\site-packages\transformers\utils\__init__.py)
这个确实很坑,默认里diffusers版本太高
解决方法:
conda list 查看diffusers版本,为0.14.0.
将这个删掉,
pip uninstall diffusers
重新安装0.12.1版本
pip install diffusers==0.12.1
或者在创建环境时直接修改 environments.yaml, "diffusers" --> "diffusers==0.12.1"
如果提示:TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
网络问题,多试几次就好。
如果提示RuntimeError: CUDA out of memory.,加个参数 --n_samples 1
---------------------------------
V2版本地址:GitHub - Stability-AI/stablediffusion: High-Resolution Image Synthesis with Latent Diffusion Modelshttps://github.com/Stability-AI/stablediffusion
模型下载地址:文章来源:https://www.toymoban.com/news/detail-780064.html
stabilityai/stable-diffusion-2-1 · Hugging Facehttps://huggingface.co/stabilityai/stable-diffusion-2-1文章来源地址https://www.toymoban.com/news/detail-780064.html
到了这里,关于stable diffusion v1及v2版本 本地部署方法、踩坑的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!