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
模型下载地址:
stabilityai/stable-diffusion-2-1 · Hugging Facehttps://huggingface.co/stabilityai/stable-diffusion-2-1
版权归原作者 jbzj 所有, 如有侵权,请联系我们删除。