如何部署一个自己的AI绘图

目前AI绘图只支持N卡,显存最少4G,部署的时候一定要注意设备的配置**

1.在windows上部署

可以观看b站up:独立研究员-星空的教程
AI绘画 【Stable Diffusion】 NovelAI 整合包 解压即用
AI绘画 【Stable Diffusion】NovelAI整合包 WebUI更新与最新设置
一定要完整做完两个教程,否则有电脑被入侵的风险**
⚠️警惕!你的NovelAI模型,极有可能被恶意攻击! 藏在AI绘画泄露模型背后的,巨大安全隐患!

2.在linux/GPU服务器(ubuntu)上部署

参考:官方文档
官方文档中的自动安装会有各种各样的问题,这里建议手动安装

2.1用anaconda管理环境

2.1.1 安装anaconda

wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh
bash Anaconda3-2022.05-Linux-x86_64.sh

2.1.2 创建虚拟环境

  conda create --name NovelAI  python=3.9.12 # NovelAI为环境名,3.8为python的版本号

2.1.3 激活环境

conda activate NovelAI

2.2安装stable-diffusion-webui

依次运行一下代码,如果出现Permission denied,在相应命令前加上sudo

# install torch with CUDA support. See https://pytorch.org/get-started/locally/ for more instructions if this fails.
pip install torch --extra-index-url https://download.pytorch.org/whl/cu113

# check if torch supports GPU; this must output "True". You need CUDA 11. installed for this. You might be able to use
# a different version, but this is what I tested.
python -c "import torch; print(torch.cuda.is_available())"

# clone web ui and go into its directory
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
cd stable-diffusion-webui

# clone repositories for Stable Diffusion and (optionally) CodeFormer
mkdir repositories
git clone https://github.com/CompVis/stable-diffusion.git repositories/stable-diffusion
git clone https://github.com/CompVis/taming-transformers.git repositories/taming-transformers
git clone https://github.com/sczhou/CodeFormer.git repositories/CodeFormer
git clone https://github.com/salesforce/BLIP.git repositories/BLIP

# install requirements of Stable Diffusion
pip install transformers==4.19.2 diffusers invisible-watermark --prefer-binary

# install k-diffusion
pip install git+https://github.com/crowsonkb/k-diffusion.git --prefer-binary

# (optional) install GFPGAN (face restoration)
pip install git+https://github.com/TencentARC/GFPGAN.git --prefer-binary

# (optional) install requirements for CodeFormer (face restoration)
pip install -r repositories/CodeFormer/requirements.txt --prefer-binary

# install requirements of web ui
pip install -r requirements.txt  --prefer-binary

# update numpy to latest version
pip install -U numpy  --prefer-binary

2.3 模型

刚安装完是没有模型的,需要下载模型

2.3.1 模型目录

所以模型都放在这个目录下,可以通过sftp上传到该目录下

stable-diffusion-webui\models\Stable-diffusion

2.3.2 各种各样的模型下载

https://rentry.org/sdmodels

2.3.3最近泄露的NovelAI模型

链接:https://pan.baidu.com/s/1Mu_ynhBkkWi1Nr1nWl_Xyw?pwd=rs47
提取码:rs47

2.4运行

2.4.1 本地运行

python webui.py

2.4.2 服务器运行本地远程访问

python webui.py --listen

然后即可通过服务器7860端口访问(记得服务器控制台放行端口)

http://<服务器公网ip>:7860/

2.4.3 后台运行

nohup python webui.py --listen 2>&1 &

更多参数设置

3.在colab上部署

如果自己电脑显存不够,又没有GPU服务器的话可以在colab部署,可以免费使用一块T4,只需要一个谷歌账号,而且没有安全风险,缺点就是不稳定,需要魔法
代码:colab一键部署
教程:NovelAI 4chan colab tutorial教學:目前最接近NovelAI官方且免費的版本(需要魔法 )

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年2月26日 上午9:32
下一篇 2023年2月26日 上午9:33

相关推荐