comfy-ts 2.21.0 → 2.23.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/{ServeApp-ByMobrWW.js → ServeApp-DolRCMHj.js} +183 -14
- package/dist/ServeApp-DolRCMHj.js.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{exampleAssets-B5sMqNia.js → exampleAssets-Duneoq6r.js} +331 -42
- package/dist/exampleAssets-Duneoq6r.js.map +1 -0
- package/dist/{findDefinedWorkflow-BNZgYIww.js → findDefinedWorkflow-DjoJA8y7.js} +2 -2
- package/dist/{findDefinedWorkflow-BNZgYIww.js.map → findDefinedWorkflow-DjoJA8y7.js.map} +1 -1
- package/dist/index.cjs +381 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +201 -24
- package/dist/index.d.ts +201 -24
- package/dist/index.js +380 -35
- package/dist/index.js.map +1 -1
- package/dist/{run-run-CuBSygku.js → run-run-Cr0L9lCK.js} +5 -5
- package/dist/{run-run-CuBSygku.js.map → run-run-Cr0L9lCK.js.map} +1 -1
- package/dist/{run-serve-COk_G0Qz.js → run-serve---qA7o_m.js} +4 -4
- package/dist/{run-serve-COk_G0Qz.js.map → run-serve---qA7o_m.js.map} +1 -1
- package/dist/{run-tui-CB6i_x2y.js → run-tui-DxXiWo5J.js} +4 -4
- package/dist/{run-tui-CB6i_x2y.js.map → run-tui-DxXiWo5J.js.map} +1 -1
- package/dist/{schemaDrift-CHDVYlaj.js → schemaDrift-BTxdABHi.js} +36 -2
- package/dist/schemaDrift-BTxdABHi.js.map +1 -0
- package/dist/serve-web.js +207 -47
- package/dist/web.d.ts +201 -24
- package/dist/web.js +380 -35
- package/dist/web.js.map +1 -1
- package/examples/README.md +2 -0
- package/examples/comfy-cloud/sdk.d.ts +102 -1
- package/examples/depth-explorer/models.ts +722 -0
- package/examples/depth-explorer/serve.ts +140 -0
- package/examples/depth-explorer/thumbs/bae.webp +0 -0
- package/examples/depth-explorer/thumbs/da3-mono-large.webp +0 -0
- package/examples/depth-explorer/thumbs/dav1-vitl.webp +0 -0
- package/examples/depth-explorer/thumbs/dav2-vitl.webp +0 -0
- package/examples/depth-explorer/thumbs/dsine.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-albedo.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-metalness.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-roughness.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-shading.webp +0 -0
- package/examples/depth-explorer/thumbs/iid-specular.webp +0 -0
- package/examples/depth-explorer/thumbs/leres.webp +0 -0
- package/examples/depth-explorer/thumbs/lotus-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-albedo.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/marigold2-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/metric3d-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/metric3d-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/midas-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/midas.webp +0 -0
- package/examples/depth-explorer/thumbs/moge2-depth.webp +0 -0
- package/examples/depth-explorer/thumbs/moge2-normal.webp +0 -0
- package/examples/depth-explorer/thumbs/zoe-da.webp +0 -0
- package/examples/depth-explorer/thumbs/zoe.webp +0 -0
- package/examples/depth-explorer/web/App.tsx +457 -0
- package/examples/depth-explorer/web/gl.ts +202 -0
- package/examples/depth-explorer/web/index.html +14 -0
- package/examples/depth-explorer/web/main.tsx +19 -0
- package/examples/depth-explorer/web/pixels.ts +86 -0
- package/examples/depth-explorer/web/state.ts +329 -0
- package/examples/depth-explorer/web/styles.css +366 -0
- package/examples/depth-explorer/web/tsconfig.json +16 -0
- package/examples/rvion/17-relight.cflow.ts +110 -0
- package/examples/rvion/18-world.cflow.ts +101 -0
- package/examples/world-explorer/serve.ts +171 -0
- package/examples/world-explorer/web/index.html +14 -0
- package/examples/world-explorer/web/main.tsx +200 -0
- package/examples/world-explorer/web/state.ts +212 -0
- package/examples/world-explorer/web/styles.css +131 -0
- package/examples/world-explorer/web/thumb.ts +21 -0
- package/examples/world-explorer/web/tsconfig.json +11 -0
- package/examples/world-explorer/world-state.ts +40 -0
- package/package.json +6 -7
- package/src/cli/serve/ServeApp.ts +106 -6
- package/src/cli/serve/describeVar.ts +12 -1
- package/src/cli/serve/resultHistory.ts +28 -5
- package/src/cli/serve/thumbs.ts +77 -0
- package/src/cli/serve/web/api.ts +9 -1
- package/src/cli/serve/web/components/Gallery.tsx +26 -1
- package/src/cli/serve/web/components/controls/BasicControls.tsx +14 -17
- package/src/cli/serve/web/components/controls/MediaControl.tsx +62 -9
- package/src/cli/serve/web/components/controls/RichSelect.tsx +262 -0
- package/src/cli/serve/web/state/RunSt.poll.test.ts +4 -1
- package/src/cli/serve/web/state/choiceButtons.ts +26 -2
- package/src/cli/serve/web/styles.ts +42 -0
- package/src/cli/serve/web/widgets/OutputWidgets.tsx +19 -0
- package/src/cli/serve/web/widgets/RelightSt.ts +113 -0
- package/src/cli/serve/web/widgets/RelightWidget.tsx +305 -0
- package/src/cli/serve/web/widgets/relightGl.ts +305 -0
- package/src/cli/serve/web/widgets/widgetStyles.ts +19 -0
- package/src/coreExports.ts +10 -0
- package/src/graph/ComfyNode.ts +12 -2
- package/src/host/ComfyHost.ts +153 -2
- package/src/host/ResilientWebsocket.ts +10 -0
- package/src/manager/script-update-manager.bun.ts +0 -7
- package/src/runner/ComfyExecution.ts +165 -20
- package/src/runner/ComfyWsApi.ts +2 -0
- package/src/runner/historyReplay.ts +53 -0
- package/src/runner/outputs3d.ts +18 -0
- package/src/sdk-generator/comfyui-sdk-codegen.ts +7 -2
- package/src/vars/ComfyVars.ts +32 -2
- package/src/vars/DefinedWorkflow.ts +4 -0
- package/src/vars/outputWidgets.ts +47 -0
- package/dist/ServeApp-ByMobrWW.js.map +0 -1
- package/dist/exampleAssets-B5sMqNia.js.map +0 -1
- package/dist/schemaDrift-CHDVYlaj.js.map +0 -1
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--bg: #111316;
|
|
3
|
+
--panel: #181b20;
|
|
4
|
+
--card: #1d2127;
|
|
5
|
+
--line: #2a2f37;
|
|
6
|
+
--text: #e6e8eb;
|
|
7
|
+
--dim: #8a929c;
|
|
8
|
+
--accent: #6aa8ff;
|
|
9
|
+
--err: #ff7a7a;
|
|
10
|
+
/* the panel's tokens, which the shared widget rules read */
|
|
11
|
+
--panel-2: var(--card);
|
|
12
|
+
--border: var(--line);
|
|
13
|
+
--hairline: var(--line);
|
|
14
|
+
--sel-bg: #2c3542;
|
|
15
|
+
--sel-border: var(--accent);
|
|
16
|
+
--sel-text: #c3d3fb;
|
|
17
|
+
--amber: #e0af68;
|
|
18
|
+
color-scheme: dark;
|
|
19
|
+
}
|
|
20
|
+
.relightWrap {
|
|
21
|
+
padding: 10px;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
gap: 8px;
|
|
25
|
+
}
|
|
26
|
+
* {
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
body {
|
|
30
|
+
margin: 0;
|
|
31
|
+
background: var(--bg);
|
|
32
|
+
color: var(--text);
|
|
33
|
+
font:
|
|
34
|
+
13px/1.4 ui-sans-serif,
|
|
35
|
+
system-ui,
|
|
36
|
+
-apple-system,
|
|
37
|
+
sans-serif;
|
|
38
|
+
}
|
|
39
|
+
button,
|
|
40
|
+
select,
|
|
41
|
+
a.ghost {
|
|
42
|
+
font: inherit;
|
|
43
|
+
color: var(--text);
|
|
44
|
+
background: var(--card);
|
|
45
|
+
border: 1px solid var(--line);
|
|
46
|
+
border-radius: 6px;
|
|
47
|
+
padding: 5px 10px;
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
text-decoration: none;
|
|
50
|
+
}
|
|
51
|
+
button:disabled {
|
|
52
|
+
opacity: 0.45;
|
|
53
|
+
cursor: default;
|
|
54
|
+
}
|
|
55
|
+
button.primary {
|
|
56
|
+
background: var(--accent);
|
|
57
|
+
border-color: var(--accent);
|
|
58
|
+
color: #0b1220;
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
width: 100%;
|
|
61
|
+
padding: 8px;
|
|
62
|
+
margin-top: 14px;
|
|
63
|
+
}
|
|
64
|
+
.ghost {
|
|
65
|
+
background: transparent;
|
|
66
|
+
}
|
|
67
|
+
.dim {
|
|
68
|
+
color: var(--dim);
|
|
69
|
+
}
|
|
70
|
+
.small {
|
|
71
|
+
font-size: 12px;
|
|
72
|
+
margin-top: 6px;
|
|
73
|
+
}
|
|
74
|
+
.err {
|
|
75
|
+
color: var(--err);
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: column;
|
|
78
|
+
gap: 6px;
|
|
79
|
+
padding: 10px;
|
|
80
|
+
font-size: 12px;
|
|
81
|
+
overflow: auto;
|
|
82
|
+
}
|
|
83
|
+
.app {
|
|
84
|
+
min-height: 100vh;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
}
|
|
88
|
+
header {
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: baseline;
|
|
91
|
+
gap: 14px;
|
|
92
|
+
padding: 12px 20px;
|
|
93
|
+
border-bottom: 1px solid var(--line);
|
|
94
|
+
}
|
|
95
|
+
h1 {
|
|
96
|
+
font-size: 16px;
|
|
97
|
+
margin: 0;
|
|
98
|
+
}
|
|
99
|
+
h2 {
|
|
100
|
+
font-size: 12px;
|
|
101
|
+
text-transform: uppercase;
|
|
102
|
+
letter-spacing: 0.08em;
|
|
103
|
+
color: var(--dim);
|
|
104
|
+
margin: 4px 0 10px;
|
|
105
|
+
}
|
|
106
|
+
.body {
|
|
107
|
+
display: flex;
|
|
108
|
+
flex: 1;
|
|
109
|
+
min-height: 0;
|
|
110
|
+
}
|
|
111
|
+
aside {
|
|
112
|
+
width: 280px;
|
|
113
|
+
flex-shrink: 0;
|
|
114
|
+
padding: 16px;
|
|
115
|
+
border-right: 1px solid var(--line);
|
|
116
|
+
background: var(--panel);
|
|
117
|
+
}
|
|
118
|
+
aside label {
|
|
119
|
+
display: block;
|
|
120
|
+
color: var(--dim);
|
|
121
|
+
margin: 14px 0 6px;
|
|
122
|
+
}
|
|
123
|
+
label.check {
|
|
124
|
+
display: flex;
|
|
125
|
+
gap: 8px;
|
|
126
|
+
align-items: center;
|
|
127
|
+
color: var(--text);
|
|
128
|
+
margin: 10px 0 0;
|
|
129
|
+
cursor: pointer;
|
|
130
|
+
}
|
|
131
|
+
.drop {
|
|
132
|
+
border: 1px dashed var(--line);
|
|
133
|
+
border-radius: 8px;
|
|
134
|
+
min-height: 140px;
|
|
135
|
+
display: grid;
|
|
136
|
+
place-items: center;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
}
|
|
140
|
+
.drop.over {
|
|
141
|
+
border-color: var(--accent);
|
|
142
|
+
}
|
|
143
|
+
.drop img {
|
|
144
|
+
display: block;
|
|
145
|
+
width: 100%;
|
|
146
|
+
}
|
|
147
|
+
.samples {
|
|
148
|
+
display: flex;
|
|
149
|
+
gap: 6px;
|
|
150
|
+
flex-wrap: wrap;
|
|
151
|
+
margin-top: 10px;
|
|
152
|
+
}
|
|
153
|
+
.samples img {
|
|
154
|
+
width: 40px;
|
|
155
|
+
height: 40px;
|
|
156
|
+
object-fit: cover;
|
|
157
|
+
border-radius: 4px;
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
opacity: 0.8;
|
|
160
|
+
}
|
|
161
|
+
.samples img:hover {
|
|
162
|
+
opacity: 1;
|
|
163
|
+
}
|
|
164
|
+
.seg {
|
|
165
|
+
display: flex;
|
|
166
|
+
}
|
|
167
|
+
.seg button {
|
|
168
|
+
flex: 1;
|
|
169
|
+
border-radius: 0;
|
|
170
|
+
}
|
|
171
|
+
.seg button:first-child {
|
|
172
|
+
border-radius: 6px 0 0 6px;
|
|
173
|
+
}
|
|
174
|
+
.seg button:last-child {
|
|
175
|
+
border-radius: 0 6px 6px 0;
|
|
176
|
+
}
|
|
177
|
+
.seg button.on {
|
|
178
|
+
background: #2c3542;
|
|
179
|
+
border-color: var(--accent);
|
|
180
|
+
}
|
|
181
|
+
main {
|
|
182
|
+
flex: 1;
|
|
183
|
+
padding: 16px 20px 40px;
|
|
184
|
+
overflow: auto;
|
|
185
|
+
}
|
|
186
|
+
section + section {
|
|
187
|
+
margin-top: 24px;
|
|
188
|
+
}
|
|
189
|
+
.grid {
|
|
190
|
+
display: grid;
|
|
191
|
+
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
|
192
|
+
gap: 14px;
|
|
193
|
+
}
|
|
194
|
+
.card {
|
|
195
|
+
background: var(--card);
|
|
196
|
+
border: 1px solid var(--line);
|
|
197
|
+
border-radius: 8px;
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
}
|
|
200
|
+
.card.off {
|
|
201
|
+
opacity: 0.6;
|
|
202
|
+
}
|
|
203
|
+
.cardHead {
|
|
204
|
+
display: flex;
|
|
205
|
+
justify-content: space-between;
|
|
206
|
+
gap: 8px;
|
|
207
|
+
padding: 8px 10px;
|
|
208
|
+
}
|
|
209
|
+
.name {
|
|
210
|
+
font-weight: 600;
|
|
211
|
+
}
|
|
212
|
+
.fam {
|
|
213
|
+
font-weight: 400;
|
|
214
|
+
color: var(--dim);
|
|
215
|
+
}
|
|
216
|
+
.meta {
|
|
217
|
+
color: var(--dim);
|
|
218
|
+
white-space: nowrap;
|
|
219
|
+
}
|
|
220
|
+
.frame {
|
|
221
|
+
background: #0c0d0f;
|
|
222
|
+
display: grid;
|
|
223
|
+
place-items: center;
|
|
224
|
+
position: relative;
|
|
225
|
+
overflow: hidden;
|
|
226
|
+
}
|
|
227
|
+
.card.done .frame {
|
|
228
|
+
cursor: zoom-in;
|
|
229
|
+
}
|
|
230
|
+
.frame > img,
|
|
231
|
+
.frame > canvas {
|
|
232
|
+
width: 100%;
|
|
233
|
+
height: 100%;
|
|
234
|
+
object-fit: contain;
|
|
235
|
+
display: block;
|
|
236
|
+
}
|
|
237
|
+
.frame .dim {
|
|
238
|
+
display: flex;
|
|
239
|
+
flex-direction: column;
|
|
240
|
+
align-items: center;
|
|
241
|
+
gap: 4px;
|
|
242
|
+
}
|
|
243
|
+
.blurb {
|
|
244
|
+
padding: 8px 10px;
|
|
245
|
+
color: var(--dim);
|
|
246
|
+
font-size: 12px;
|
|
247
|
+
}
|
|
248
|
+
.missing {
|
|
249
|
+
display: flex;
|
|
250
|
+
flex-direction: column;
|
|
251
|
+
gap: 4px;
|
|
252
|
+
padding: 10px;
|
|
253
|
+
font-size: 11px;
|
|
254
|
+
word-break: break-all;
|
|
255
|
+
}
|
|
256
|
+
.missing a {
|
|
257
|
+
color: var(--accent);
|
|
258
|
+
}
|
|
259
|
+
.spin {
|
|
260
|
+
display: inline-block;
|
|
261
|
+
width: 12px;
|
|
262
|
+
height: 12px;
|
|
263
|
+
border: 2px solid var(--line);
|
|
264
|
+
border-top-color: var(--accent);
|
|
265
|
+
border-radius: 50%;
|
|
266
|
+
animation: spin 0.8s linear infinite;
|
|
267
|
+
vertical-align: -2px;
|
|
268
|
+
}
|
|
269
|
+
@keyframes spin {
|
|
270
|
+
to {
|
|
271
|
+
transform: rotate(360deg);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
.focus {
|
|
275
|
+
position: fixed;
|
|
276
|
+
inset: 0;
|
|
277
|
+
background: rgba(0, 0, 0, 0.75);
|
|
278
|
+
display: grid;
|
|
279
|
+
place-items: center;
|
|
280
|
+
padding: 24px;
|
|
281
|
+
z-index: 10;
|
|
282
|
+
}
|
|
283
|
+
.focusBox {
|
|
284
|
+
background: var(--panel);
|
|
285
|
+
border: 1px solid var(--line);
|
|
286
|
+
border-radius: 10px;
|
|
287
|
+
width: min(1200px, 100%);
|
|
288
|
+
max-height: 100%;
|
|
289
|
+
display: flex;
|
|
290
|
+
flex-direction: column;
|
|
291
|
+
overflow: hidden;
|
|
292
|
+
}
|
|
293
|
+
.focusBar {
|
|
294
|
+
display: flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
gap: 10px;
|
|
297
|
+
padding: 10px 14px;
|
|
298
|
+
border-bottom: 1px solid var(--line);
|
|
299
|
+
}
|
|
300
|
+
.focusBar b {
|
|
301
|
+
margin-right: auto;
|
|
302
|
+
}
|
|
303
|
+
.wipe {
|
|
304
|
+
position: relative;
|
|
305
|
+
flex-shrink: 0;
|
|
306
|
+
margin: 0 auto;
|
|
307
|
+
cursor: ew-resize;
|
|
308
|
+
user-select: none;
|
|
309
|
+
overflow: hidden;
|
|
310
|
+
}
|
|
311
|
+
.wipe .layer {
|
|
312
|
+
position: absolute;
|
|
313
|
+
inset: 0;
|
|
314
|
+
width: 100%;
|
|
315
|
+
height: 100%;
|
|
316
|
+
object-fit: contain;
|
|
317
|
+
display: block;
|
|
318
|
+
}
|
|
319
|
+
.handle {
|
|
320
|
+
position: absolute;
|
|
321
|
+
top: 0;
|
|
322
|
+
bottom: 0;
|
|
323
|
+
width: 2px;
|
|
324
|
+
background: #fff;
|
|
325
|
+
box-shadow: 0 0 6px rgba(0, 0, 0, 0.6);
|
|
326
|
+
pointer-events: none;
|
|
327
|
+
}
|
|
328
|
+
.tag {
|
|
329
|
+
position: absolute;
|
|
330
|
+
top: 8px;
|
|
331
|
+
background: rgba(0, 0, 0, 0.6);
|
|
332
|
+
padding: 2px 8px;
|
|
333
|
+
border-radius: 4px;
|
|
334
|
+
font-size: 12px;
|
|
335
|
+
}
|
|
336
|
+
.tag.l {
|
|
337
|
+
left: 8px;
|
|
338
|
+
}
|
|
339
|
+
.tag.r {
|
|
340
|
+
right: 8px;
|
|
341
|
+
}
|
|
342
|
+
.glWrap {
|
|
343
|
+
display: flex;
|
|
344
|
+
flex-direction: column;
|
|
345
|
+
}
|
|
346
|
+
canvas.gl {
|
|
347
|
+
width: 100%;
|
|
348
|
+
height: calc(100vh - 200px);
|
|
349
|
+
min-height: 320px;
|
|
350
|
+
display: block;
|
|
351
|
+
cursor: grab;
|
|
352
|
+
touch-action: none;
|
|
353
|
+
}
|
|
354
|
+
.glControls {
|
|
355
|
+
display: flex;
|
|
356
|
+
gap: 18px;
|
|
357
|
+
align-items: center;
|
|
358
|
+
padding: 10px 14px;
|
|
359
|
+
border-top: 1px solid var(--line);
|
|
360
|
+
}
|
|
361
|
+
.glControls label {
|
|
362
|
+
display: flex;
|
|
363
|
+
gap: 8px;
|
|
364
|
+
align-items: center;
|
|
365
|
+
margin: 0;
|
|
366
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
// the depth explorer page: dom-typed like examples/web, so it keeps its own config. It renders
|
|
3
|
+
// the panel's relight widget, so it checks src/ too, like src/cli/serve/web does
|
|
4
|
+
"extends": "../../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
7
|
+
"paths": {
|
|
8
|
+
"src/*": ["../../../src/*"],
|
|
9
|
+
"comfy-ts": ["../../../src/index.ts"]
|
|
10
|
+
},
|
|
11
|
+
"tsBuildInfoFile": "../../../node_modules/.cache/tsbuildinfo-depth-explorer-web.json"
|
|
12
|
+
},
|
|
13
|
+
// MUST override the root's exclude, which lists this directory
|
|
14
|
+
"exclude": ["../../web"],
|
|
15
|
+
"include": [".", "../../../src"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// relight a photo: one depth model, one normal model and the Marigold IID material maps, drawn
|
|
2
|
+
// by the serve panel's relight widget (a point light you move over the image in 3D: drag for
|
|
3
|
+
// left/right and up/down, wheel for nearer/farther, plus shadows and drifting light motes).
|
|
4
|
+
// The models are the depth explorer's catalog (examples/depth-explorer/models.ts): one choice per
|
|
5
|
+
// map lists the ones this host can run, each option with its picture, date, weights and quality
|
|
6
|
+
// (a choice of one still says what it is). Every material map can be « none ». The image presets
|
|
7
|
+
// are the example animals (a url works too, see the commented ones). Outside the panel (CLI,
|
|
8
|
+
// TUI) each map is a plain output image.
|
|
9
|
+
//
|
|
10
|
+
// run directly: bun examples/rvion/17-relight.cflow.ts [path/to/image.png]
|
|
11
|
+
import { asAbsolutePath, type BaseNodeInputs, ComfyTS, exampleImagePath, MediaImage, v, widget } from 'comfy-ts'
|
|
12
|
+
import { availability, MODELS, optionLook, type ModelEntry } from '../depth-explorer/models.ts'
|
|
13
|
+
|
|
14
|
+
const comfy = ComfyTS.create()
|
|
15
|
+
const host = comfy.host({ id: 'windows-1' })
|
|
16
|
+
await host.loadSchemaFromCache()
|
|
17
|
+
|
|
18
|
+
/** the catalog entries for one map this host can run (by its cached schema) */
|
|
19
|
+
function runnable(which: (m: ModelEntry) => boolean): string[] {
|
|
20
|
+
return MODELS.filter((m) => which(m) && availability(host.schema.data.spec, m).ok).map((m) => m.id)
|
|
21
|
+
}
|
|
22
|
+
const looks = (ids: string[]) => ({ options: Object.fromEntries(ids.map((id) => [id, optionLook(entry(id))])) })
|
|
23
|
+
function entry(id: string): ModelEntry {
|
|
24
|
+
const m = MODELS.find((x) => x.id === id)
|
|
25
|
+
if (m == null) throw new Error(`no model '${id}' in the depth explorer catalog`)
|
|
26
|
+
return m
|
|
27
|
+
}
|
|
28
|
+
const pick = (ids: string[], preferred: string): string => (ids.includes(preferred) ? preferred : (ids[0] ?? preferred))
|
|
29
|
+
|
|
30
|
+
type MapName = NonNullable<ModelEntry['map']>
|
|
31
|
+
const ofMap = (map: MapName): string[] => runnable((m) => m.map === map)
|
|
32
|
+
const ids = {
|
|
33
|
+
depth: runnable((m) => m.kind === 'depth'),
|
|
34
|
+
normal: runnable((m) => m.kind === 'normal'),
|
|
35
|
+
albedo: ofMap('albedo'),
|
|
36
|
+
roughness: ofMap('roughness'),
|
|
37
|
+
metalness: ofMap('metalness'),
|
|
38
|
+
specular: ofMap('specular'),
|
|
39
|
+
shading: ofMap('shading'),
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** a material map: its models, the preferred one picked, or none */
|
|
43
|
+
const material = (map: MapName, preferred: string, label: string) =>
|
|
44
|
+
v.choice(ids[map], pick(ids[map], preferred), { label, select: 'zero-or-one' }).ui(looks(ids[map]))
|
|
45
|
+
|
|
46
|
+
const image = v.image(exampleImagePath('lioness_768x768.jpg'), {
|
|
47
|
+
presets: {
|
|
48
|
+
lioness: exampleImagePath('lioness_768x768.jpg'),
|
|
49
|
+
bear: exampleImagePath('bear_1024x1024.jpg'),
|
|
50
|
+
walrus: exampleImagePath('walrus_1344x768.jpg'),
|
|
51
|
+
deer: exampleImagePath('deer_768x1344.jpg'),
|
|
52
|
+
// a preset can be a url, fetched once when a run uses it:
|
|
53
|
+
// 'genomea cover': 'https://www.bifocalfiction.com/images/genomea-cover-cn1.png',
|
|
54
|
+
// 'dead city 1': 'https://www.bifocalfiction.com/generated/la-ville-morte-chapitre-3/horizontal/strip-01.webp',
|
|
55
|
+
// 'dead city 2': 'https://www.bifocalfiction.com/generated/la-ville-morte-chapitre-3/horizontal/strip-02.webp',
|
|
56
|
+
// 'dead city 3': 'https://www.bifocalfiction.com/generated/la-ville-morte-chapitre-3/horizontal/strip-03.webp',
|
|
57
|
+
},
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export const relight = host.defineWorkflow({
|
|
61
|
+
id: 'relight',
|
|
62
|
+
vars: {
|
|
63
|
+
image,
|
|
64
|
+
depth: v.choice(ids.depth, pick(ids.depth, 'da3-mono-large')).ui(looks(ids.depth)),
|
|
65
|
+
normal: v.choice(ids.normal, pick(ids.normal, 'moge2-normal'), 'normals').ui(looks(ids.normal)),
|
|
66
|
+
albedo: material('albedo', 'iid-albedo', 'albedo'),
|
|
67
|
+
roughness: material('roughness', 'iid-roughness', 'roughness'),
|
|
68
|
+
metalness: material('metalness', 'iid-metalness', 'metalness'),
|
|
69
|
+
/** the non diffuse light: what shines */
|
|
70
|
+
specular: material('specular', 'iid-specular', 'specular'),
|
|
71
|
+
/** the diffuse light and the cast shadows: an output to look at, the widget lights without it */
|
|
72
|
+
shading: material('shading', 'iid-shading', 'shadows'),
|
|
73
|
+
detail: v.int(768, { min: 384, max: 1536 }),
|
|
74
|
+
},
|
|
75
|
+
widgets: [
|
|
76
|
+
widget.relight({
|
|
77
|
+
image: 'source',
|
|
78
|
+
depth: 'depth',
|
|
79
|
+
normal: 'normal',
|
|
80
|
+
albedo: 'albedo',
|
|
81
|
+
roughness: 'roughness',
|
|
82
|
+
metalness: 'metalness',
|
|
83
|
+
specular: 'specular',
|
|
84
|
+
}),
|
|
85
|
+
],
|
|
86
|
+
build: async (b, vars, wf) => {
|
|
87
|
+
const loaded = await new MediaImage({ path: asAbsolutePath(image.absPath()) }).loadInWorkflow_viaLoadImageNode(wf)
|
|
88
|
+
const saveNode = wf.builderBase.SaveImageWebsocket
|
|
89
|
+
if (saveNode == null) throw new Error('this host has no SaveImageWebsocket node')
|
|
90
|
+
const save = (images: BaseNodeInputs[string], tag: string): void => void saveNode({ images }, { tag })
|
|
91
|
+
const p = { detail: vars.detail, wf }
|
|
92
|
+
save(loaded, 'source')
|
|
93
|
+
save(entry(vars.depth).build(b, loaded, p), 'depth')
|
|
94
|
+
save(entry(vars.normal).build(b, loaded, p), 'normal')
|
|
95
|
+
for (const map of ['albedo', 'roughness', 'metalness', 'specular', 'shading'] as const) {
|
|
96
|
+
const id = vars[map]
|
|
97
|
+
if (id != null) save(entry(id).build(b, loaded, p), map)
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
export default relight
|
|
103
|
+
|
|
104
|
+
// standalone run (skipped when another driver, e.g. the TUI, imports this module)
|
|
105
|
+
if (import.meta.main) {
|
|
106
|
+
if (process.argv[2]) relight.vars.image.set(process.argv[2])
|
|
107
|
+
const execution = await relight.run({ log: true, save: { prefix: 'comfy-ts-example/relight' } })
|
|
108
|
+
for (const out of execution.images) console.log(`🟢 ${out.tags.join(',')} ${out.absPath}`)
|
|
109
|
+
host.disconnect()
|
|
110
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// turn one picture into a 360° world: Qwen-Image-Edit-2509 with Tencent's HY-Pano 2.0 LoRA (from
|
|
2
|
+
// HY-World 2.0) expands the picture into an equirectangular panorama, the same prompt template,
|
|
3
|
+
// size, steps and guidance as their pipeline_with_qwen_image.py. Its left and right edges meet:
|
|
4
|
+
// the viewer wraps it around you. MoGe then measures the panorama's depth all around and the
|
|
5
|
+
// world is saved as a textured mesh (glb) seen from its middle.
|
|
6
|
+
//
|
|
7
|
+
// run directly: bun examples/rvion/18-world.cflow.ts [path/to/image.png] [seed]
|
|
8
|
+
import { ComfyTS, exampleImagePath, v } from 'comfy-ts'
|
|
9
|
+
|
|
10
|
+
const comfy = ComfyTS.create()
|
|
11
|
+
const host = comfy.host({ id: 'windows-1' })
|
|
12
|
+
await host.loadSchemaFromCache()
|
|
13
|
+
|
|
14
|
+
/** HY-Pano 2.0's own prompt template (hyworld2/panogen/pipeline_with_qwen_image.py) */
|
|
15
|
+
const PANO_PREFIX =
|
|
16
|
+
'Create a **ERP** panoramic expansion of the provided image. Preserve the original style, lighting, and fine details seamlessly throughout the extended areas, extend according to: '
|
|
17
|
+
const PANO_SUFFIX = ' 8k UHD, masterpiece, razor-sharp details.'
|
|
18
|
+
const PANO_NEGATIVE =
|
|
19
|
+
'低分辨率,低画质,模糊。杂乱的背景,结构扭曲,模糊纹理,物体融合。构图混乱。过度光滑,画面具有AI感。人脸畸形。巨大物体,巨大建筑,近景特写,近景压迫,比例失调。车,车辆。画面上方的树叶。'
|
|
20
|
+
const PANO_LORA = 'world\\hy-pano-2-qwen-lora.safetensors'
|
|
21
|
+
/** HY-Pano's canvas and its edge blend width: 1952 - 32 = 1920, 2:1 */
|
|
22
|
+
const PANO_W = 1952
|
|
23
|
+
const PANO_H = 960
|
|
24
|
+
const BLEND = 32
|
|
25
|
+
|
|
26
|
+
const image = v.image(exampleImagePath('lioness_768x768.jpg'), {
|
|
27
|
+
presets: {
|
|
28
|
+
lioness: exampleImagePath('lioness_768x768.jpg'),
|
|
29
|
+
bear: exampleImagePath('bear_1024x1024.jpg'),
|
|
30
|
+
walrus: exampleImagePath('walrus_1344x768.jpg'),
|
|
31
|
+
deer: exampleImagePath('deer_768x1344.jpg'),
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
export const world = host.defineWorkflow({
|
|
36
|
+
id: 'world',
|
|
37
|
+
vars: {
|
|
38
|
+
image,
|
|
39
|
+
/** what the unseen sides hold; empty lets the model continue the picture */
|
|
40
|
+
extend: v.text(''),
|
|
41
|
+
seed: v.seed(42),
|
|
42
|
+
steps: v.int(40, { min: 8, max: 60 }),
|
|
43
|
+
cfg: v.float(7.5, { min: 1, max: 12 }),
|
|
44
|
+
},
|
|
45
|
+
build: async (b, vars, wf) => {
|
|
46
|
+
const picture = await image.loadInWorkflow(wf)
|
|
47
|
+
const clip = b.CLIPLoader({ clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors', type: 'qwen_image' })
|
|
48
|
+
const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
|
|
49
|
+
const unet = b.UNETLoader({ unet_name: 'qwen_image_edit_2509_int8_convrot.safetensors', weight_dtype: 'default' })
|
|
50
|
+
const withLora = b.LoraLoaderModelOnly({ model: unet, lora_name: PANO_LORA, strength_model: 1 })
|
|
51
|
+
const encode = (prompt: string) =>
|
|
52
|
+
b.TextEncodeQwenImageEditPlus({ clip, prompt, vae, image1: picture })
|
|
53
|
+
const samples = b.KSampler({
|
|
54
|
+
model: b.ModelSamplingAuraFlow({ model: withLora, shift: 3.1 }),
|
|
55
|
+
positive: encode(`${PANO_PREFIX}${vars.extend}${PANO_SUFFIX}`),
|
|
56
|
+
negative: encode(PANO_NEGATIVE),
|
|
57
|
+
latent_image: b.EmptySD3LatentImage({ width: PANO_W, height: PANO_H, batch_size: 1 }),
|
|
58
|
+
seed: vars.seed,
|
|
59
|
+
steps: vars.steps,
|
|
60
|
+
cfg: vars.cfg,
|
|
61
|
+
sampler_name: 'euler',
|
|
62
|
+
scheduler: 'simple',
|
|
63
|
+
denoise: 1,
|
|
64
|
+
})
|
|
65
|
+
const raw = b.VAEDecode({ samples, vae })
|
|
66
|
+
// the seam: HY-Pano's own edge blend (circular_blend_edges), the last BLEND columns fade into
|
|
67
|
+
// the first ones, then leave; 1952 wide becomes an exact 2:1 that wraps without a cut
|
|
68
|
+
const strip = (x: number) => b.ImageCrop({ image: raw, width: BLEND, height: PANO_H, x, y: 0 })
|
|
69
|
+
const joined = b.ImageCompositeMasked({
|
|
70
|
+
destination: strip(PANO_W - BLEND),
|
|
71
|
+
source: strip(0),
|
|
72
|
+
x: 0,
|
|
73
|
+
y: 0,
|
|
74
|
+
mask: b['kjnodes.CreateGradientMask']({ invert: true, frames: 1, width: BLEND, height: PANO_H }),
|
|
75
|
+
})
|
|
76
|
+
const panorama = b.ImageCompositeMasked({
|
|
77
|
+
destination: b.ImageCrop({ image: raw, width: PANO_W - BLEND, height: PANO_H, x: 0, y: 0 }),
|
|
78
|
+
source: joined,
|
|
79
|
+
x: 0,
|
|
80
|
+
y: 0,
|
|
81
|
+
})
|
|
82
|
+
b.SaveImageWebsocket({ images: panorama }, { tag: 'panorama' })
|
|
83
|
+
// the world: MoGe reads 12 perspective views of the panorama, merges one distance map all
|
|
84
|
+
// around, and the textured mesh is that map seen from the middle
|
|
85
|
+
const geometry = b.MoGePanoramaInference({
|
|
86
|
+
moge_model: b.LoadMoGeModel({ model_name: 'moge_2_vitl_normal_fp16.safetensors' }),
|
|
87
|
+
image: panorama,
|
|
88
|
+
})
|
|
89
|
+
b.SaveGLB({ mesh: b.MoGePointMapToMesh({ moge_geometry: geometry }), filename_prefix: 'comfy-ts/world' })
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
export default world
|
|
94
|
+
|
|
95
|
+
if (import.meta.main) {
|
|
96
|
+
if (process.argv[2]) world.vars.image.set(process.argv[2])
|
|
97
|
+
if (process.argv[3]) world.vars.seed.set(Number(process.argv[3]))
|
|
98
|
+
const execution = await world.run({ log: true, save: { prefix: 'comfy-ts-example/world' } })
|
|
99
|
+
for (const img of execution.images) console.log(`🟢 ${img.tags.join(',')} ${img.absPath}`)
|
|
100
|
+
host.disconnect()
|
|
101
|
+
}
|