Windows平台StableSwarmUI-0.6.1-Beta文生图

记录更新版本问题,更新目前最新测试版 StableSwarmUI-0.6.4-Beta。

StableSwarmUI-0.6.4-shutdown-server-error.png

进入控制台界面,定位错误日志:

img

1
2
3
4
5
6
7
8
9
10
11
20:37:05.205 [Error] [WebAPI] Error handling API request '/API/ListConnectedUsers' for user 'local': Internal exception: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponsePipeWriter.WriteAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
at StableSwarmUI.Utils.Utilities.YieldJsonOutput(HttpContext context, WebSocket socket, Int32 status, JObject obj) in E:\AI\StableSwarmUI-0.6.2-Beta\src\Utils\Utilities.cs:line 325
at StableSwarmUI.WebAPI.API.HandleAsyncRequest(HttpContext context) in E:\AI\StableSwarmUI-0.6.2-Beta\src\WebAPI\API.cs:line 136

20:37:05.271 [Error] [WebAPI] Error handling API request '/API/GetServerResourceInfo' for user 'local': Internal exception: System.OperationCanceledException: The operation was canceled.
at System.Threading.CancellationToken.ThrowOperationCanceledException()
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponsePipeWriter.WriteAsync(ReadOnlyMemory`1 source, CancellationToken cancellationToken)
at StableSwarmUI.Utils.Utilities.YieldJsonOutput(HttpContext context, WebSocket socket, Int32 status, JObject obj) in E:\AI\StableSwarmUI-0.6.2-Beta\src\Utils\Utilities.cs:line 325
at StableSwarmUI.WebAPI.API.HandleAsyncRequest(HttpContext context) in E:\AI\StableSwarmUI-0.6.2-Beta\src\WebAPI\API.cs:line 136

出现问题原因,日志已经提醒了,可能找不到对应 API 所在路径。由于个人更新版本时出现疏忽,未及时执行更新脚本 update-windows.bat。如果你是 Unix 或者 Linux 平台,请尝试执行 update-linuxmac.sh

如果做完以上尝试,依旧存在提醒“无法向服务器发送请求,服务器是否崩溃?”。问题不大,不影响正常

Windows 平台,解决方案如下。

如果出现提醒:“无法向服务器发送请求,服务器是否崩溃”。请尝试执行更新脚本 .\StableSwarmUI-0.6.4-Beta\update-windows.bat,再次执行关闭服务器或者更新和重启服务器。

pFbXXh8.md.png

如果有你幸访问本教程,可以看到文初使用 sd_xl_base_1.0.safetensors 模型生成的图片样张。参数如下:

1
2
3
4
5
6
7
prompt: a photo of a cat,
images: 2, seed: 1, steps: 20, cfgscale: 7,
variationseed: 1991156077,aspectratio: 1:1,
width: 1024, height: 1024,
initimagecreativity: 0.6, refinercontrolpercentage: 0.2,
refinermethod: PostApply, refinerupscalemethod: pixel-bilinear,
model: OfficialStableDiffusion/sd_xl_base_1.0.safetensors, swarm_version: 0.6.1.0, date: 2024-04-05, generation_time: 2.13 (prep) and 18.11 (gen) seconds

友情提醒:如果你将 seed 参数(图像种子)值设置为 -1 则会生成随机图像。如果你想强化学习,可以参考官方文档参数设置,这是一个不错的选择。

获取 StableSwarmUI:StableSwarmUI ,你需要部署 Python 环境。如果你访问 Python 官网有困难,可以从 Python中文网 获取资源。当然也可以从国内各大开源软件镜像网站获取。如果实在有困难,文末我也会给出自己上传的 Windows 平台 Python 安装包。

我个人 Python 环境,仅供参考:

1
2
PS D:\work> python -V
Python 3.10.6

Windows 平台打开 powershell 使用 expand-archive 命令解压 StableSwarmUI-0.6.1-Beta

1
Expand-Archive .\StableSwarmUI-0.6.1-Beta.zip -DestinationPath E:\AI\

进入 StableSwarmUI 根目录:

1
cd E:\AI\StableSwarmUI-0.6.1-Beta\

让我们一起愉快的开启 StableSwarmUI 体验之旅吧,在这之前,再次友情提醒安装好 Python 环境哟。

StableSwarmUI 安装与启动

启动 StableSwarmUI 之前我想介绍一下,个人硬件环境(笔电)。不算太新,不算太老,将将能玩(学习):

  • CPU:R7-7735H(实际上是 R7-6800H的马甲U,苏妈挤了多少次牙膏了,升级命名鬼才)。8 个纯大核 u,平时也够用了。
  • 显卡(GPU):NVIDIA GeForce RTX 4060 Laptop GPU, 8.00 GiB

上了独立显卡,这种搭配,AMD 强劲的核显显得有点浪费了。

大学新生开学季,怎么套路换电脑?新思路,老爸啊,你儿子想学 Ai,需要高配一丢丢的 N 卡作为生产力。千万别说是我教的,问就是生产力需要。

有点跑题了,继续 StableSwarmUI 介绍, 目前处于 Beta 版本

A Modular Stable Diffusion Web-User-Interface, with an emphasis on making powertools easily accessible, high performance, and extensibility.

安装与启动,Windows 平台执行 launch-windows.bat 脚本,安装过程可能比较缓慢,也许你需要科学上网。

Windows 平台执行 launch-windows.bat 脚本,调用 dotnet 过程。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
PS E:\AI\StableSwarmUI-0.6.1-Beta> .\launch-windows.bat
error: 指定的源已添加到可用程序包源的列表中。请提供唯一的源。

Usage: dotnet nuget add source [arguments] [options]

Arguments:
PackageSourcePath 包源的路径。

Options:
-n|--name 源的名称。
-u|--username 连接到已验证源时要使用的用户名。
-p|--password 连接到已验证源时要使用的密码。
--store-password-in-clear-text 通过禁用密码加密来启用存储可移植包源凭据。
--valid-authentication-types 此源的有效身份验证类型的列表(用逗号分隔)。如果服务器公布 NTLM 或 Negotiate,并且你的凭据必 须使用基本机制发送(例如将 PAT 与本地 Azure DevOps Server 一起使用时),请将此项设置为 basic。其他有效值包括 negotiate、kerberos、ntlm 和 digest,但这些值很可能没有用。
--protocol-version The NuGet server protocol version to be used. Currently supported versions are 2 and 3. See https://learn.microsoft.com/nuget/api/overview for information about the version 3 protocol. Defaults to 2 if not specified.
--configfile NuGet 配置文件。如果指定,将仅使用此文件中的设置。如果未指定,则将使用当前目录中的配置文件 的层次结构。有关详细信息,请参阅 https://docs.microsoft.com/nuget/consume-packages/configuring-nuget-behavior
-h|--help Show help information

适用于 .NET MSBuild 版本 17.9.6+a4ecab324
正在确定要还原的项目…
已还原 E:\AI\StableSwarmUI-0.6.1-Beta\src\StableSwarmUI.csproj (用时 2.75 sec)。
StableSwarmUI -> E:\AI\StableSwarmUI-0.6.1-Beta\src\bin\live_release\StableSwarmUI.dll

已成功生成。
0 个警告
0 个错误

已用时间 00:00:10.68

启动 StableSwarmUI 过程。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
17:11:09.194 [Init] === StableSwarmUI v0.6.1.0 Starting ===
17:11:09.390 [Init] Prepping extension: StableSwarmUI.Builtin_StabilityAPIExtension.StabilityAPIExtension...
17:11:09.400 [Init] Prepping extension: StableSwarmUI.Builtin_ScorersExtension.ScorersExtension...
17:11:09.400 [Init] Prepping extension: StableSwarmUI.Builtin_ImageBatchToolExtension.ImageBatchToolExtension...
17:11:09.401 [Init] Prepping extension: StableSwarmUI.Builtin_GridGeneratorExtension.GridGeneratorExtension...
17:11:09.402 [Init] Prepping extension: StableSwarmUI.Builtin_DynamicThresholding.DynamicThresholdingExtension...
17:11:09.403 [Init] Prepping extension: StableSwarmUI.Builtin_ComfyUIBackend.ComfyUIBackendExtension...
17:11:09.404 [Init] Prepping extension: StableSwarmUI.Builtin_AutoWebUIExtension.AutoWebUIBackendExtension...
17:11:09.439 [Init] Parsing command line...
17:11:09.441 [Init] Loading settings file...
17:11:09.442 [Init] No settings file found.
17:11:09.443 [Init] Re-saving settings file...
17:11:09.462 [Init] Applying command line settings...
17:11:09.615 [Init] Prepping options...
17:11:09.895 [Init] Loading models list...
17:11:09.906 [Init] Loading backends...
17:11:09.908 [Init] Loading backends from file...
17:11:09.909 [Init] Prepping API...
17:11:09.910 [Init] Backend request handler loop ready...
17:11:09.912 [Init] Prepping webserver...
17:11:10.086 [Init] Scan for web extensions...
17:11:10.164 [Init] Readying extensions for launch...
17:11:10.165 [Init] Launching server...
17:11:10.166 [Init] Starting webserver on http://localhost:7801
17:11:10.213 [Init] Program is running.
17:11:10.715 [Init] Launch web browser to install page...
17:11:13.249 [Info] Creating new admin session 'local' for ::1
17:11:46.067 [Init] [Installer] Installation request received, processing...
17:11:46.069 [Init] [Installer] Setting theme to dark_dreams.
17:11:46.070 [Init] [Installer] Configuring settings as 'just yourself' install.
17:11:46.070 [Init] [Installer] Downloading ComfyUI backend... please wait...
18:13:01.394 [Init] [Installer] Downloaded! Extracting... (look in terminal window for details)

7-Zip (a) 23.01 (x86) : Copyright (c) 1999-2023 Igor Pavlov : 2023-06-20

Scanning the drive for archives:
1 file, 1446137955 bytes (1380 MiB)

Extracting archive: dlbackend\comfyui_dl.7z
--
Path = dlbackend\comfyui_dl.7z
Type = 7z
Physical Size = 1446137955
Headers Size = 326646
Method = LZMA:25 BCJ2
Solid = +
Blocks = 2

Everything is Ok

Folders: 2689
Files: 28279
Size: 5157388562
Compressed: 1446137955
18:14:49.725 [Init] [Installer] Installing prereqs...
18:15:03.751 [Init] [Installer] Enabling ComfyUI...
18:15:03.757 [Init] [Installer] Downloading model from 'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors'... please wait...
18:15:03.758 [Init] Initializing backend #0 - ComfyUI Self-Starting...
Cloning into 'sd-dynamic-thresholding'...
remote: Enumerating objects: 373, done.
remote: Counting objects: 100% (116/116), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 373 (delta 102), reused 102 (delta 93), pack-reused 257Receiving objects: 84% (314/373), 620.00 KiB | 607.00 KRece
Receiving objects: 100% (373/373), 1.00 MiB | 984.00 KiB/s, done.
Resolving deltas: 100% (186/186), done.
18:15:13.209 [Info] Saving backends...
18:15:15.127 [Info] Self-Start ComfyUI (Git Pull) exited properly.
18:15:45.869 [Error] Failed to download 'https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors' (HTTP): HttpRequestException: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。 (huggingface.co:443)
18:15:45.913 [Init] [Installer] Model download complete.
18:15:45.942 [Warning] Failed to load metadata for OfficialStableDiffusion/sd_xl_base_1.0.safetensors:
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
at System.IO.Stream.ReadExactly(Byte[] buffer, Int32 offset, Int32 count)
at StableSwarmUI.Text2Image.T2IModel.GetSafetensorsHeaderFrom(String modelPath) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModel.cs:line 70
at StableSwarmUI.Text2Image.T2IModelHandler.LoadMetadata(T2IModel model) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModelHandler.cs:line 367
at StableSwarmUI.Text2Image.T2IModelHandler.<>c__DisplayClass22_0.<AddAllFromFolder>b__1(String file) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModelHandler.cs:line 509
18:15:45.951 [Info] ComfyUI backend 0 shutting down...
18:15:45.952 [Init] [Installer] Installed!
18:15:48.159 [Info] Creating new admin session 'local' for ::1
18:16:50.589 [Info] Self-Start ComfyUI (Install rembg) exited properly.
18:16:52.376 [Info] Self-Start ComfyUI (Install opencv-python-headless) exited properly.
18:17:08.055 [Info] Self-Start ComfyUI (Install imageio-ffmpeg) exited properly.
18:17:08.068 [Init] Self-Start ComfyUI-0 on port 7821 is loading...
18:18:22.518 [Init] Self-Start ComfyUI-0 on port 7821 started.
18:18:22.521 [Init] Initializing backend #0 - ComfyUI Self-Starting...
18:18:26.190 [Warning] Failed to load metadata for OfficialStableDiffusion/sd_xl_base_1.0.safetensors:
System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
at System.IO.Stream.ReadAtLeastCore(Span`1 buffer, Int32 minimumBytes, Boolean throwOnEndOfStream)
at System.IO.Stream.ReadExactly(Byte[] buffer, Int32 offset, Int32 count)
at StableSwarmUI.Text2Image.T2IModel.GetSafetensorsHeaderFrom(String modelPath) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModel.cs:line 70
at StableSwarmUI.Text2Image.T2IModelHandler.LoadMetadata(T2IModel model) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModelHandler.cs:line 367
at StableSwarmUI.Text2Image.T2IModelHandler.<>c__DisplayClass22_0.<AddAllFromFolder>b__1(String file) in E:\AI\StableSwarmUI-0.6.1-Beta\src\Text2Image\T2IModelHandler.cs:line 509
18:18:33.285 [Info] Self-Start ComfyUI (Git Pull) exited properly.
fatal: unable to access 'https://github.com/mcmonkeyprojects/sd-dynamic-thresholding/': Failure when receiving data from the peer
18:18:33.320 [Init] Self-Start ComfyUI-0 on port 7822 is loading...
18:18:41.465 [Init] Self-Start ComfyUI-0 on port 7822 started.
18:19:01.743 [Info] Shutting down...
18:19:01.814 [Info] Backend request handler loop closing...
18:19:01.815 [Info] ComfyUI backend 0 shutting down...
18:19:01.815 [Info] Shutting down self-start ComfyUI (port=7822) process #43240...
18:19:01.866 [Info] Self-Start ComfyUI-0 on port 7822 exited properly from disabling.
18:19:01.928 [Info] Backend handler shutdown complete without saving.
18:19:01.929 [Info] Will shut down session handler...
18:19:01.929 [Info] Will save user data.
18:19:01.932 [Info] Session handler is shut down.
18:19:01.936 [Info] All core shutdowns complete.
18:19:02.960 [Info] Self-Start ComfyUI-0 on port 7821 exited properly from disabling.

初次安装,从官方渠道获取比较缓慢,优先访问 https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/sd_xl_base_1.0.safetensors,看到报错或者警告信息是正常状态。在国内无法访问进去,可以前往第三方网站或者社区,比如魔搭社区获取他人上传的模型数据。

sd_xl_base_1.0 模型获取

魔搭社区,获取 sd_xl_base_1.0.safetensors

如果你使用 git 获取,默认你已经部署并配置好 Git 环境,可以直接获取完整模型训练仓库 git clone https://www.modelscope.cn/AI-ModelScope/stable-diffusion-xl-base-1.0.git。当然,你也可以点击文件 sd_xl_base_1.0.safetensors 直接下载。如果急需体验,个人推荐直接下载模型文件。完整模型仓库所占空间较大,存在版本库迭代,每个作者提交同步的内容有所不同。

如果本地没有模型数据,需要获取别人培养的模型数据,复制到 StableSwarmUI 指定的 \StableSwarmUI-0.6.1-Beta\Models\Stable-Diffusion\OfficialStableDiffusion 目录。

传入模型数据后,进入 web UI 界面点击模型,刷新即可看到模型。个人建议,最好还是在服务器功能模块选择服务器信息功能,点击关闭服务(Shutdown Server),然后再次执行 launch-windows.bat 启动 web 应用程序。

本地启动完成后,会自动跳转到默认设置浏览器,访问 http://localhost:7801

首页展示画面,初体验同时使用到了两种模型:

  1. sd_xl_base_1.0.safetensors
  2. chilloutmix_NiPrunedFp32Fix.safetensors

使用 sd_xl_base_1.0.safetensors 模型生成一张猫咪图像(大图在文初):

pFqixIJ.png

使用 chilloutmix_NiPrunedFp32Fix.safetensors 模型生成一张猫咪图像:

pFbqDld.png

Windows 平台 Python 安装包(2.7.17、3.9.4、3.10.6、3.11.5):

链接: https://pan.baidu.com/s/1uN8ceOnPVT3GASYMQSXUvw?pwd=8888

提取码: 8888

最后,以上总结仅供参考哟,希望对你的学习和工作有所帮助。

参考资料

  • StableSwarmUI
  • ComfyUI
  • 魔搭社区 (modelscope.cn)

—END—