苹果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 查看效果
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhiacgbc
系列文章
更多
同类精品
更多
-
photoshop保存的图片太大微信发不了怎么办
PHP中文网 06-15 -
word里面弄一个表格后上面的标题会跑到下面怎么办
PHP中文网 06-20 -
photoshop扩展功能面板显示灰色怎么办
PHP中文网 06-14 -
《学习通》视频自动暂停处理方法
HelloWorld317 07-05 -
Android 11 保存文件到外部存储,并分享文件
Luke 10-12 -
TikTok加速器哪个好免费的TK加速器推荐
TK小达人 10-01 -
微信公众号没有声音提示怎么办
PHP中文网 03-31 -
excel下划线不显示怎么办
PHP中文网 06-23 -
excel打印预览压线压字怎么办
PHP中文网 06-22 -
微信运动停用后别人还能看到步数吗
PHP中文网 07-22