作者:寒斜
立即体验基于函数计算部署 Stable Diffusion:
https://developer.aliyun.com/topic/aigc
AIGC 领域目前大火, 除了 Chatgpt,在文生图领域 Stable Diffusion 大放异彩,深刻的地影响着绘画、视频制作等相关领域。利用这项技术,普通人也可以制作出令人惊叹的艺术作品。今天我们将使用阿里云函数计算来部署一套 Stable Diffusion WebUi,给大家展示一下这项技术的魅力。 在进入技术教程之前,我们先看一下笔者生成的相关图片内容。
Stable Diffusion WebUi:
https://github.com/AUTOMATIC1111/stable-diffusion-webui
画廊
sd+ mdjrny/ChilloutMix
Cheese Daddy
国风
daclefo_painting
函数计算的优势
开箱即用,通过应用中心或者 Serverless Devs 一键部署快速体验,无需进行复杂的环境配置 用时消费,通过 Serverless 弹性策略在您启动服务的才开始计费 支持 GPU 渲染,出图快,花费低准备项
开通阿里云**函数计算 [ 1]**
开通阿里云**容器镜像服务 ACR [ 2]**
下载 Serverless Devs [ 3]
使用 Serverless Devs 配置**阿里云秘钥信息 [ 4]**
快速开始
一行指令部署
创建一个本地文件目录如 stable-diffusion 在 stable-diffusion 目录下创建一个 s.yaml 文件,内容如下edition: 1.0.0 name: fc-stable-diffusion access: default services: cn-shanghai-stable-diffusion-sd: component: devsapp/fc props: region: cn-shanghai service: description: stable-diffusion部署到函数计算 internetAccess: true name: stable-diffusion function: handler: index.handler timeout: 600 diskSize: 10240 caPort: 7860 instanceType: fc.gpu.tesla.1 runtime: custom-container cpu: 8 customContainerConfig: args: '' accelerationType: Default image: registry.cn-shanghai.aliyuncs.com/vipas/stable-diffusion-web:v2 accelerationInfo: status: Preparing command: '' webServerMode: true instanceConcurrency: 1 memorySize: 32768 environmentVariables: {} gpuMemorySize: 16384 name: sd asyncConfiguration: {} triggers: - name: defaultTrigger description: '' type: http qualifier: LATEST config: methods: - GET - POST - PUT - DELETE authType: anonymous disableURLInternet: false customDomains: - domainName: auto protocol: HTTP routeConfigs: - path: /*
执行部署指令 s deploy
效果预览及操作
执行完部署指令后,很快就能拿到访问地址,如下面↓
http://sd.stable-diffusion.xxxxxx.cn-shanghai.fc.devsapp.net 内容(xxxxxx为您自己账号 uid)
cn-shanghai-stable-diffusion-sd: region: cn-shanghai service: name: stable-diffusion function: name: sd runtime: custom-container handler: index.handler memorySize: 32768 timeout: 600 url: system_url: https://sd-stable-iffusion-zulpjlkgaj.cn-shanghai.fcapp.run custom_domain: - domain: http://sd.stable-diffusion.xxxxxx.cn-shanghai.fc.devsapp.net triggers: - type: http name: defaultTrigger
函数计算初次启动要花费 3-4 分钟,需要完成镜像拉取,冷启动等操作。
最后画面如下:
我们提供的默认镜像自带了 sd 基础模型。
部署成功之后您可以输入一些文字描述进行图片生成,如上图 sd 生成了一只可爱的小狗?。
总结及扩展
函数计算部署 SD,一行指令运行即可。但我们仍然面临很多实际的使用问题,比如这里使用的镜像仅保留了一个基础模型,后面要扩展需要重新打镜像,非常麻烦,整体冷启动时长较长,初次访问体验欠佳。诸如以上,如何动态管理模型和扩展,以及加快启动速度,在接下来实践篇我们进一步探讨。
有奖体验
阿里云将提供免费 Serverless 函数计算产品资源,邀请你,体验一把 AIGC 级的毕加索、达芬奇、梵高等大师作画的快感。下面请尽情发挥你的想象空间!!双重奖品设置,完成体验场景可得社区 1000 积分兑换奖品,还可参加 AI 生成图像比赛赢取 Airpods、500 元猫超卡及社区定制抱枕!
? 体验地址:
https://developer.aliyun.com/topic/aigc
你也可以轻松做出下方画作??
相关链接:
[1] 函数计算
https://www.aliyun.com/product/fc?spm=5176.devs
[2] 容器镜像服务 ACR
https://www.aliyun.com/product/acr?spm=5176.28055625.J_3207526240.121.1d22154aWn0gl1&scm=20140722.M_4776670._.V_1
[3] Serverless Devs
https://docs.serverless-devs.com/serverless-devs/quick_start
[4] 阿里云秘钥信息
https://docs.serverless-devs.com/serverless-devs/command/config#config-add-%E5%91%BD%E4%BB%A4
diffusionserverlesscodeweburlstable diffusionaigcappwebuigpuelo基础模型scriptdoc冷启动amlcpu积分兑换stemchatgptutm文生图gitchat艺术作品ai 生成github图片生成视频制作gpt图片内容