【笔记】MacOS部署AI绘画模型

前言

MacOS部署AI绘画模型

下载项目

1
2
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui
cd stable-diffusion-webui

下载模型

  • 将下载后的.safetensors文件放到stable-diffusion-webui/models/Stable-diffusion目录下

启动WebUI

1
./webui.sh

踩坑

  • 报错:ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.

原因

  • 使用了网络代理

解决问题

  • 修改stable-diffusion-webui/webui.py的第80行代码,从share=cmd_opts.share,改为share=True,
1
2
app, local_url, share_url = shared.demo.launch(
share=True,

踩坑

  • 报错
1
ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`

原因

  • 使用了SOCKS代理,但没有下载httpx[socks]依赖

解决问题

  • 关闭SOCKS代理

踩坑

  • 报错:RuntimeError: "upsample_nearest2d_channels_last" not implemented for 'Half'

原因

  • Mac不支持半精度

解决问题

  • 在启动时通过--no-half参数关闭半精度

  • 修改webui-macos-env.sh文件第13行,添加--no-half参数

1
export COMMANDLINE_ARGS="--skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate --no-half"

生成AI绘画

  • 输入提示词,生成AI绘画

最好是英文提示词,避免AI理解中文出错
多个关键词用,分隔
包含多个单词的整句提示词,通过()包起来

完成

参考文献

Bing的博客
知乎——AIGC LLM从业者