苹果M1芯片上运行Stable Diffusion(文字作画)

苹果M1芯片上运行Stable Diffusion(文字作画)

    正在检查是否收录...

1 源码下载

git clone -b apple-silicon-mps-support https://github.com/bfirsh/stable-diffusion.git cd stable-diffusion

2 修改gitee国内源(如果可以稳定访问github就不需要)

numpy==1.23.1 --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu albumentations==0.4.6 diffusers opencv-python==4.6.0.66 pudb==2019.2 invisible-watermark imageio==2.9.0 imageio-ffmpeg==0.4.2 pytorch-lightning==1.4.2 omegaconf==2.1.1 test-tube>=0.7.5 streamlit>=0.73.1 einops==0.3.0 torch-fidelity==0.3.0 transformers==4.19.2 torchmetrics==0.6.0 kornia==0.6 -e git+https://gitee.com/rexiyz/taming-transformers.git@master#egg=taming-transformers -e git+https://gitee.com/arcsion/CLIP.git@main#egg=clip 

3 安装依赖

pip install -r requirements.txt

3.1 如果onnx报错,安装protobuf

brew install Cmake protobuf rust brew link --overwrite protobuf 

3.2 如果grpcio报错(链接)

brew install openssl CFLAGS="-I/opt/homebrew/opt/openssl/include" LDFLAGS="-L/opt/homebrew/opt/openssl/lib" GRPC_PYTHON_BUILD_SYSTEM_OPENSSL=1 GRPC_PYTHON_BUILD_SYSTEM_ZLIB=1 pip install grpcio

4 下载模型文件(链接)

https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/resolve/main/sd-v1-4.ckpt

放到源码目录下的

models/ldm/stable-diffusion-v1/model.ckpt 

5 执行图片生成

 python scripts/txt2img.py \ --prompt "a red juicy apple floating in outer space, like a planet" \ --n_samples 1 --n_iter 1 --plms 

会自定下载模型文件,有人说下载慢,时间段不同,但是我下载很快没有啥问题 

5.1 如果报错As a temporary fix, you can set the environment variable `PYTORCH_ENABLE_MPS_FALLBACK=1`

执行

export PYTORCH_ENABLE_MPS_FALLBACK=1

5.2 查看效果

codegitpythonpytorchdiffusiontransformertransformersstemgithuburlcliappappleclip图片生成cpuscripticonclonestreamlitamlnumpyonnxhuggingfacelmsidepromptfix
  • 本文作者:李琛
  • 本文链接: https://wapzz.net/post-3604.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
本站部分内容来源于网络转载,仅供学习交流使用。如涉及版权问题,请及时联系我们,我们将第一时间处理。
文章很赞!支持一下吧 还没有人为TA充电
为TA充电
还没有人为TA充电
0
  • 支付宝打赏
    支付宝扫一扫
  • 微信打赏
    微信扫一扫
感谢支持
文章很赞!支持一下吧
关于作者
2.3W+
5
0
1
WAP站长官方

快手 Dragonfly 策略引擎的设计与应用

上一篇

openAI灰度测试GPT4.5 实现六大能力增强

下一篇
  • 复制图片
按住ctrl可打开默认菜单