使用阿里PAI DSW部署Stable Diffusion WebUI

参考内容为《快速启动Stable Diffusion WebUI》

进入到网址https://pai.console.aliyun.com/里边。

点击创建实例。

把实例名称填写好,选择GPU规格,然后选择实例名称是ecs.gn6v-c8g1.2xlarge

选择stable-diffusion-webui-env:pytorch1.13-gpu-py310-cu117-ubuntu22.04,然后点击下一步。

点击创建实例。

等着实例的状态是运行中,然后点击打开

点击Notebook

! apt update更新镜像,点击左侧三角箭头。

完成之后如下图:

点击"+"新增文本框。

! apt install -y aria2安装aria2

安装完成。

import os引入os库。

python 复制代码
def aria2(url, filename, d):
    !aria2c --console-log-level=error -c -x 16 -s 16 {url} -o {filename} -d {d}
    
url_prefix = {
    "cn-shanghai": "http://pai-vision-data-sh.oss-cn-shanghai-internal.aliyuncs.com",
    "cn-hangzhou": "http://pai-vision-data-hz2.oss-cn-hangzhou-internal.aliyuncs.com",
    "cn-shenzhen": "http://pai-vision-data-sz.oss-cn-shenzhen-internal.aliyuncs.com",
    "cn-beijing": "http://pai-vision-data-bj.oss-cn-beijing-internal.aliyuncs.com", 
}

dsw_region = os.environ.get("dsw_region")
prefix = url_prefix[dsw_region] if dsw_region in url_prefix else "http://pai-vision-data-sh.oss-cn-shanghai.aliyuncs.com"

执行代码,安装必须的依赖。

! git clone https://gitcode.net/mirrors/AUTOMATIC1111/stable-diffusion-webui.git下载源代码。

%cd stable-diffusion-webui进入到源代码里边。

! git checkout a9fed7c364061ae6efb37f797b6b522cb3cf7aa2进行检查。

python 复制代码
repositories_url = f"{prefix}/aigc-data/code/repositories.tar.gz"
aria2(repositories_url, repositories_url.split("/")[-1], "./")

下载必须的文件

! tar -xf repositories.tar.gz进行解压。

%cd ..返回上一级。

python 复制代码
%cd stable-diffusion-webui/extensions
! git clone https://gitcode.net/mirrors/DominikDoom/a1111-sd-webui-tagcomplete.git
! git clone https://gitcode.net/ranting8323/stable-diffusion-webui-localization-zh_CN
%cd ..
! wget -c http://pai-vision-data-sh.oss-cn-shanghai.aliyuncs.com/aigc-data/webui_config/config.json
%cd ..

在特定的目录下载文件。

python 复制代码
model_url = f"{prefix}/aigc-data/sd_models/Counterfeit-V2.5_fp16.safetensors"
aria2(model_url, model_url.split("/")[-1], "stable-diffusion-webui/models/Stable-diffusion")

vae_url = f"{prefix}/aigc-data/vae_models/Counterfeit-V2.5.vae.pt"
aria2(vae_url, vae_url.split("/")[-1], "stable-diffusion-webui/models/VAE")

embedding_url = f"{prefix}/aigc-data/embedding/EasyNegative.safetensors"
aria2(embedding_url, embedding_url.split("/")[-1], "stable-diffusion-webui/embeddings")

下载所有需要模型。

python 复制代码
! cd stable-diffusion-webui && python -m venv --system-site-packages --symlinks venv
! cd stable-diffusion-webui && \
  sed -i 's/can_run_as_root=0/can_run_as_root=1/g' webui.sh && \
  ./webui.sh --no-download-sd-model --xformers

启动webui。

点击http://127.0.0.1:7860

模型的VAE:Counterfeit-V2.5.vae.pt
提示词:

prompt

bash 复制代码
((masterpiece,best quality)),1girl, solo, animal ears, rabbit, barefoot, knees up, dress, sitting, rabbit ears, short sleeves, looking at viewer, grass, short hair, smile, white hair, puffy sleeves, outdoors, puffy short sleeves, bangs, on ground, full body, animal, white dress, sunlight, brown eyes, dappled sunlight, day, depth of field

negative prompt

bash 复制代码
EasyNegative, extra fingers,fewer fingers

采样方法(Sampler):DPM++2M Karras

高清修复:勾选

重绘幅度:0.6

放大倍率:1.8

高度:832

提示词相关性(CFG Scale):10

随机种子(seed):2337269170

点击"生成",等着图片生成。

用过之后,删除实例。

确认删除。

删除之后,就如下图:

相关推荐
全息数据4 天前
DDPM代码讲解【详细!!!】
深度学习·stable diffusion·多模态·ddpm
老鱼说AI13 天前
当自回归模型遇上扩散模型:下一代序列预测模型详解与Pytorch实现
人工智能·pytorch·深度学习·神经网络·语言模型·自然语言处理·stable diffusion
我希望的一路生花18 天前
Nik Collection 6.2全新版Nik降噪锐化调色PS/LR插件
人工智能·计算机视觉·设计模式·stable diffusion·aigc
GetcharZp19 天前
玩转AI绘画,你只差一个节点式“魔法”工具——ComfyUI 保姆级入门指南
人工智能·stable diffusion
Seeklike21 天前
diffuxers学习--AutoPipeline
人工智能·python·stable diffusion·diffusers
游戏AI研究所21 天前
ComfyUI 里的 Prompt 插值器(prompt interpolation / text encoder 插值方式)的含义和作用!
人工智能·游戏·机器学习·stable diffusion·prompt·aigc
迈火24 天前
ComfyUI-3D-Pack:3D创作的AI神器
人工智能·gpt·3d·ai·stable diffusion·aigc·midjourney
Seeklike25 天前
diffusers学习--stable diffusion的管线解析
人工智能·stable diffusion·diffusers
马甲是掉不了一点的<.<25 天前
Stable Diffusion 环境配置详细指南
stable diffusion·环境配置
软件测试-阿涛25 天前
【AI绘画】Stable Diffusion webUI 常用功能使用技巧
人工智能·深度学习·计算机视觉·ai作画·stable diffusion