@syncshio/kano-plugin-sd-webui 0.0.0-stage → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entry.js +1484 -0
- package/kano-release.json +5 -0
- package/package.json +25 -4
- package/plugin.json +38 -0
- package/README.md +0 -3
package/dist/entry.js
ADDED
|
@@ -0,0 +1,1484 @@
|
|
|
1
|
+
import { buildLocalWebviewUrl as e, createLaunchCheck as t, getPythonProbeDetails as n, getRuntimePackageVersion as r, parseShellArgs as i, resolvePath as a, selectLaunchCapability as o } from "@syncshio/kano-plugin-sdk/host";
|
|
2
|
+
import { computed as s, defineComponent as c, h as l } from "vue";
|
|
3
|
+
//#region ../kano-plugin-sdk/src/contracts/launch.ts
|
|
4
|
+
var u = {
|
|
5
|
+
RefreshHostCapabilities: "refresh-host-capabilities",
|
|
6
|
+
OpenPythonSettings: "open-python-settings",
|
|
7
|
+
OpenLaunchSettings: "open-launch-settings",
|
|
8
|
+
OpenVersionManagement: "open-version-management",
|
|
9
|
+
OpenExtensionManagement: "open-extension-management",
|
|
10
|
+
ApplyLaunchParam: "apply-launch-param",
|
|
11
|
+
ApplyBackendSelection: "apply-backend-selection",
|
|
12
|
+
OpenUrl: "open-url"
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../kano-plugin-sdk/src/helpers/define-plugin.ts
|
|
16
|
+
function d(e) {
|
|
17
|
+
return e;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region packages/plugins/sd-webui/launch/preflight/params.ts
|
|
21
|
+
var f = [
|
|
22
|
+
"--backend",
|
|
23
|
+
"--device-name",
|
|
24
|
+
"--device-id",
|
|
25
|
+
"--use-cpu",
|
|
26
|
+
"--use-directml",
|
|
27
|
+
"--use-ipex",
|
|
28
|
+
"--lowvram",
|
|
29
|
+
"--medvram",
|
|
30
|
+
"--medvram-sdxl",
|
|
31
|
+
"--lowram",
|
|
32
|
+
"--xformers",
|
|
33
|
+
"--force-enable-xformers",
|
|
34
|
+
"--xformers-flash-attention",
|
|
35
|
+
"--opt-sdp-attention",
|
|
36
|
+
"--opt-sdp-no-mem-attention",
|
|
37
|
+
"--opt-sub-quad-attention",
|
|
38
|
+
"--opt-split-attention",
|
|
39
|
+
"--opt-split-attention-invokeai",
|
|
40
|
+
"--opt-split-attention-v1",
|
|
41
|
+
"--disable-opt-split-attention",
|
|
42
|
+
"--precision",
|
|
43
|
+
"--skip-torch-cuda-test",
|
|
44
|
+
"--skip-install"
|
|
45
|
+
];
|
|
46
|
+
function p(e, t) {
|
|
47
|
+
if (typeof e == "number" && Number.isFinite(e) && e > 0) return e;
|
|
48
|
+
if (typeof e == "string" && e.trim()) {
|
|
49
|
+
let t = Number(e);
|
|
50
|
+
if (Number.isFinite(t) && t > 0) return t;
|
|
51
|
+
}
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region packages/plugins/sd-webui/types.ts
|
|
56
|
+
var m = /* @__PURE__ */ function(e) {
|
|
57
|
+
return e.None = "none", e.MediumSdxl = "medvram-sdxl", e.Medium = "medvram", e.Low = "lowvram", e.Full = "lowram", e;
|
|
58
|
+
}({}), h = /* @__PURE__ */ function(e) {
|
|
59
|
+
return e.AutoXformers = "auto-xformers", e.ForceXformers = "force-xformers", e.XformersFlashAttention = "xformers-flash-attn", e.ScaledDotProduct = "sdp", e.ScaledDotProductNoMem = "sdp-no-mem", e.SubQuad = "sub-quad", e.Auto = "auto", e.ForceDoggettx = "doggettx", e.ForceInvokeAI = "invokeai", e.ForceV1 = "v1", e.Disable = "disable", e;
|
|
60
|
+
}({}), g = /* @__PURE__ */ function(e) {
|
|
61
|
+
return e.FollowLauncher = "follow-launcher", e.Auto = "auto", e.Light = "light", e.Dark = "dark", e;
|
|
62
|
+
}({}), _ = /* @__PURE__ */ function(e) {
|
|
63
|
+
return e.Native = "native", e.CudaMallocAsync = "cudaMallocAsync", e;
|
|
64
|
+
}({});
|
|
65
|
+
function v(e) {
|
|
66
|
+
let t = e.remoteUrl.toLowerCase(), n = e.branch.toLowerCase(), r = e.tags.map((e) => e.toLowerCase());
|
|
67
|
+
return t.includes("vladmandic") ? "vladmandic" : t.includes("automatic1111") ? "automatic1111" : t.includes("lllyasviel") || t.includes("forge") ? "forge" : n.includes("sdnext") || r.some((e) => e.includes("sdnext")) ? "vladmandic" : n.includes("forge") || r.some((e) => e.includes("forge")) ? "forge" : e.commit ? "automatic1111" : "unknown";
|
|
68
|
+
}
|
|
69
|
+
function y(e) {
|
|
70
|
+
return e < 4e3 ? "lowvram" : e < 8e3 ? "medvram" : e < 12e3 ? "medvram-sdxl" : "none";
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region packages/plugins/sd-webui/params.ts
|
|
74
|
+
var b = [
|
|
75
|
+
{
|
|
76
|
+
id: "performance",
|
|
77
|
+
label: "性能优化",
|
|
78
|
+
icon: "i-lucide-zap",
|
|
79
|
+
order: 1
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: "network",
|
|
83
|
+
label: "网络设置",
|
|
84
|
+
icon: "i-lucide-globe",
|
|
85
|
+
order: 2
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: "ui",
|
|
89
|
+
label: "界面设置",
|
|
90
|
+
icon: "i-lucide-palette",
|
|
91
|
+
order: 3
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: "security",
|
|
95
|
+
label: "安全设置",
|
|
96
|
+
icon: "i-lucide-shield",
|
|
97
|
+
order: 4,
|
|
98
|
+
collapsed: !0
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "advanced",
|
|
102
|
+
label: "高级选项",
|
|
103
|
+
icon: "i-lucide-settings-2",
|
|
104
|
+
order: 5,
|
|
105
|
+
collapsed: !0
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: "debug",
|
|
109
|
+
label: "调试选项",
|
|
110
|
+
icon: "i-lucide-bug",
|
|
111
|
+
order: 6,
|
|
112
|
+
collapsed: !0
|
|
113
|
+
}
|
|
114
|
+
], ee = [
|
|
115
|
+
{
|
|
116
|
+
id: "vramOptimization",
|
|
117
|
+
label: "VRAM 优化",
|
|
118
|
+
type: "select",
|
|
119
|
+
group: "performance",
|
|
120
|
+
order: 1,
|
|
121
|
+
audience: "basic",
|
|
122
|
+
options: [
|
|
123
|
+
{
|
|
124
|
+
value: m.None,
|
|
125
|
+
label: "无优化 (12GB+)",
|
|
126
|
+
description: "适用于 12GB 以上显存"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
value: m.MediumSdxl,
|
|
130
|
+
label: "SDXL 中等优化 (8GB+)",
|
|
131
|
+
description: "适用于 8GB 显存生成 SDXL",
|
|
132
|
+
available: { minCommit: "016554e43740e0b7ded75e89255de81270de9d6c" }
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
value: m.Medium,
|
|
136
|
+
label: "中等优化 (4GB+)",
|
|
137
|
+
description: "适用于 4-8GB 显存"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
value: m.Low,
|
|
141
|
+
label: "低显存优化",
|
|
142
|
+
description: "适用于 4GB 以下显存,性能较慢"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
value: m.Full,
|
|
146
|
+
label: "完全卸载到内存",
|
|
147
|
+
description: "将所有模型卸载到内存,极端低显存模式",
|
|
148
|
+
audience: "expert"
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
default: m.None,
|
|
152
|
+
defaultFn: (e) => y(e.vramMB)
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "xattnOptimization",
|
|
156
|
+
label: "注意力优化",
|
|
157
|
+
type: "select",
|
|
158
|
+
group: "performance",
|
|
159
|
+
order: 2,
|
|
160
|
+
audience: "basic",
|
|
161
|
+
available: { not: { forks: ["vladmandic"] } },
|
|
162
|
+
options: [
|
|
163
|
+
{
|
|
164
|
+
value: h.AutoXformers,
|
|
165
|
+
label: "自动 (xformers)",
|
|
166
|
+
available: { minCommit: "dc1117233ef8f9b25ff1ac40b158f20b70ba2fcb" }
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: h.ForceXformers,
|
|
170
|
+
label: "强制 xformers",
|
|
171
|
+
audience: "advanced",
|
|
172
|
+
available: { minCommit: "3061cdb7b610d4ba7f1ea695d9d6364b591e5bc7" }
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: h.XformersFlashAttention,
|
|
176
|
+
label: "xformers + Flash Attention",
|
|
177
|
+
available: { minCommit: "3262e825cc542ff634e6ba2e3a162eafdc6c1bba" }
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
value: h.ScaledDotProduct,
|
|
181
|
+
label: "Scaled Dot Product",
|
|
182
|
+
available: { minCommit: "fec0a895119a124a295e3dad5205de5766031dc7" }
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
value: h.ScaledDotProductNoMem,
|
|
186
|
+
label: "SDP (无内存优化)",
|
|
187
|
+
available: { minCommit: "37acba263389e22bc46cfffc80b2ca8b76a85287" }
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
value: h.SubQuad,
|
|
191
|
+
label: "Sub-Quadratic",
|
|
192
|
+
available: { minCommit: "d782a95967c9eea753df3333cd1954b6ec73eba0" }
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
value: h.Auto,
|
|
196
|
+
label: "自动 (PyTorch 默认)"
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
value: h.ForceDoggettx,
|
|
200
|
+
label: "Doggettx 分割注意力"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
value: h.ForceInvokeAI,
|
|
204
|
+
label: "InvokeAI 分割注意力"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
value: h.ForceV1,
|
|
208
|
+
label: "V1 旧版分割",
|
|
209
|
+
audience: "expert"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
value: h.Disable,
|
|
213
|
+
label: "禁用优化",
|
|
214
|
+
audience: "expert"
|
|
215
|
+
}
|
|
216
|
+
],
|
|
217
|
+
default: h.AutoXformers
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: "noHalf",
|
|
221
|
+
label: "禁用半精度",
|
|
222
|
+
description: "使用全精度浮点数,增加显存使用但可能提高兼容性",
|
|
223
|
+
type: "boolean",
|
|
224
|
+
group: "performance",
|
|
225
|
+
order: 3,
|
|
226
|
+
audience: "advanced",
|
|
227
|
+
default: !1,
|
|
228
|
+
defaultFn: (e) => e.useCPU || !e.supportsHalfPrecision,
|
|
229
|
+
cli: "--no-half",
|
|
230
|
+
warning: "启用后会显著增加显存使用"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "noHalfVae",
|
|
234
|
+
label: "禁用 VAE 半精度",
|
|
235
|
+
description: "VAE 使用全精度,可解决某些图像问题",
|
|
236
|
+
type: "boolean",
|
|
237
|
+
group: "performance",
|
|
238
|
+
order: 4,
|
|
239
|
+
audience: "advanced",
|
|
240
|
+
default: !1,
|
|
241
|
+
defaultFn: (e) => !e.supportsHalfPrecision,
|
|
242
|
+
cli: "--no-half-vae"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: "upcastSampling",
|
|
246
|
+
label: "Upcast Sampling",
|
|
247
|
+
description: "采样时使用高精度,可改善某些情况下的图像质量",
|
|
248
|
+
type: "boolean",
|
|
249
|
+
group: "performance",
|
|
250
|
+
order: 5,
|
|
251
|
+
audience: "advanced",
|
|
252
|
+
available: { minCommit: "84d9ce30cb427759547bc7876ed80ab91787d175" },
|
|
253
|
+
default: !1,
|
|
254
|
+
defaultFn: (e) => e.selection?.backend === "directml",
|
|
255
|
+
cli: "--upcast-sampling"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
id: "optChannelsLast",
|
|
259
|
+
label: "Channels Last 内存格式",
|
|
260
|
+
description: "使用 Channels Last 内存格式优化性能(仅 CUDA)",
|
|
261
|
+
type: "boolean",
|
|
262
|
+
group: "performance",
|
|
263
|
+
order: 6,
|
|
264
|
+
audience: "advanced",
|
|
265
|
+
available: { backend: ["cuda"] },
|
|
266
|
+
default: !1,
|
|
267
|
+
cli: "--opt-channelslast"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: "disableNanCheck",
|
|
271
|
+
label: "禁用 NaN 检查",
|
|
272
|
+
type: "boolean",
|
|
273
|
+
group: "performance",
|
|
274
|
+
order: 7,
|
|
275
|
+
audience: "expert",
|
|
276
|
+
available: { minCommit: "c361b89026442f3412162657f330d500b803e052" },
|
|
277
|
+
default: !1,
|
|
278
|
+
cli: "--disable-nan-check"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
id: "alwaysBatchCondUncond",
|
|
282
|
+
label: "总是批处理条件",
|
|
283
|
+
description: "低显存模式下批处理条件和非条件去噪",
|
|
284
|
+
type: "boolean",
|
|
285
|
+
group: "performance",
|
|
286
|
+
order: 8,
|
|
287
|
+
audience: "expert",
|
|
288
|
+
showWhen: { or: [{
|
|
289
|
+
param: "vramOptimization",
|
|
290
|
+
equals: m.Low
|
|
291
|
+
}, {
|
|
292
|
+
param: "vramOptimization",
|
|
293
|
+
equals: m.Medium
|
|
294
|
+
}] },
|
|
295
|
+
available: { and: [{ not: { forks: ["vladmandic"] } }, { maxCommit: "d02c4da483a656331f641224fe5da5f694580066" }] },
|
|
296
|
+
default: !1,
|
|
297
|
+
cli: "--always-batch-cond-uncond"
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: "cudaAllocatorBackend",
|
|
301
|
+
label: "CUDA 内存分配器",
|
|
302
|
+
type: "select",
|
|
303
|
+
group: "performance",
|
|
304
|
+
order: 9,
|
|
305
|
+
audience: "expert",
|
|
306
|
+
available: { backend: ["cuda"] },
|
|
307
|
+
options: [{
|
|
308
|
+
value: _.Native,
|
|
309
|
+
label: "原生分配器"
|
|
310
|
+
}, {
|
|
311
|
+
value: _.CudaMallocAsync,
|
|
312
|
+
label: "cudaMallocAsync (推荐)",
|
|
313
|
+
available: { backendFeature: "memoryPools" }
|
|
314
|
+
}],
|
|
315
|
+
default: _.Native,
|
|
316
|
+
defaultFn: (e) => e.selection?.features.memoryPools ? _.CudaMallocAsync : _.Native
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: "useAccelerate",
|
|
320
|
+
label: "使用 Accelerate",
|
|
321
|
+
description: "通过 Accelerate 库启动,支持分布式训练",
|
|
322
|
+
type: "boolean",
|
|
323
|
+
group: "performance",
|
|
324
|
+
order: 10,
|
|
325
|
+
audience: "expert",
|
|
326
|
+
default: !1
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: "port",
|
|
330
|
+
label: "端口",
|
|
331
|
+
type: "port",
|
|
332
|
+
group: "network",
|
|
333
|
+
order: 1,
|
|
334
|
+
audience: "basic",
|
|
335
|
+
min: 1,
|
|
336
|
+
max: 65535,
|
|
337
|
+
default: 7860,
|
|
338
|
+
cli: {
|
|
339
|
+
arg: "--port",
|
|
340
|
+
format: "value",
|
|
341
|
+
when: "changed"
|
|
342
|
+
}
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
id: "listen",
|
|
346
|
+
label: "监听所有地址",
|
|
347
|
+
description: "允许从其他设备访问 WebUI",
|
|
348
|
+
type: "boolean",
|
|
349
|
+
group: "network",
|
|
350
|
+
order: 2,
|
|
351
|
+
audience: "basic",
|
|
352
|
+
default: !1,
|
|
353
|
+
cli: "--listen",
|
|
354
|
+
warning: "启用后任何能访问你网络的人都可以使用 WebUI"
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
id: "serverName",
|
|
358
|
+
label: "服务器地址",
|
|
359
|
+
description: "指定服务器绑定地址(留空使用 127.0.0.1)",
|
|
360
|
+
type: "string",
|
|
361
|
+
group: "network",
|
|
362
|
+
order: 3,
|
|
363
|
+
audience: "advanced",
|
|
364
|
+
placeholder: "127.0.0.1",
|
|
365
|
+
default: "",
|
|
366
|
+
cli: {
|
|
367
|
+
arg: "--server-name",
|
|
368
|
+
format: "value",
|
|
369
|
+
when: "truthy"
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
id: "share",
|
|
374
|
+
label: "Gradio Share",
|
|
375
|
+
description: "创建公共 Gradio 链接",
|
|
376
|
+
type: "boolean",
|
|
377
|
+
group: "network",
|
|
378
|
+
order: 4,
|
|
379
|
+
audience: "advanced",
|
|
380
|
+
default: !1,
|
|
381
|
+
cli: "--share",
|
|
382
|
+
warning: "会创建一个可从互联网访问的公共链接"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: "gradioAuth",
|
|
386
|
+
label: "Gradio 认证",
|
|
387
|
+
description: "设置 WebUI 访问密码(格式:用户名:密码)",
|
|
388
|
+
type: "string",
|
|
389
|
+
group: "network",
|
|
390
|
+
order: 5,
|
|
391
|
+
audience: "advanced",
|
|
392
|
+
placeholder: "admin:password",
|
|
393
|
+
default: "",
|
|
394
|
+
cli: {
|
|
395
|
+
arg: "--gradio-auth",
|
|
396
|
+
format: "value",
|
|
397
|
+
when: "truthy"
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "apiAuth",
|
|
402
|
+
label: "API 认证",
|
|
403
|
+
description: "设置 API 访问密码(格式:用户名:密码)",
|
|
404
|
+
type: "string",
|
|
405
|
+
group: "network",
|
|
406
|
+
order: 6,
|
|
407
|
+
audience: "advanced",
|
|
408
|
+
placeholder: "admin:password",
|
|
409
|
+
default: "",
|
|
410
|
+
cli: {
|
|
411
|
+
arg: "--api-auth",
|
|
412
|
+
format: "value",
|
|
413
|
+
when: "truthy"
|
|
414
|
+
}
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
id: "corsDomains",
|
|
418
|
+
label: "CORS 允许域名",
|
|
419
|
+
description: "允许跨域请求的域名列表(逗号分隔)",
|
|
420
|
+
type: "string",
|
|
421
|
+
group: "network",
|
|
422
|
+
order: 7,
|
|
423
|
+
audience: "expert",
|
|
424
|
+
placeholder: "http://localhost:3000",
|
|
425
|
+
default: ""
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
id: "theme",
|
|
429
|
+
label: "主题",
|
|
430
|
+
type: "select",
|
|
431
|
+
group: "ui",
|
|
432
|
+
order: 1,
|
|
433
|
+
audience: "basic",
|
|
434
|
+
available: { not: { forks: ["vladmandic"] } },
|
|
435
|
+
options: [
|
|
436
|
+
{
|
|
437
|
+
value: g.FollowLauncher,
|
|
438
|
+
label: "跟随启动器"
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
value: g.Auto,
|
|
442
|
+
label: "跟随系统"
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
value: g.Light,
|
|
446
|
+
label: "浅色"
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
value: g.Dark,
|
|
450
|
+
label: "深色"
|
|
451
|
+
}
|
|
452
|
+
],
|
|
453
|
+
default: g.FollowLauncher
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
id: "autoLaunch",
|
|
457
|
+
label: "自动打开浏览器",
|
|
458
|
+
type: "boolean",
|
|
459
|
+
group: "ui",
|
|
460
|
+
order: 2,
|
|
461
|
+
audience: "basic",
|
|
462
|
+
default: !1,
|
|
463
|
+
cli: "--autolaunch"
|
|
464
|
+
},
|
|
465
|
+
{
|
|
466
|
+
id: "freezeSettings",
|
|
467
|
+
label: "冻结设置",
|
|
468
|
+
description: "禁止通过 WebUI 修改设置",
|
|
469
|
+
type: "boolean",
|
|
470
|
+
group: "ui",
|
|
471
|
+
order: 3,
|
|
472
|
+
audience: "advanced",
|
|
473
|
+
default: !1,
|
|
474
|
+
cli: "--freeze-settings"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
id: "api",
|
|
478
|
+
label: "启用 API",
|
|
479
|
+
type: "boolean",
|
|
480
|
+
group: "security",
|
|
481
|
+
order: 1,
|
|
482
|
+
audience: "basic",
|
|
483
|
+
available: { not: { forks: ["vladmandic"] } },
|
|
484
|
+
default: !0,
|
|
485
|
+
cli: "--api"
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
id: "noWebUi",
|
|
489
|
+
label: "仅 API 模式",
|
|
490
|
+
description: "禁用 Web 界面,只运行 API",
|
|
491
|
+
type: "boolean",
|
|
492
|
+
group: "security",
|
|
493
|
+
order: 2,
|
|
494
|
+
audience: "advanced",
|
|
495
|
+
available: { not: { forks: ["vladmandic"] } },
|
|
496
|
+
default: !1,
|
|
497
|
+
cli: "--nowebui"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
id: "enableInsecureExtensionAccess",
|
|
501
|
+
label: "允许不安全扩展访问",
|
|
502
|
+
description: "允许扩展访问系统资源",
|
|
503
|
+
type: "boolean",
|
|
504
|
+
group: "security",
|
|
505
|
+
order: 3,
|
|
506
|
+
audience: "advanced",
|
|
507
|
+
default: !1,
|
|
508
|
+
warning: "可能存在安全风险"
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
id: "disableSafeUnpickle",
|
|
512
|
+
label: "禁用安全反序列化",
|
|
513
|
+
description: "禁用 pickle 安全检查",
|
|
514
|
+
type: "boolean",
|
|
515
|
+
group: "security",
|
|
516
|
+
order: 4,
|
|
517
|
+
audience: "expert",
|
|
518
|
+
default: !1,
|
|
519
|
+
cli: "--disable-safe-unpickle",
|
|
520
|
+
warning: "可能加载恶意模型,请确保模型来源可信"
|
|
521
|
+
},
|
|
522
|
+
{
|
|
523
|
+
id: "allowCode",
|
|
524
|
+
label: "允许代码执行",
|
|
525
|
+
description: "允许通过 API 执行代码",
|
|
526
|
+
type: "boolean",
|
|
527
|
+
group: "security",
|
|
528
|
+
order: 5,
|
|
529
|
+
audience: "expert",
|
|
530
|
+
default: !1,
|
|
531
|
+
cli: "--allow-code",
|
|
532
|
+
warning: "严重安全风险,不建议启用"
|
|
533
|
+
},
|
|
534
|
+
{
|
|
535
|
+
id: "skipInstall",
|
|
536
|
+
label: "跳过依赖安装",
|
|
537
|
+
description: "跳过启动时的依赖检查和安装",
|
|
538
|
+
type: "boolean",
|
|
539
|
+
group: "advanced",
|
|
540
|
+
order: 1,
|
|
541
|
+
audience: "expert",
|
|
542
|
+
default: !1,
|
|
543
|
+
env: (e) => e ? { PIP_NO_DEPS: "true" } : {}
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
id: "noHashing",
|
|
547
|
+
label: "禁用模型哈希",
|
|
548
|
+
type: "boolean",
|
|
549
|
+
group: "advanced",
|
|
550
|
+
order: 2,
|
|
551
|
+
audience: "advanced",
|
|
552
|
+
available: { minCommit: "81823407d9b3c3daf2f9de59e0d75ef9a257f902" },
|
|
553
|
+
default: !1,
|
|
554
|
+
cli: "--no-hashing"
|
|
555
|
+
},
|
|
556
|
+
{
|
|
557
|
+
id: "gradioQueue",
|
|
558
|
+
label: "启用 Gradio 队列",
|
|
559
|
+
type: "boolean",
|
|
560
|
+
group: "advanced",
|
|
561
|
+
order: 3,
|
|
562
|
+
audience: "expert",
|
|
563
|
+
available: { and: [{ minCommit: "63b824376c49013880ff44c260ea426e2899511e" }, { maxCommit: "43a0912a07376fd045095de0fea54de098b113ef" }] },
|
|
564
|
+
default: !1,
|
|
565
|
+
cli: "--gradio-queue"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
id: "noGradioQueue",
|
|
569
|
+
label: "禁用 Gradio 队列",
|
|
570
|
+
type: "boolean",
|
|
571
|
+
group: "advanced",
|
|
572
|
+
order: 4,
|
|
573
|
+
audience: "expert",
|
|
574
|
+
available: { minCommit: "af2db25c84c9a226ab34959e868fc18740418b4b" },
|
|
575
|
+
default: !1
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
id: "huggingfaceOfflineMode",
|
|
579
|
+
label: "Huggingface 离线模式",
|
|
580
|
+
description: "禁用 Huggingface 在线下载",
|
|
581
|
+
type: "boolean",
|
|
582
|
+
group: "advanced",
|
|
583
|
+
order: 5,
|
|
584
|
+
audience: "advanced",
|
|
585
|
+
default: !1,
|
|
586
|
+
env: (e) => e ? {
|
|
587
|
+
TRANSFORMERS_OFFLINE: "1",
|
|
588
|
+
HF_HUB_OFFLINE: "1"
|
|
589
|
+
} : {}
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
id: "launchLiveOutput",
|
|
593
|
+
label: "启动实时输出",
|
|
594
|
+
type: "boolean",
|
|
595
|
+
group: "advanced",
|
|
596
|
+
order: 6,
|
|
597
|
+
audience: "advanced",
|
|
598
|
+
default: !1,
|
|
599
|
+
env: {
|
|
600
|
+
name: "WEBUI_LAUNCH_LIVE_OUTPUT",
|
|
601
|
+
format: "boolean"
|
|
602
|
+
}
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
id: "extraArgs",
|
|
606
|
+
label: "额外启动参数",
|
|
607
|
+
type: "text",
|
|
608
|
+
group: "advanced",
|
|
609
|
+
order: 100,
|
|
610
|
+
audience: "expert",
|
|
611
|
+
placeholder: "--custom-arg value",
|
|
612
|
+
default: ""
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
id: "uiDebugMode",
|
|
616
|
+
label: "UI 调试模式",
|
|
617
|
+
type: "boolean",
|
|
618
|
+
group: "debug",
|
|
619
|
+
order: 1,
|
|
620
|
+
audience: "expert",
|
|
621
|
+
available: { not: { forks: ["vladmandic"] } },
|
|
622
|
+
default: !1,
|
|
623
|
+
cli: "--ui-debug-mode"
|
|
624
|
+
}
|
|
625
|
+
], te = [
|
|
626
|
+
{
|
|
627
|
+
id: "default",
|
|
628
|
+
name: "默认",
|
|
629
|
+
description: "使用默认配置启动",
|
|
630
|
+
icon: "i-lucide-rocket",
|
|
631
|
+
params: {},
|
|
632
|
+
isDefault: !0
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
id: "low-vram",
|
|
636
|
+
name: "低显存",
|
|
637
|
+
description: "适用于 4GB 以下显存",
|
|
638
|
+
icon: "i-lucide-gauge",
|
|
639
|
+
params: {
|
|
640
|
+
vramOptimization: m.Low,
|
|
641
|
+
xattnOptimization: h.ScaledDotProduct,
|
|
642
|
+
noHalfVae: !0
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
id: "sdxl-optimized",
|
|
647
|
+
name: "SDXL 优化",
|
|
648
|
+
description: "适用于 SDXL 模型生成",
|
|
649
|
+
icon: "i-lucide-image",
|
|
650
|
+
params: {
|
|
651
|
+
vramOptimization: m.MediumSdxl,
|
|
652
|
+
xattnOptimization: h.ScaledDotProduct
|
|
653
|
+
},
|
|
654
|
+
available: { minCommit: "016554e43740e0b7ded75e89255de81270de9d6c" }
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
id: "api-only",
|
|
658
|
+
name: "仅 API",
|
|
659
|
+
description: "无 Web 界面,仅运行 API",
|
|
660
|
+
icon: "i-lucide-terminal",
|
|
661
|
+
params: {
|
|
662
|
+
api: !0,
|
|
663
|
+
noWebUi: !0
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
id: "share",
|
|
668
|
+
name: "公开分享",
|
|
669
|
+
description: "创建公共访问链接",
|
|
670
|
+
icon: "i-lucide-share-2",
|
|
671
|
+
params: {
|
|
672
|
+
share: !0,
|
|
673
|
+
listen: !0
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
], x = "garbage_collection_threshold:0.9,max_split_size_mb:512";
|
|
677
|
+
function S(e, t, n = !1) {
|
|
678
|
+
let r = [];
|
|
679
|
+
for (let i = 0; i < e.length; i += 1) {
|
|
680
|
+
if (e[i] !== t) {
|
|
681
|
+
r.push(e[i]);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
n && i + 1 < e.length && (i += 1);
|
|
685
|
+
}
|
|
686
|
+
return r;
|
|
687
|
+
}
|
|
688
|
+
function ne(e, t, n) {
|
|
689
|
+
if (e.repo?.forkId === "vladmandic") return t;
|
|
690
|
+
let r = [...t];
|
|
691
|
+
r = S(r, "--no-half"), r = S(r, "--no-half-vae"), r = S(r, "--upcast-sampling"), r = S(r, "--precision", !0);
|
|
692
|
+
let i = e.selection?.backend, a = e.getParam("noHalf", !1), o = e.getParam("noHalfVae", !1), s = e.getParam("upcastSampling", !1), c = i === "cpu" || i === "directml", l = i === "cpu" || a;
|
|
693
|
+
return s && (e.isCommitAfter("84d9ce30cb427759547bc7876ed80ab91787d175") && !l ? r.push("--upcast-sampling") : (l = !0, n.push("当前源码版本不支持 upcast-sampling,已回退到 no-half"))), c && r.push("--precision", "full"), l && r.push("--no-half"), o && !l ? r.push("--no-half-vae") : o && l && n.push("no-half 已覆盖 VAE 精度设置,no-half-vae 已省略"), r;
|
|
694
|
+
}
|
|
695
|
+
function re(e) {
|
|
696
|
+
return e ? [
|
|
697
|
+
"-m",
|
|
698
|
+
"accelerate.commands.launch",
|
|
699
|
+
"--num_cpu_threads_per_process=6"
|
|
700
|
+
] : [];
|
|
701
|
+
}
|
|
702
|
+
function C(e) {
|
|
703
|
+
let t = [];
|
|
704
|
+
switch (e.getParam("vramOptimization", m.None)) {
|
|
705
|
+
case m.Low:
|
|
706
|
+
t.push("--lowvram");
|
|
707
|
+
break;
|
|
708
|
+
case m.Medium:
|
|
709
|
+
t.push("--medvram");
|
|
710
|
+
break;
|
|
711
|
+
case m.MediumSdxl:
|
|
712
|
+
e.isCommitAfter("016554e43740e0b7ded75e89255de81270de9d6c") ? t.push("--medvram-sdxl") : t.push("--medvram");
|
|
713
|
+
break;
|
|
714
|
+
case m.Full: t.push("--lowram");
|
|
715
|
+
}
|
|
716
|
+
return t;
|
|
717
|
+
}
|
|
718
|
+
function w(e) {
|
|
719
|
+
let t = [];
|
|
720
|
+
if (e.repo?.forkId === "vladmandic") return t;
|
|
721
|
+
switch (e.getParam("xattnOptimization", h.AutoXformers)) {
|
|
722
|
+
case h.AutoXformers:
|
|
723
|
+
e.selection?.backend === "directml" && e.isCommitAfter("d782a95967c9eea753df3333cd1954b6ec73eba0") ? t.push("--opt-sub-quad-attention") : e.isCommitAfter("dc1117233ef8f9b25ff1ac40b158f20b70ba2fcb") && t.push("--xformers");
|
|
724
|
+
break;
|
|
725
|
+
case h.ForceXformers:
|
|
726
|
+
e.isCommitAfter("3061cdb7b610d4ba7f1ea695d9d6364b591e5bc7") && t.push("--force-enable-xformers");
|
|
727
|
+
break;
|
|
728
|
+
case h.XformersFlashAttention:
|
|
729
|
+
e.isCommitAfter("3262e825cc542ff634e6ba2e3a162eafdc6c1bba") && (t.push("--xformers"), t.push("--xformers-flash-attention"));
|
|
730
|
+
break;
|
|
731
|
+
case h.ScaledDotProduct:
|
|
732
|
+
e.isCommitAfter("fec0a895119a124a295e3dad5205de5766031dc7") && t.push("--opt-sdp-attention");
|
|
733
|
+
break;
|
|
734
|
+
case h.ScaledDotProductNoMem:
|
|
735
|
+
e.isCommitAfter("37acba263389e22bc46cfffc80b2ca8b76a85287") && t.push("--opt-sdp-no-mem-attention");
|
|
736
|
+
break;
|
|
737
|
+
case h.SubQuad:
|
|
738
|
+
e.isCommitAfter("d782a95967c9eea753df3333cd1954b6ec73eba0") && t.push("--opt-sub-quad-attention");
|
|
739
|
+
break;
|
|
740
|
+
case h.ForceDoggettx:
|
|
741
|
+
t.push("--opt-split-attention");
|
|
742
|
+
break;
|
|
743
|
+
case h.ForceInvokeAI:
|
|
744
|
+
t.push("--opt-split-attention-invokeai");
|
|
745
|
+
break;
|
|
746
|
+
case h.ForceV1:
|
|
747
|
+
t.push("--opt-split-attention-v1");
|
|
748
|
+
break;
|
|
749
|
+
case h.Disable: t.push("--disable-opt-split-attention");
|
|
750
|
+
}
|
|
751
|
+
return t;
|
|
752
|
+
}
|
|
753
|
+
function T(e) {
|
|
754
|
+
let t = [];
|
|
755
|
+
if (e.repo?.forkId === "vladmandic") return t;
|
|
756
|
+
switch (e.getParam("theme", g.FollowLauncher)) {
|
|
757
|
+
case g.Light:
|
|
758
|
+
t.push("--theme", "light");
|
|
759
|
+
break;
|
|
760
|
+
case g.Dark: t.push("--theme", "dark");
|
|
761
|
+
}
|
|
762
|
+
return t;
|
|
763
|
+
}
|
|
764
|
+
function E(e) {
|
|
765
|
+
let t = [], n = e.getParam("corsDomains", "");
|
|
766
|
+
if (!n) return t;
|
|
767
|
+
let r = n.split(",").map((e) => e.trim()).filter(Boolean), i = r.some((e) => e.includes("*"));
|
|
768
|
+
for (let e of r) i ? t.push("--cors-allow-origins-regex", e.replace(/\*/g, ".*")) : t.push("--cors-allow-origins", e);
|
|
769
|
+
return t;
|
|
770
|
+
}
|
|
771
|
+
function ie(e, t) {
|
|
772
|
+
return e.repo?.forkId !== "vladmandic" && ![
|
|
773
|
+
"cuda",
|
|
774
|
+
"hip",
|
|
775
|
+
"zluda"
|
|
776
|
+
].includes(t);
|
|
777
|
+
}
|
|
778
|
+
function ae(e, t) {
|
|
779
|
+
let n = e.selection?.gpuOrdinal;
|
|
780
|
+
return n === void 0 ? !1 : e.getParam("useAccelerate", !1) ? !0 : n !== 0 && ![
|
|
781
|
+
"cuda",
|
|
782
|
+
"cpu",
|
|
783
|
+
"hip",
|
|
784
|
+
"zluda",
|
|
785
|
+
"level-zero"
|
|
786
|
+
].includes(t);
|
|
787
|
+
}
|
|
788
|
+
function oe(e, t, n) {
|
|
789
|
+
n.CUDA_VISIBLE_DEVICES = t === "cuda" && e.selection?.gpuOrdinal !== void 0 ? String(e.selection.gpuOrdinal) : "-1", n.HIP_VISIBLE_DEVICES = ["hip", "zluda"].includes(t) && e.selection?.gpuOrdinal !== void 0 ? String(e.selection.gpuOrdinal) : "-1", n.ONEAPI_DEVICE_SELECTOR = t === "level-zero" && e.selection?.gpuOrdinal !== void 0 ? `level_zero:${e.selection.gpuOrdinal}` : "!*";
|
|
790
|
+
}
|
|
791
|
+
async function D(e, t, n) {
|
|
792
|
+
let r = "modules/cmd_args.py", i = await e.hasFeature({ fileContains: {
|
|
793
|
+
path: r,
|
|
794
|
+
pattern: "--backend"
|
|
795
|
+
} }), a = await e.hasFeature({ fileContains: {
|
|
796
|
+
path: r,
|
|
797
|
+
pattern: "--device-name"
|
|
798
|
+
} });
|
|
799
|
+
i && n.push("--backend", t), a && n.push("--device-name", t);
|
|
800
|
+
}
|
|
801
|
+
function se(e) {
|
|
802
|
+
throw Error(`Unsupported backend: ${e}`);
|
|
803
|
+
}
|
|
804
|
+
async function ce(e) {
|
|
805
|
+
let t = [], n = {}, r = e.selection?.backend;
|
|
806
|
+
if (!r) return {
|
|
807
|
+
args: t,
|
|
808
|
+
env: n
|
|
809
|
+
};
|
|
810
|
+
switch (oe(e, r, n), r) {
|
|
811
|
+
case "cuda":
|
|
812
|
+
n.PYTORCH_CUDA_ALLOC_CONF = e.getParam("cudaAllocatorBackend", _.Native) === _.CudaMallocAsync ? "backend:cudaMallocAsync" : x, e.selection?.features.bf16 && (n.TORCH_CUDNN_V8_API_ENABLED = "1", n.CUDA_MODULE_LOADING = "LAZY"), await D(e, "cuda", t);
|
|
813
|
+
break;
|
|
814
|
+
case "hip":
|
|
815
|
+
n.PYTORCH_HIP_ALLOC_CONF = x;
|
|
816
|
+
break;
|
|
817
|
+
case "zluda":
|
|
818
|
+
n.PYTORCH_HIP_ALLOC_CONF = x, t.push("--use-cpu", "interrogate");
|
|
819
|
+
break;
|
|
820
|
+
case "directml":
|
|
821
|
+
t.push("--use-directml"), await D(e, "directml", t);
|
|
822
|
+
break;
|
|
823
|
+
case "level-zero":
|
|
824
|
+
t.push("--use-ipex");
|
|
825
|
+
break;
|
|
826
|
+
case "mps": break;
|
|
827
|
+
case "cpu":
|
|
828
|
+
t.push("--use-cpu", "all");
|
|
829
|
+
break;
|
|
830
|
+
default: se(r);
|
|
831
|
+
}
|
|
832
|
+
return ae(e, r) && t.push("--device-id", String(e.selection?.gpuOrdinal)), ie(e, r) && t.push("--skip-torch-cuda-test"), {
|
|
833
|
+
args: t,
|
|
834
|
+
env: n
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
async function le(e, t, n) {
|
|
838
|
+
return n.launch.compileLaunchProvider(e, t, async ({ ctx: e, build: t }) => {
|
|
839
|
+
let n = [], r = [...t.args], i = { ...t.env };
|
|
840
|
+
r.push(...C(e)), r.push(...w(e)), r.push(...T(e)), r.push(...E(e));
|
|
841
|
+
let a = await ce(e);
|
|
842
|
+
r.push(...a.args), Object.assign(i, a.env);
|
|
843
|
+
let o = e.getParam("listen", !1), s = e.getParam("share", !1), c = e.getParam("enableInsecureExtensionAccess", !1);
|
|
844
|
+
if ((o || s) && c && e.isCommitAfter("dc1117233ef8f9b25ff1ac40b158f20b70ba2fcb") && r.push("--enable-insecure-extension-access"), e.getParam("skipInstall", !1) && (e.repo?.forkId === "vladmandic" ? r.push("--skip-requirements", "--skip-extensions", "--skip-git", "--skip-torch") : e.isCommitAfter("e79a0e09f5a5e50aeb8b13b0a1b6d12f4c18a5ea") && r.push("--skip-install")), e.repo?.forkId === "vladmandic" && (i.TORCH_COMMAND = "skip", i.XFORMERS_PACKAGE = "skip", e.getParam("noWebUi", !1))) {
|
|
845
|
+
let e = r.indexOf("--nowebui");
|
|
846
|
+
e !== -1 && (r[e] = "--api-only");
|
|
847
|
+
}
|
|
848
|
+
if (r = ne(e, r, n), r.includes("--lowvram") && r.includes("--medvram") && (n.push("lowvram 和 medvram 同时启用,将使用 lowvram"), r = S(r, "--medvram")), r.includes("--no-half")) {
|
|
849
|
+
let e = r.includes("--no-half-vae");
|
|
850
|
+
r = S(r, "--no-half-vae"), e && n.push("no-half 已包含 VAE,no-half-vae 是多余的");
|
|
851
|
+
}
|
|
852
|
+
return {
|
|
853
|
+
args: r,
|
|
854
|
+
env: i,
|
|
855
|
+
warnings: [...t.warnings, ...n]
|
|
856
|
+
};
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region packages/plugins/sd-webui/launch/preflight/actions.ts
|
|
861
|
+
function O() {
|
|
862
|
+
return {
|
|
863
|
+
id: u.OpenPythonSettings,
|
|
864
|
+
label: "Python 管理",
|
|
865
|
+
description: "打开 Python 管理页检查当前解释器和依赖"
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
function k() {
|
|
869
|
+
return {
|
|
870
|
+
id: u.RefreshHostCapabilities,
|
|
871
|
+
label: "重新探测",
|
|
872
|
+
description: "重新探测当前宿主 GPU 和后端能力"
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
function A() {
|
|
876
|
+
return {
|
|
877
|
+
id: u.ApplyBackendSelection,
|
|
878
|
+
label: "切到 CPU",
|
|
879
|
+
description: "将启动后端切换到 CPU 兜底",
|
|
880
|
+
payload: { backend: "cpu" },
|
|
881
|
+
confirm: !1
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function j(e, t, n) {
|
|
885
|
+
return {
|
|
886
|
+
id: u.ApplyLaunchParam,
|
|
887
|
+
label: n,
|
|
888
|
+
description: "写回推荐启动参数",
|
|
889
|
+
payload: {
|
|
890
|
+
paramId: e,
|
|
891
|
+
value: t
|
|
892
|
+
},
|
|
893
|
+
confirm: !1
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region packages/plugins/sd-webui/launch/preflight/probe-values.ts
|
|
898
|
+
function M(e) {
|
|
899
|
+
if (!e) return;
|
|
900
|
+
let t = e.match(/^(\d+)/);
|
|
901
|
+
if (!t) return;
|
|
902
|
+
let n = Number.parseInt(t[1], 10);
|
|
903
|
+
return Number.isNaN(n) ? void 0 : n;
|
|
904
|
+
}
|
|
905
|
+
function N(e, t) {
|
|
906
|
+
let n = e?.[t];
|
|
907
|
+
return typeof n == "string" ? n : void 0;
|
|
908
|
+
}
|
|
909
|
+
function P(e, t) {
|
|
910
|
+
let n = e?.[t];
|
|
911
|
+
return typeof n == "boolean" ? n : void 0;
|
|
912
|
+
}
|
|
913
|
+
function F(e) {
|
|
914
|
+
return e === "failed" ? {
|
|
915
|
+
message: "读取 Python runtime 事实失败,无法提前验证 torch/onnxruntime 兼容性",
|
|
916
|
+
suggestion: "请检查已配置的 Python 路径是否可执行,并确认运行时探测 RPC 可正常返回"
|
|
917
|
+
} : {
|
|
918
|
+
message: "尚未读取 Python runtime 事实,无法提前验证 torch/onnxruntime 兼容性",
|
|
919
|
+
suggestion: "建议为该实例配置 Python 环境,以便在启动前完成后端兼容性检查"
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
//#endregion
|
|
923
|
+
//#region packages/plugins/sd-webui/launch/preflight/backend-runtime-checks.ts
|
|
924
|
+
function I(e, r, i) {
|
|
925
|
+
let a = e.runtime.status === "collected", o = n(i["torch-runtime"]), s = n(i["onnxruntime-cuda"]), c = N(o, "cuda_version") || e.runtime.torch?.cudaVersion, l = P(s, "use_cuda") ?? e.runtime.onnxruntime?.useCuda ?? !1, u = !!(i["torch-runtime"] && !o || i["onnxruntime-cuda"] && !s), d = [], f = P(o, "cuda_available"), p = !!(o || s || a), m = !!(o || a), h = f === !0 || !!c || l;
|
|
926
|
+
f === !1 || m && !h ? d.push(t("sd-webui-cuda-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到 CUDA 版 torch/onnxruntime,CUDA backend 无法完成闭环", "请确认该环境已安装 CUDA 版 PyTorch,或切换到 CPU 后端", [O(), A()])) : p && h ? d.push(t("sd-webui-cuda-runtime-ready", "runtime", !0, "info", "已检测到 CUDA 版 Python 包")) : u && d.push(t("sd-webui-cuda-runtime-probe-incomplete", "runtime", !1, "warning", "CUDA runtime 探测未返回可解析详情,暂不能提前确认 torch/onnxruntime 状态", "请重新探测当前 Python 环境;如果仍失败,再检查 Python 依赖或切换后端", [O()]));
|
|
927
|
+
let g = M(e.host.backends.cuda?.driverSupportedVersion), v = M(c);
|
|
928
|
+
g !== void 0 && v !== void 0 && g < v && d.push(t("sd-webui-cuda-driver-version", "runtime", !1, "error", `宿主驱动支持的 CUDA 主版本 ${g} 低于当前 torch 运行时要求的 ${v}`, "请升级显卡驱动,或切换到匹配当前驱动版本的 Python 环境", [O(), A()]));
|
|
929
|
+
let y = M(N(s, "cuda_version") || e.runtime.onnxruntime?.cudaVersion);
|
|
930
|
+
l && v !== void 0 && y !== void 0 && v !== y && d.push(t("sd-webui-onnxruntime-cuda-mismatch", "runtime", !1, "warning", `torch CUDA ${v} 与 onnxruntime CUDA ${y} 主版本不一致,可能导致部分扩展或推理链路异常`, "建议统一安装同一 CUDA 主版本构建的 torch 与 onnxruntime-gpu", [O()]));
|
|
931
|
+
let b = e.params.cudaAllocatorBackend;
|
|
932
|
+
if (b === _.CudaMallocAsync && !r.features.memoryPools) d.push(t("sd-webui-cuda-allocator-unsupported", "runtime", !1, "error", "当前 GPU/CUDA runtime 不支持 cudaMallocAsync,但参数里已经选择了该分配器", "请将 CUDA 内存分配器改回原生分配器", [j("cudaAllocatorBackend", _.Native, "改回原生分配器")]));
|
|
933
|
+
else if (b === _.CudaMallocAsync) {
|
|
934
|
+
let e = n(i["cuda-malloc-async"]), r = P(e, "cuda_available");
|
|
935
|
+
e && r === !1 && d.push(t("sd-webui-cuda-allocator-runtime", "runtime", !1, "error", "当前 Python 环境未通过 CUDA runtime 实探,不能安全启用 cudaMallocAsync", "请先确认 CUDA 版 torch 可用,或将 CUDA 内存分配器改回原生分配器", [O(), j("cudaAllocatorBackend", _.Native, "改回原生分配器")]));
|
|
936
|
+
}
|
|
937
|
+
return d;
|
|
938
|
+
}
|
|
939
|
+
function L(e, r, i) {
|
|
940
|
+
let a = e.runtime.status === "collected", o = n(i["torch-runtime"]), s = N(o, "cuda_version") || e.runtime.torch?.cudaVersion, c = N(o, "hip_version") || e.runtime.torch?.hipVersion, l = [], u = M(e.host.backends.hip?.version), d = M(c), f = M(s);
|
|
941
|
+
return (o || a) && !(r === "zluda" ? s : c) && l.push(t(r === "zluda" ? "sd-webui-zluda-runtime-missing" : "sd-webui-hip-runtime-missing", "runtime", !1, "error", r === "zluda" ? "当前 Python 环境未检测到 CUDA 版 PyTorch runtime,ZLUDA backend 无法完成闭环" : "当前 Python 环境未检测到 ROCm/HIP 版 PyTorch runtime,HIP backend 无法完成闭环", r === "zluda" ? "请切换到 CUDA 版 PyTorch,或改用 ROCm / DirectML / CPU" : "请切换到 ROCm 版 PyTorch,或改用 DirectML / CPU", [O(), A()])), r === "hip" && u !== void 0 && d !== void 0 && u < d && l.push(t("sd-webui-hip-driver-version", "runtime", !1, "warning", `宿主 ROCm/HIP 版本主号 ${u} 低于当前 torch 运行时要求的 ${d}`, "请升级 HIP/ROCm 运行时,或改用与当前系统版本匹配的 Python 环境", [O()])), r === "zluda" && e.host.os.name === "windows" && f === void 0 && l.push(t("sd-webui-zluda-cuda-runtime", "runtime", !1, "warning", "当前 ZLUDA 选择没有检测到 CUDA 版 torch 元数据,兼容层可能无法正常挂接", "建议改用明确的 CUDA 版 PyTorch 环境,或回退到 ROCm / DirectML")), l;
|
|
942
|
+
}
|
|
943
|
+
function R(e, i) {
|
|
944
|
+
let a = e.runtime.status === "collected", o = n(i["torch-runtime"]), s = P(o, "supports_directml") ?? e.runtime.torch?.supportsDirectML ?? !1;
|
|
945
|
+
return (o || a) && !(s || r(e.runtime, "torch-directml", "torch_directml")) ? [t("sd-webui-directml-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到 DirectML 版运行时,DirectML backend 不能正常启动", "请安装 torch-directml,或切换到其它后端", [O(), A()])] : [];
|
|
946
|
+
}
|
|
947
|
+
function z(e, i) {
|
|
948
|
+
let a = e.runtime.status === "collected", o = n(i["torch-runtime"]), s = P(o, "supports_ipex") ?? e.runtime.torch?.supportsIpex ?? !1, c = N(o, "xpu_version") || e.runtime.torch?.xpuVersion;
|
|
949
|
+
return (o || a) && !(s || c || r(e.runtime, "intel-extension-for-pytorch", "intel_extension_for_pytorch")) ? [t("sd-webui-level-zero-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到 IPEX/XPU 运行时,Level Zero backend 不能正常启动", "请安装 intel-extension-for-pytorch / XPU 版 torch,或切换到其它后端", [O(), A()])] : [];
|
|
950
|
+
}
|
|
951
|
+
function B(e) {
|
|
952
|
+
return P(n(e["torch-runtime"]), "mps_available") === !1 ? [t("sd-webui-mps-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到可用的 MPS runtime,MPS backend 无法启动", "请改用支持 MPS 的 PyTorch 环境,或切换到 CPU", [O(), A()])] : [];
|
|
953
|
+
}
|
|
954
|
+
function V(e, t, n) {
|
|
955
|
+
switch (t.backend) {
|
|
956
|
+
case "cuda": return I(e, t, n);
|
|
957
|
+
case "hip":
|
|
958
|
+
case "zluda": return L(e, t.backend, n);
|
|
959
|
+
case "directml": return R(e, n);
|
|
960
|
+
case "level-zero": return z(e, n);
|
|
961
|
+
case "mps": return B(n);
|
|
962
|
+
default: return [];
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function H(e, r) {
|
|
966
|
+
let i = [], a = e.params.xattnOptimization;
|
|
967
|
+
if (a === h.ForceXformers || a === h.XformersFlashAttention) {
|
|
968
|
+
let e = n(r["xformers-flash-attn"]);
|
|
969
|
+
a === h.ForceXformers && P(e, "xformers") !== !0 && i.push(t("sd-webui-xformers-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到 xformers,但启动参数强制启用了 xformers", "请安装 xformers,或将注意力优化改回自动/其它模式", [O(), j("xattnOptimization", h.Auto, "改回自动注意力")])), a === h.XformersFlashAttention && (P(e, "xformers") !== !0 || P(e, "flash_attn") !== !0) && i.push(t("sd-webui-flash-attn-runtime-missing", "runtime", !1, "error", "当前 Python 环境缺少 xformers 或 flash-attn,但启动参数要求启用 xformers flash attention", "请补齐 xformers / flash-attn,或改回其它注意力优化模式", [O(), j("xattnOptimization", h.Auto, "改回自动注意力")]));
|
|
970
|
+
}
|
|
971
|
+
return (a === h.ScaledDotProduct || a === h.ScaledDotProductNoMem) && P(n(r.sdp), "sdp_available") !== !0 && i.push(t("sd-webui-sdp-runtime-missing", "runtime", !1, "error", "当前 Python 环境未检测到 Scaled Dot Product Attention 支持", "请升级到支持 SDP 的 torch,或改用其它注意力优化模式", [O(), j("xattnOptimization", h.Auto, "改回自动注意力")])), i;
|
|
972
|
+
}
|
|
973
|
+
//#endregion
|
|
974
|
+
//#region packages/plugins/sd-webui/launch/preflight.ts
|
|
975
|
+
async function U(e, t, n) {
|
|
976
|
+
let r = {};
|
|
977
|
+
if (!t?.selectable) return r;
|
|
978
|
+
let i = [];
|
|
979
|
+
switch (t.backend !== "cpu" && i.push(["torch-runtime", 3e4]), t.backend === "cuda" && (i.push(["onnxruntime-cuda", 1e4]), e.params.cudaAllocatorBackend === _.CudaMallocAsync && t.features.memoryPools && i.push(["cuda-malloc-async", 5e3])), e.params.xattnOptimization) {
|
|
980
|
+
case h.ForceXformers:
|
|
981
|
+
case h.XformersFlashAttention:
|
|
982
|
+
i.push(["xformers-flash-attn", 4e3]);
|
|
983
|
+
break;
|
|
984
|
+
case h.ScaledDotProduct:
|
|
985
|
+
case h.ScaledDotProductNoMem: i.push(["sdp", 4e3]);
|
|
986
|
+
}
|
|
987
|
+
for (let [t, a] of i) r[t] = await n.launch.runRuntimeProbe(e, t, { timeoutMs: a });
|
|
988
|
+
return r;
|
|
989
|
+
}
|
|
990
|
+
async function W(e, t) {
|
|
991
|
+
let n = o(e), r = n?.selectable && (n.backend === "hip" || n.backend === "zluda") && e.host.os.name === "windows" ? e.host.backends.hip?.path : void 0, [i, a, s, c, l] = await Promise.all([
|
|
992
|
+
e.host.os.name === "windows" ? t.launch.checkVCRuntime("sd-webui-vc-runtime") : [],
|
|
993
|
+
t.launch.checkHttpPort(p(e.params.port, 7860), "sd-webui-port"),
|
|
994
|
+
t.launch.checkDuplicateExtensions(e),
|
|
995
|
+
r ? t.launch.checkPaths([{
|
|
996
|
+
id: "sd-webui-rocblas-runtime",
|
|
997
|
+
stage: "runtime",
|
|
998
|
+
paths: [`${r}/bin/rocblas.dll`, `${r}/rocblas/bin/rocblas.dll`],
|
|
999
|
+
successMessage: "已检测到 rocblas.dll",
|
|
1000
|
+
failureMessage: "未检测到 rocblas.dll,HIP / ZLUDA 运行时可能无法正常启动",
|
|
1001
|
+
suggestion: "请确认 ROCm/HIP SDK 安装完整,或补齐兼容包后再启动"
|
|
1002
|
+
}]) : [],
|
|
1003
|
+
U(e, n, t)
|
|
1004
|
+
]);
|
|
1005
|
+
return [
|
|
1006
|
+
...i,
|
|
1007
|
+
...a,
|
|
1008
|
+
...s,
|
|
1009
|
+
...c,
|
|
1010
|
+
...ue(e, n, l)
|
|
1011
|
+
];
|
|
1012
|
+
}
|
|
1013
|
+
function ue(e, n, i) {
|
|
1014
|
+
let a = [], o = e.runtime.status === "collected";
|
|
1015
|
+
if (!n) return a.push(t("sd-webui-selection-missing", "selection", !1, "error", "未能根据当前宿主事实解析出有效的启动后端", "请检查 GPU 检测结果或切换到 CPU 作为兜底后端", [k(), A()])), a;
|
|
1016
|
+
if (!n.selectable) return a.push(t("sd-webui-selection-unavailable", "selection", !1, "error", n.reasons[0] || "当前选择的后端在宿主机上不可用", "请检查宿主探测结果,或切换其它后端", [k(), A()])), a;
|
|
1017
|
+
a.push(t("sd-webui-selection-resolved", "selection", !0, "info", `已选择 ${n.backend.toUpperCase()} backend${n.gpuId ? ` (${n.name})` : ""}`));
|
|
1018
|
+
let s = n.backend;
|
|
1019
|
+
if (!o) {
|
|
1020
|
+
let n = F(e.runtime.status);
|
|
1021
|
+
a.push(t("sd-webui-runtime-unknown", "runtime", !1, "warning", n.message, n.suggestion, [O()]));
|
|
1022
|
+
}
|
|
1023
|
+
a.push(...V(e, n, i), ...H(e, i));
|
|
1024
|
+
let c = r(e.runtime, "numpy");
|
|
1025
|
+
return (M(c) || 0) >= 2 && a.push(t("sd-webui-numpy-major-version", "runtime", !1, "warning", `当前环境中的 numpy 版本为 ${c},部分 SD-WebUI 分支和扩展仍要求 numpy < 2`, "如遇到启动或扩展加载异常,建议先将 numpy 降级到 2 以下", [O()])), s === "cpu" && a.push(t("sd-webui-cpu-fallback", "selection", !1, "warning", "当前将以 CPU 模式启动,生成速度会显著降低", "若期望使用 GPU,请检查 CUDA runtime 或重新选择可用后端", [k()])), (!e.repo?.forkId || e.repo.forkId === "unknown") && a.push(t("sd-webui-fork-unknown", "runtime", !0, "info", "未识别具体分支类型,将使用通用兼容参数启动")), a;
|
|
1026
|
+
}
|
|
1027
|
+
//#endregion
|
|
1028
|
+
//#region packages/plugins/sd-webui/launch.ts
|
|
1029
|
+
var G = {
|
|
1030
|
+
ownedArgs: f,
|
|
1031
|
+
extraArgs: {
|
|
1032
|
+
param: "extraArgs",
|
|
1033
|
+
target: { env: "COMMANDLINE_ARGS" }
|
|
1034
|
+
},
|
|
1035
|
+
entry: {
|
|
1036
|
+
type: "python",
|
|
1037
|
+
script: "launch.py",
|
|
1038
|
+
prelude: (e) => re(e.getParam("useAccelerate", !1))
|
|
1039
|
+
},
|
|
1040
|
+
params: ee,
|
|
1041
|
+
groups: b,
|
|
1042
|
+
presets: te,
|
|
1043
|
+
strategy: {
|
|
1044
|
+
requirements: {
|
|
1045
|
+
repo: !0,
|
|
1046
|
+
pythonRuntime: !0,
|
|
1047
|
+
backendSelection: !0
|
|
1048
|
+
},
|
|
1049
|
+
preflight: W,
|
|
1050
|
+
compile: (e, t) => le(e, G, t)
|
|
1051
|
+
},
|
|
1052
|
+
detectFork: v,
|
|
1053
|
+
getWebViewUrl(t) {
|
|
1054
|
+
return e({
|
|
1055
|
+
host: t.serverName,
|
|
1056
|
+
port: t.port,
|
|
1057
|
+
defaultPort: 7860
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
}, de = { categories: [
|
|
1061
|
+
{
|
|
1062
|
+
id: "checkpoint",
|
|
1063
|
+
marketTypes: ["checkpoint"],
|
|
1064
|
+
label: "Checkpoints",
|
|
1065
|
+
icon: "i-lucide-box",
|
|
1066
|
+
paths: ["models/Stable-diffusion"],
|
|
1067
|
+
extensions: [
|
|
1068
|
+
".safetensors",
|
|
1069
|
+
".ckpt",
|
|
1070
|
+
".pt"
|
|
1071
|
+
]
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
id: "lora",
|
|
1075
|
+
marketTypes: ["lora", "lycoris"],
|
|
1076
|
+
label: "LoRA",
|
|
1077
|
+
icon: "i-lucide-layers",
|
|
1078
|
+
paths: ["models/Lora"],
|
|
1079
|
+
extensions: [".safetensors", ".pt"]
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
id: "vae",
|
|
1083
|
+
marketTypes: ["vae"],
|
|
1084
|
+
label: "VAE",
|
|
1085
|
+
icon: "i-lucide-paintbrush",
|
|
1086
|
+
paths: ["models/VAE"],
|
|
1087
|
+
extensions: [".safetensors", ".pt"]
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
id: "embedding",
|
|
1091
|
+
marketTypes: ["embedding"],
|
|
1092
|
+
label: "Embeddings",
|
|
1093
|
+
icon: "i-lucide-text",
|
|
1094
|
+
paths: ["embeddings"],
|
|
1095
|
+
extensions: [
|
|
1096
|
+
".safetensors",
|
|
1097
|
+
".pt",
|
|
1098
|
+
".bin"
|
|
1099
|
+
]
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
id: "controlnet",
|
|
1103
|
+
marketTypes: ["controlnet"],
|
|
1104
|
+
label: "ControlNet",
|
|
1105
|
+
icon: "i-lucide-move-3d",
|
|
1106
|
+
paths: ["extensions/sd-webui-controlnet/models", "models/ControlNet"],
|
|
1107
|
+
extensions: [".safetensors", ".pth"]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
id: "upscaler",
|
|
1111
|
+
marketTypes: ["upscaler"],
|
|
1112
|
+
label: "Upscalers",
|
|
1113
|
+
icon: "i-lucide-maximize-2",
|
|
1114
|
+
paths: [
|
|
1115
|
+
"models/ESRGAN",
|
|
1116
|
+
"models/RealESRGAN",
|
|
1117
|
+
"models/SwinIR"
|
|
1118
|
+
],
|
|
1119
|
+
extensions: [".pth", ".pt"]
|
|
1120
|
+
},
|
|
1121
|
+
{
|
|
1122
|
+
id: "hypernetwork",
|
|
1123
|
+
marketTypes: ["hypernetwork"],
|
|
1124
|
+
label: "Hypernetworks",
|
|
1125
|
+
icon: "i-lucide-network",
|
|
1126
|
+
paths: ["models/hypernetworks"],
|
|
1127
|
+
extensions: [".pt"]
|
|
1128
|
+
}
|
|
1129
|
+
] };
|
|
1130
|
+
//#endregion
|
|
1131
|
+
//#region packages/plugins/sd-webui/config.ts
|
|
1132
|
+
async function K(e, t) {
|
|
1133
|
+
let n = t.fs;
|
|
1134
|
+
if (!await n.exists(e)) return {};
|
|
1135
|
+
let r = await n.readFile(e);
|
|
1136
|
+
if (!r.trim()) return {};
|
|
1137
|
+
let i;
|
|
1138
|
+
try {
|
|
1139
|
+
i = JSON.parse(r);
|
|
1140
|
+
} catch (t) {
|
|
1141
|
+
throw Error(`无法解析 ${e.split(/[\\/]/).pop()}: ${t instanceof Error ? t.message : t}`, { cause: t });
|
|
1142
|
+
}
|
|
1143
|
+
if (!i || typeof i != "object" || Array.isArray(i)) throw Error(`${e.split(/[\\/]/).pop()} 格式无效: 根节点必须是对象`);
|
|
1144
|
+
return i;
|
|
1145
|
+
}
|
|
1146
|
+
//#endregion
|
|
1147
|
+
//#region packages/plugins/sd-webui/extensions.ts
|
|
1148
|
+
var q = {
|
|
1149
|
+
directory: "extensions",
|
|
1150
|
+
supportsToggle: !0
|
|
1151
|
+
}, fe = {
|
|
1152
|
+
...q,
|
|
1153
|
+
supportsToggle: !1
|
|
1154
|
+
}, pe = "config.json", J = "disabled_extensions";
|
|
1155
|
+
function Y(e) {
|
|
1156
|
+
return `${e.path}/${pe}`;
|
|
1157
|
+
}
|
|
1158
|
+
function me(e) {
|
|
1159
|
+
let t = e[J];
|
|
1160
|
+
return Array.isArray(t) ? new Set(t.filter((e) => typeof e == "string")) : /* @__PURE__ */ new Set();
|
|
1161
|
+
}
|
|
1162
|
+
async function he(e, t) {
|
|
1163
|
+
let [n, r] = await Promise.all([t.extensions.defaultScan(e, fe), K(Y(e), t)]), i = me(r);
|
|
1164
|
+
return n.map((e) => ({
|
|
1165
|
+
...e,
|
|
1166
|
+
enabled: !i.has(e.id)
|
|
1167
|
+
}));
|
|
1168
|
+
}
|
|
1169
|
+
async function ge(e, t, n, r) {
|
|
1170
|
+
let i = await K(Y(e), r), a = i[J], o = Array.isArray(a) ? a.filter((e) => typeof e == "string") : [], s = n ? o.filter((e) => e !== t) : o.includes(t) ? o : [...o, t];
|
|
1171
|
+
return s.length === o.length && s.every((e, t) => e === o[t]) ? { enabled: n } : (i[J] = s, await r.fs.writeFile(Y(e), `${JSON.stringify(i, null, 4)}\n`), { enabled: n });
|
|
1172
|
+
}
|
|
1173
|
+
var _e = {
|
|
1174
|
+
getConfig() {
|
|
1175
|
+
return q;
|
|
1176
|
+
},
|
|
1177
|
+
scanExtensions: he,
|
|
1178
|
+
toggleExtension: ge
|
|
1179
|
+
};
|
|
1180
|
+
function X(e) {
|
|
1181
|
+
let t = "";
|
|
1182
|
+
if (e.full_name) t = e.full_name.split("/")[0];
|
|
1183
|
+
else {
|
|
1184
|
+
let n = e.url.match(/github\.com[/:]([^/]+)\//);
|
|
1185
|
+
n && (t = n[1]);
|
|
1186
|
+
}
|
|
1187
|
+
let n = e.url.match(/\/([^/]+?)(\.git)?$/), r = n ? n[1] : e.name, i = e.full_name ? `https://github.com/${e.full_name}` : e.url.replace(".git", "");
|
|
1188
|
+
return {
|
|
1189
|
+
id: r,
|
|
1190
|
+
name: e.name,
|
|
1191
|
+
description: e.github_description || e.description,
|
|
1192
|
+
gitUrl: e.url,
|
|
1193
|
+
author: t,
|
|
1194
|
+
stars: e.stars,
|
|
1195
|
+
tags: e.tags,
|
|
1196
|
+
homepage: i,
|
|
1197
|
+
branch: e.default_branch
|
|
1198
|
+
};
|
|
1199
|
+
}
|
|
1200
|
+
var ve = { sources: [{
|
|
1201
|
+
id: "official",
|
|
1202
|
+
name: "Automatic1111 官方",
|
|
1203
|
+
url: "https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui-extensions/master/index.json",
|
|
1204
|
+
type: "json",
|
|
1205
|
+
transform: (e) => {
|
|
1206
|
+
let t = e;
|
|
1207
|
+
return t.extensions ? t.extensions.map(X) : [];
|
|
1208
|
+
}
|
|
1209
|
+
}] }, ye = {
|
|
1210
|
+
kind: "git",
|
|
1211
|
+
presets: [{
|
|
1212
|
+
id: "stable-1.9",
|
|
1213
|
+
name: "Stable 1.9.4",
|
|
1214
|
+
description: "推荐的稳定版本",
|
|
1215
|
+
branch: "master",
|
|
1216
|
+
commit: "v1.9.4",
|
|
1217
|
+
isRecommended: !0
|
|
1218
|
+
}, {
|
|
1219
|
+
id: "stable-1.8",
|
|
1220
|
+
name: "Stable 1.8.0",
|
|
1221
|
+
description: "旧版稳定版本",
|
|
1222
|
+
branch: "master",
|
|
1223
|
+
commit: "v1.8.0"
|
|
1224
|
+
}],
|
|
1225
|
+
recommendedRemotes: [
|
|
1226
|
+
{
|
|
1227
|
+
id: "automatic1111",
|
|
1228
|
+
name: "Automatic1111 (官方)",
|
|
1229
|
+
url: "https://github.com/AUTOMATIC1111/stable-diffusion-webui.git",
|
|
1230
|
+
description: "官方仓库",
|
|
1231
|
+
isDefault: !0
|
|
1232
|
+
},
|
|
1233
|
+
{
|
|
1234
|
+
id: "vladmandic",
|
|
1235
|
+
name: "Vladmandic (SD.Next)",
|
|
1236
|
+
url: "https://github.com/vladmandic/automatic.git",
|
|
1237
|
+
description: "更多后端支持和优化"
|
|
1238
|
+
},
|
|
1239
|
+
{
|
|
1240
|
+
id: "forge",
|
|
1241
|
+
name: "Forge",
|
|
1242
|
+
url: "https://github.com/lllyasviel/stable-diffusion-webui-forge.git",
|
|
1243
|
+
description: "ControlNet 作者维护的分支"
|
|
1244
|
+
}
|
|
1245
|
+
],
|
|
1246
|
+
defaultBranch: "master"
|
|
1247
|
+
};
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region packages/plugins/sd-webui/discover-import.ts
|
|
1250
|
+
function be(e, t) {
|
|
1251
|
+
for (let n of e.split(/\r?\n/).reverse()) if (t) {
|
|
1252
|
+
let e = /^\s*@?set\s+(?:"COMMANDLINE_ARGS=(.*)"|COMMANDLINE_ARGS=(.*))\s*$/i.exec(n);
|
|
1253
|
+
if (e) return (e[1] ?? e[2]).trim();
|
|
1254
|
+
} else {
|
|
1255
|
+
let e = /^\s*(?:export\s+)?COMMANDLINE_ARGS=(?:"((?:\\.|[^"\\])*)"|'([^']*)'|([^#]*?))\s*(?:#.*)?$/.exec(n);
|
|
1256
|
+
if (e) return (e[1]?.replace(/\\(["\\$\x60])/g, "$1") ?? e[2] ?? e[3]).trim();
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
async function xe(e, t) {
|
|
1260
|
+
let n = t.launch.isWindowsPlatform() ? ["webui-user.bat", "webui-user.sh"] : ["webui-user.sh", "webui-user.bat"];
|
|
1261
|
+
for (let r of n) {
|
|
1262
|
+
let n = t.launch.resolvePath(e, r);
|
|
1263
|
+
if (!await t.fs.exists(n)) continue;
|
|
1264
|
+
let i = be(await t.fs.readFile(n), r.endsWith(".bat"));
|
|
1265
|
+
if (i !== void 0) return i ? { initialParams: { extraArgs: i } } : null;
|
|
1266
|
+
}
|
|
1267
|
+
return null;
|
|
1268
|
+
}
|
|
1269
|
+
//#endregion
|
|
1270
|
+
//#region packages/plugins/output-gallery/connect.ts
|
|
1271
|
+
var Se = "kano:output-gallery";
|
|
1272
|
+
function Ce(e, t) {
|
|
1273
|
+
let n = [];
|
|
1274
|
+
e.services.watch(Se, ([r]) => {
|
|
1275
|
+
for (let e of n) e.dispose();
|
|
1276
|
+
if (n = [], !r) return;
|
|
1277
|
+
let i = r.page, a = c({
|
|
1278
|
+
props: {
|
|
1279
|
+
app: {
|
|
1280
|
+
type: Object,
|
|
1281
|
+
required: !0
|
|
1282
|
+
},
|
|
1283
|
+
api: {
|
|
1284
|
+
type: Object,
|
|
1285
|
+
required: !0
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
setup(e) {
|
|
1289
|
+
let n = s(() => t(() => e.app, e.api));
|
|
1290
|
+
return () => l(i, {
|
|
1291
|
+
key: e.app.id,
|
|
1292
|
+
source: n.value,
|
|
1293
|
+
instanceId: e.app.id
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
}), o = "输出图库", u = "i-lucide-image";
|
|
1297
|
+
n.push(e.ui.registerTab({
|
|
1298
|
+
id: "outputs",
|
|
1299
|
+
label: o,
|
|
1300
|
+
icon: u,
|
|
1301
|
+
order: 46,
|
|
1302
|
+
component: a,
|
|
1303
|
+
keepAlive: !1
|
|
1304
|
+
})), n.push(e.apps.registerAction({
|
|
1305
|
+
id: "output",
|
|
1306
|
+
label: o,
|
|
1307
|
+
icon: u,
|
|
1308
|
+
order: 3,
|
|
1309
|
+
kind: "tab",
|
|
1310
|
+
target: "outputs"
|
|
1311
|
+
}));
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
//#endregion
|
|
1315
|
+
//#region packages/plugins/sd-webui/gallery-source.ts
|
|
1316
|
+
function Z(e, t) {
|
|
1317
|
+
let n;
|
|
1318
|
+
for (let [r, i] of e.entries()) i === t && (n = e[r + 1]), i.startsWith(t + "=") && (n = i.slice(t.length + 1));
|
|
1319
|
+
return n;
|
|
1320
|
+
}
|
|
1321
|
+
function we(e, t) {
|
|
1322
|
+
let n = e(), { args: r, error: o } = i(String(n.params.extraArgs ?? "")), s = Z(r, "--data-dir"), c = s ? a(n.path, s) : n.path, l = a(c, "outputs"), u = Z(r, "--ui-settings-file"), d = u ? a(n.path, u) : a(c, "config.json");
|
|
1323
|
+
return {
|
|
1324
|
+
root: l,
|
|
1325
|
+
configPath: d,
|
|
1326
|
+
describe: (e) => Te(e.parameters ?? ""),
|
|
1327
|
+
async extraRoots() {
|
|
1328
|
+
if (o) throw Error(o);
|
|
1329
|
+
let e = await K(d, t), r = [], i = (e) => {
|
|
1330
|
+
let t = e.replaceAll("\\", "/").replace(/\/\.\//g, "/").replace(/\/+$/, "");
|
|
1331
|
+
return /^(?:[a-z]:|\/\/)/i.test(t) ? t.toLowerCase() : t;
|
|
1332
|
+
}, s = /* @__PURE__ */ new Set([i(l)]);
|
|
1333
|
+
function c(e, t) {
|
|
1334
|
+
if (typeof t != "string" || !t.trim()) return;
|
|
1335
|
+
let o = a(n.path, t);
|
|
1336
|
+
s.has(i(o)) || (s.add(i(o)), r.push({
|
|
1337
|
+
label: e,
|
|
1338
|
+
path: o
|
|
1339
|
+
}));
|
|
1340
|
+
}
|
|
1341
|
+
return e.outdir_samples ? c("生成图片", e.outdir_samples) : (c("文生图", e.outdir_txt2img_samples), c("图生图", e.outdir_img2img_samples), c("后期处理", e.outdir_extras_samples)), e.outdir_grids ? c("网格图", e.outdir_grids) : (c("文生图网格", e.outdir_txt2img_grids), c("图生图网格", e.outdir_img2img_grids)), c("手动保存", e.outdir_save), c("图生图原图", e.outdir_init_images), r;
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
var Q = {
|
|
1346
|
+
Steps: "步数",
|
|
1347
|
+
Sampler: "采样器",
|
|
1348
|
+
"Schedule type": "调度器",
|
|
1349
|
+
"CFG scale": "CFG",
|
|
1350
|
+
Seed: "种子",
|
|
1351
|
+
Size: "尺寸",
|
|
1352
|
+
"Denoising strength": "降噪强度",
|
|
1353
|
+
"Clip skip": "CLIP 跳层"
|
|
1354
|
+
};
|
|
1355
|
+
function Te(e) {
|
|
1356
|
+
let t = e.trim().split(/\r?\n/), n = /^Steps:\s*\d+\s*(?:,|$)/i.test(t.at(-1) ?? "") ? t.pop() : "", r = t.findIndex((e) => /^Negative prompt:/i.test(e)), i = (r < 0 ? t : t.slice(0, r)).join("\n").trim(), a = r < 0 ? "" : t.slice(r).join("\n").replace(/^Negative prompt:\s*/i, "").trim(), o = [], s = [];
|
|
1357
|
+
for (let e of n.matchAll(/(?:^|,)\s*([\w][\w /-]*):\s*("(?:\\.|[^"\\])*"|[^,]*)/g)) {
|
|
1358
|
+
let t = e[1].trim(), n = e[2].trim();
|
|
1359
|
+
n.startsWith("\"") && n.endsWith("\"") && (n = n.slice(1, -1).replace(/\\(["\\])/g, "$1")), t === "Model" && n && s.push(n), Object.hasOwn(Q, t) && o.push({
|
|
1360
|
+
label: Q[t],
|
|
1361
|
+
value: n
|
|
1362
|
+
});
|
|
1363
|
+
}
|
|
1364
|
+
return {
|
|
1365
|
+
positive: i,
|
|
1366
|
+
negative: a,
|
|
1367
|
+
samples: o.length ? [{
|
|
1368
|
+
title: "生成参数",
|
|
1369
|
+
values: o
|
|
1370
|
+
}] : [],
|
|
1371
|
+
models: s,
|
|
1372
|
+
raw: n || void 0
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
var $ = d({
|
|
1376
|
+
id: "sd-webui",
|
|
1377
|
+
app: {
|
|
1378
|
+
icon: "i-lucide-image",
|
|
1379
|
+
color: "#6366f1",
|
|
1380
|
+
identifiers: [
|
|
1381
|
+
{
|
|
1382
|
+
type: "file",
|
|
1383
|
+
pattern: "launch.py",
|
|
1384
|
+
weight: 10
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
type: "file",
|
|
1388
|
+
pattern: "webui.py",
|
|
1389
|
+
weight: 8
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
type: "folder",
|
|
1393
|
+
pattern: "modules",
|
|
1394
|
+
weight: 5
|
|
1395
|
+
},
|
|
1396
|
+
{
|
|
1397
|
+
type: "git-remote",
|
|
1398
|
+
pattern: "AUTOMATIC1111/stable-diffusion-webui",
|
|
1399
|
+
weight: 20
|
|
1400
|
+
},
|
|
1401
|
+
{
|
|
1402
|
+
type: "git-remote",
|
|
1403
|
+
pattern: "vladmandic/automatic",
|
|
1404
|
+
weight: 20
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
type: "git-remote",
|
|
1408
|
+
pattern: "lllyasviel/stable-diffusion-webui-forge",
|
|
1409
|
+
weight: 20
|
|
1410
|
+
}
|
|
1411
|
+
],
|
|
1412
|
+
async detect(e, t) {
|
|
1413
|
+
let n = await t.fs.listDir(e);
|
|
1414
|
+
return n.some((e) => e.name === "launch.py" && !e.is_dir) && n.some((e) => e.name === "models" && e.is_dir);
|
|
1415
|
+
},
|
|
1416
|
+
webview: {
|
|
1417
|
+
urlTemplate: "http://127.0.0.1:{port}",
|
|
1418
|
+
defaultPort: 7860,
|
|
1419
|
+
portParamId: "port",
|
|
1420
|
+
autoOpen: !1
|
|
1421
|
+
},
|
|
1422
|
+
actions: [
|
|
1423
|
+
{
|
|
1424
|
+
id: "models",
|
|
1425
|
+
label: "模型管理",
|
|
1426
|
+
icon: "i-lucide-box",
|
|
1427
|
+
kind: "tab",
|
|
1428
|
+
target: "model-library",
|
|
1429
|
+
order: 1
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
id: "extensions",
|
|
1433
|
+
label: "扩展管理",
|
|
1434
|
+
icon: "i-lucide-puzzle",
|
|
1435
|
+
kind: "tab",
|
|
1436
|
+
target: "extension-management",
|
|
1437
|
+
order: 2
|
|
1438
|
+
},
|
|
1439
|
+
{
|
|
1440
|
+
id: "models-folder",
|
|
1441
|
+
label: "模型目录",
|
|
1442
|
+
icon: "i-lucide-folder",
|
|
1443
|
+
kind: "folder",
|
|
1444
|
+
target: "models",
|
|
1445
|
+
order: 4
|
|
1446
|
+
},
|
|
1447
|
+
{
|
|
1448
|
+
id: "model-market",
|
|
1449
|
+
label: "模型市场",
|
|
1450
|
+
icon: "i-lucide-download",
|
|
1451
|
+
run: (e, t) => t.models.openMarket("", e.id),
|
|
1452
|
+
order: 5
|
|
1453
|
+
},
|
|
1454
|
+
{
|
|
1455
|
+
id: "settings",
|
|
1456
|
+
label: "启动配置",
|
|
1457
|
+
icon: "i-lucide-settings",
|
|
1458
|
+
kind: "tab",
|
|
1459
|
+
target: "settings",
|
|
1460
|
+
order: 6
|
|
1461
|
+
}
|
|
1462
|
+
],
|
|
1463
|
+
python: {
|
|
1464
|
+
minVersion: "3.10",
|
|
1465
|
+
maxVersion: "3.11"
|
|
1466
|
+
},
|
|
1467
|
+
discoverImport: xe,
|
|
1468
|
+
launchProvider: G,
|
|
1469
|
+
modelProvider: de,
|
|
1470
|
+
extensionProvider: _e,
|
|
1471
|
+
extensionMarketProvider: ve,
|
|
1472
|
+
versionProvider: ye
|
|
1473
|
+
},
|
|
1474
|
+
activate(e) {
|
|
1475
|
+
Ce(e, we), e.services.provide("kano:shared-model-directories", { list: () => e.apps.list().map(({ id: e, name: t, path: n }) => ({
|
|
1476
|
+
appId: e,
|
|
1477
|
+
name: t,
|
|
1478
|
+
path: n,
|
|
1479
|
+
layout: "sd-webui"
|
|
1480
|
+
})) });
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
//#endregion
|
|
1484
|
+
export { $ as default, $ as sdWebuiPlugin };
|