• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

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

武飞扬头像
qauzy
帮助1

1 源码下载

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

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

  1.  
    numpy==1.23.1
  2.  
    --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
  3.  
     
  4.  
    albumentations==0.4.6
  5.  
    diffusers
  6.  
    opencv-python==4.6.0.66
  7.  
    pudb==2019.2
  8.  
    invisible-watermark
  9.  
    imageio==2.9.0
  10.  
    imageio-ffmpeg==0.4.2
  11.  
    pytorch-lightning==1.4.2
  12.  
    omegaconf==2.1.1
  13.  
    test-tube>=0.7.5
  14.  
    streamlit>=0.73.1
  15.  
    einops==0.3.0
  16.  
    torch-fidelity==0.3.0
  17.  
    transformers==4.19.2
  18.  
    torchmetrics==0.6.0
  19.  
    kornia==0.6
  20.  
    -e git https://gitee.com/rexiyz/taming-transformers.git@master#egg=taming-transformers
  21.  
    -e git https://gitee.com/arcsion/CLIP.git@main#egg=clip
学新通

3 安装依赖

pip install -r requirements.txt

3.1 如果onnx报错,安装protobuf

  1.  
    brew install Cmake protobuf rust
  2.  
    brew link --overwrite protobuf

3.2 如果grpcio报错(链接)

  1.  
    brew install openssl
  2.  
     
  3.  
    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 执行图片生成

  1.  
    python scripts/txt2img.py \
  2.  
    --prompt "a red juicy apple floating in outer space, like a planet" \
  3.  
    --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 查看效果

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhiacgbc
系列文章
更多 icon
同类精品
更多 icon
继续加载