要求
- macOS 12.3 Monterey 或更高版本
- Python
- 耐心
第一步 下載模型包
-
在https://huggingface.co注冊
-
搜索stable-diffusion-v-1-4-original跳轉(zhuǎn)到頁面
-
點(diǎn)擊接受條款
-
點(diǎn)擊上面Files and versions
-
下載sd-v1-4.ckpt (4.27 GB)并記下保存位置
開始安裝
# 安裝brew 或者 xcode工具 如果有可以跳過
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# 1. 安裝 pyenv
brew install pyenv-virtualenv
pyenv install anaconda3-2022.05
pyenv virtualenv anaconda3-2022.05
eval "$(pyenv init -)"
pyenv activate anaconda3-2022.05
# 2. 安裝系統(tǒng)級依賴
brew install cmake protobuf rust
# 3. 安裝 miniconda (M1 arm64):
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o Miniconda3-latest-MacOSX-arm64.sh
/bin/bash Miniconda3-latest-MacOSX-arm64.sh
# 4. clone代碼(如果沒有g(shù)it請先裝git)
git clone https://github.com/magnusviri/stable-diffusion.git
cd stable-diffusion
# 5. 創(chuàng)建模型包文件夾
mkdir -p models/ldm/stable-diffusion-v1/
# 6. 關(guān)聯(lián)模型
PATH_TO_CKPT="$HOME/Downloads" # 或者其他你保存前面你下載 sd-v1-4.ckpt 的路徑
ln -s "$PATH_TO_CKPT/sd-v1-4.ckpt" models/ldm/stable-diffusion-v1/model.ckpt
# 7. 安裝依賴
PIP_EXISTS_ACTION=w CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yaml
# 8. 開啟ldm
conda activate ldm
# 9. 這個(gè)只需要執(zhí)行一次 預(yù)加載模型,不走這個(gè)的話后面生成圖片的時(shí)間會(huì)非常非常慢
python scripts/preload_models.py
# 10. 啟動(dòng)交互式命令行,啟動(dòng)之后命令行前面會(huì)有dream,這時(shí)可以直接輸入描述來生成圖片,具體的參數(shù)可以 -help查看
python scripts/dream.py --full_precision # half-precision requires autocast and won't work
# ps 原始腳本也可以使用
python scripts/orig_scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms
如果特別慢的話
python ./scripts/orig_scripts/txt2img.py --prompt "ocean" --ddim_steps 5 --n_samples 1 --n_iter 1
一些比較正常的圖片
Posh girl wearing an open blazer, tie, detailed portrait, cell shaded, 4 k, concept art, by wlop, ilya kuvshinov, artgerm, krenz cushart, greg rutkowski, pixiv. cinematic dramatic atmosphere, sharp focus, volumetric lighting, cinematic lighting, studio quality
elegant seductive beautiful vampire horror gothic white hair ornate rococo intaglio dripping blood by Tom Bagshaw and Seb McKinnon, highly detailed, dramatic lighting, volumetric, red eyes
文章來源:http://www.zghlxwxcb.cn/news/detail-508790.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-508790.html
到了這里,關(guān)于【教程】MAC m1 安裝并使用AI繪畫 stable-diffusion,交互式命令行。的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!