comfy-ts 2.22.0 → 2.24.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-DuxYdaZZ.js → ServeApp-fsHtW5zG.js} +51 -17
- package/dist/ServeApp-fsHtW5zG.js.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{exampleAssets-1NHndnNB.js → exampleAssets-DZynSkZm.js} +405 -39
- package/dist/exampleAssets-DZynSkZm.js.map +1 -0
- package/dist/{findDefinedWorkflow-CRsBTTJK.js → findDefinedWorkflow-qyqFea7q.js} +2 -2
- package/dist/{findDefinedWorkflow-CRsBTTJK.js.map → findDefinedWorkflow-qyqFea7q.js.map} +1 -1
- package/dist/index.cjs +428 -46
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +147 -1
- package/dist/index.d.ts +147 -1
- package/dist/index.js +428 -47
- package/dist/index.js.map +1 -1
- package/dist/{run-run-Y5ZI48vV.js → run-run-Cn2JzKlE.js} +5 -5
- package/dist/{run-run-Y5ZI48vV.js.map → run-run-Cn2JzKlE.js.map} +1 -1
- package/dist/{run-serve-CICU_wTL.js → run-serve-BhGegaCI.js} +4 -4
- package/dist/{run-serve-CICU_wTL.js.map → run-serve-BhGegaCI.js.map} +1 -1
- package/dist/{run-tui-CViJXsHL.js → run-tui-CrM4ijkH.js} +4 -4
- package/dist/{run-tui-CViJXsHL.js.map → run-tui-CrM4ijkH.js.map} +1 -1
- package/dist/{schemaDrift-CzjaIwZX.js → schemaDrift-BGYJZGMD.js} +18 -3
- package/dist/{schemaDrift-CzjaIwZX.js.map → schemaDrift-BGYJZGMD.js.map} +1 -1
- package/dist/serve-web.js +46 -43
- package/dist/web.d.ts +147 -1
- package/dist/web.js +428 -47
- package/dist/web.js.map +1 -1
- package/examples/README.md +1 -0
- package/examples/comfy-cloud/sdk.d.ts +102 -1
- package/examples/depth-explorer/models.ts +6 -56
- package/examples/depth-explorer/serve.ts +12 -133
- package/examples/depth-explorer/web/App.tsx +20 -91
- package/examples/depth-explorer/web/index.html +1 -0
- package/examples/depth-explorer/web/state.ts +26 -109
- package/examples/depth-explorer/web/styles.css +1 -286
- package/examples/explorer-kit/catalog.ts +80 -0
- package/examples/explorer-kit/server.ts +167 -0
- package/examples/explorer-kit/web/base.css +289 -0
- package/examples/explorer-kit/web/runs.ts +160 -0
- package/examples/explorer-kit/web/ui.tsx +125 -0
- package/examples/rvion/17-relight.cflow.ts +2 -1
- package/examples/rvion/18-world.cflow.ts +101 -0
- package/examples/rvion/19-flythrough.cflow.ts +312 -0
- package/examples/rvion/20-grow-splat.cflow.ts +88 -0
- package/examples/rvion/21-photo-to-model.cflow.ts +191 -0
- package/examples/rvion/flythroughChain.ts +171 -0
- package/examples/rvion/flythroughColmap.ts +157 -0
- package/examples/rvion/flythroughFuse.ts +199 -0
- package/examples/rvion/flythroughGuide.ts +300 -0
- package/examples/rvion/flythroughPalette.ts +310 -0
- package/examples/rvion/flythroughPath.ts +177 -0
- package/examples/rvion/flythroughSplat.ts +73 -0
- package/examples/rvion/grow-splat/align.ts +114 -0
- package/examples/rvion/grow-splat/grow.ts +198 -0
- package/examples/rvion/grow-splat/ply.ts +166 -0
- package/examples/rvion/grow-splat/raster.ts +207 -0
- package/examples/rvion/grow-splat/sharp.ts +45 -0
- package/examples/rvion/splatDataset.ts +80 -0
- package/examples/rvion/splatEval.ts +380 -0
- package/examples/upscale-explorer/models.ts +341 -0
- package/examples/upscale-explorer/serve.ts +19 -0
- package/examples/upscale-explorer/web/App.tsx +250 -0
- package/examples/upscale-explorer/web/compare.tsx +285 -0
- package/examples/upscale-explorer/web/index.html +15 -0
- package/examples/upscale-explorer/web/main.tsx +12 -0
- package/examples/upscale-explorer/web/state.ts +279 -0
- package/examples/upscale-explorer/web/styles.css +241 -0
- package/examples/upscale-explorer/web/tsconfig.json +16 -0
- package/examples/upscale-explorer/web/viewport.tsx +130 -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 +7 -8
- package/src/cli/serve/ServeApp.ts +27 -2
- package/src/cli/serve/resultHistory.ts +22 -4
- package/src/cli/serve/thumbs.ts +19 -8
- package/src/cli/serve/web/api.ts +4 -0
- package/src/cli/serve/web/components/Gallery.tsx +24 -1
- package/src/cli/serve/web/styles.ts +3 -0
- package/src/coreExports.ts +6 -0
- package/src/graph/ComfyNode.ts +12 -2
- package/src/host/ComfyHost.ts +159 -2
- package/src/host/ResilientWebsocket.ts +10 -0
- package/src/manager/script-update-manager.bun.ts +0 -7
- package/src/runner/ComfyExecution.ts +185 -23
- package/src/runner/ComfyWorkflow.ts +22 -0
- package/src/runner/ComfyWsApi.ts +3 -1
- package/src/runner/comfyOrgApiKey.ts +44 -0
- package/src/runner/historyReplay.ts +53 -0
- package/src/runner/outputs3d.ts +18 -0
- package/src/sdk-generator/ComfyUIObjectInfoTypes.ts +2 -0
- package/src/sdk-generator/comfyui-sdk-codegen.ts +7 -2
- package/src/state.ts +2 -0
- package/src/vars/DefinedWorkflow.ts +1 -0
- package/dist/ServeApp-DuxYdaZZ.js.map +0 -1
- package/dist/exampleAssets-1NHndnNB.js.map +0 -1
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
// the catalog: every upscaler the explorer knows, one ComfyUI graph each. An entry runs only when
|
|
2
|
+
// the host has its nodes AND its weight files (checked live, examples/explorer-kit/catalog.ts).
|
|
3
|
+
// Every output lands at the SAME size, the source times the page's scale: a model whose native
|
|
4
|
+
// factor differs is resized after it with Lanczos, so the loupe compares like with like, pixel for
|
|
5
|
+
// pixel, against the source enlarged with Lanczos alone. `speed`: a 744×1040 card to ×4 on the 4090,
|
|
6
|
+
// weights loaded, as the page times it (about 3 s of it is the 16 to 26 MB png crossing the tunnel);
|
|
7
|
+
// `quality`: judged on the text and mana symbols of a card scan.
|
|
8
|
+
import type { BaseNode } from 'comfy-ts'
|
|
9
|
+
import { base, type CatalogEntry, type WeightFile } from '../explorer-kit/catalog.ts'
|
|
10
|
+
import type { ExplorerImg as Img, ExplorerWf as W } from '../explorer-kit/server.ts'
|
|
11
|
+
|
|
12
|
+
export type Scale = 2 | 4
|
|
13
|
+
export type UpscalerKind = 'baseline' | 'model' | 'diffusion'
|
|
14
|
+
|
|
15
|
+
export type UpscalerEntry = CatalogEntry & {
|
|
16
|
+
kind: UpscalerKind
|
|
17
|
+
/** classic = pre 2024 models, off by default */
|
|
18
|
+
tier: 'modern' | 'classic'
|
|
19
|
+
/** the network: DAT2, HAT-L, ESRGAN, SeedVR2 … */
|
|
20
|
+
arch: string
|
|
21
|
+
/** its native factor; 0 = any (the baseline, the diffusion models) */
|
|
22
|
+
native: number
|
|
23
|
+
license: string
|
|
24
|
+
/** the graph up to its output image, at the source size times `scale` */
|
|
25
|
+
build: (wf: W, image: Img, p: { scale: Scale }) => Img | BaseNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** `image` times `k` with Lanczos: the fair baseline, and the step that brings a model's native
|
|
29
|
+
* factor to the page's scale */
|
|
30
|
+
const lanczos = (wf: W, image: Img | BaseNode, k: number): BaseNode =>
|
|
31
|
+
base(wf, 'ImageScaleBy')({ image, upscale_method: 'lanczos', scale_by: k })
|
|
32
|
+
|
|
33
|
+
const upscaleFile = (file: string, url: string): WeightFile => ({
|
|
34
|
+
node: 'UpscaleModelLoader',
|
|
35
|
+
input: 'model_name',
|
|
36
|
+
file,
|
|
37
|
+
folder: 'upscale_models',
|
|
38
|
+
url,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
/** one ImageUpscaleWithModel pass (spandrel: ESRGAN, DAT, HAT, RCAN, PLKSR …, tiled by ComfyUI,
|
|
42
|
+
* which halves the tile on an out of memory), then Lanczos to the page's scale */
|
|
43
|
+
function spandrel(
|
|
44
|
+
e: Omit<UpscalerEntry, 'kind' | 'nodes' | 'files' | 'build'> & { file: string; url: string },
|
|
45
|
+
): UpscalerEntry {
|
|
46
|
+
const { file, url, ...card } = e
|
|
47
|
+
return {
|
|
48
|
+
...card,
|
|
49
|
+
kind: 'model',
|
|
50
|
+
nodes: ['UpscaleModelLoader', 'ImageUpscaleWithModel', 'ImageScaleBy'],
|
|
51
|
+
files: [upscaleFile(file, url)],
|
|
52
|
+
build: (wf, image, p) => {
|
|
53
|
+
const up = base(
|
|
54
|
+
wf,
|
|
55
|
+
'ImageUpscaleWithModel',
|
|
56
|
+
)({ upscale_model: base(wf, 'UpscaleModelLoader')({ model_name: file }), image })
|
|
57
|
+
return p.scale === e.native ? up : lanczos(wf, up, p.scale / e.native)
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const SEEDVR2_BASE = 'https://huggingface.co/Comfy-Org/SeedVR2/resolve/main'
|
|
63
|
+
const SEEDVR2_VAE: WeightFile = {
|
|
64
|
+
node: 'VAELoader',
|
|
65
|
+
input: 'vae_name',
|
|
66
|
+
file: 'seedvr2_ema_vae_fp16.safetensors',
|
|
67
|
+
folder: 'vae',
|
|
68
|
+
url: `${SEEDVR2_BASE}/vae/seedvr2_ema_vae_fp16.safetensors`,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** the Comfy-Org SeedVR2 image template (core nodes): Lanczos to the target size, one diffusion
|
|
72
|
+
* step that restores it, colour kept as the model made it. Tiled VAE, so a 12 MP card fits */
|
|
73
|
+
function seedvr2(e: Omit<UpscalerEntry, 'kind' | 'nodes' | 'files' | 'build' | 'native'> & { unet: string }): UpscalerEntry {
|
|
74
|
+
const { unet, ...card } = e
|
|
75
|
+
const unetFile: WeightFile = {
|
|
76
|
+
node: 'UNETLoader',
|
|
77
|
+
input: 'unet_name',
|
|
78
|
+
file: unet,
|
|
79
|
+
folder: 'diffusion_models',
|
|
80
|
+
url: `${SEEDVR2_BASE}/diffusion_models/${unet}`,
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
...card,
|
|
84
|
+
kind: 'diffusion',
|
|
85
|
+
native: 0,
|
|
86
|
+
nodes: ['SeedVR2Preprocess', 'SeedVR2Conditioning', 'SeedVR2PostProcessing', 'ImageScaleBy'],
|
|
87
|
+
files: [unetFile, SEEDVR2_VAE],
|
|
88
|
+
build: (wf, image, p) => {
|
|
89
|
+
const resized = lanczos(wf, image, p.scale)
|
|
90
|
+
const vae = base(wf, 'VAELoader')({ vae_name: SEEDVR2_VAE.file })
|
|
91
|
+
const model = base(wf, 'UNETLoader')({ unet_name: unet, weight_dtype: 'default' })
|
|
92
|
+
const tiles = { tile_size: 512, overlap: 128, temporal_size: 4096, temporal_overlap: 8 }
|
|
93
|
+
const latent = base(
|
|
94
|
+
wf,
|
|
95
|
+
'VAEEncodeTiled',
|
|
96
|
+
)({ pixels: base(wf, 'SeedVR2Preprocess')({ resized_images: resized }), vae, ...tiles })
|
|
97
|
+
const cond = base(wf, 'SeedVR2Conditioning')({ model, vae_conditioning: latent })
|
|
98
|
+
const [positive, negative] = [cond.outputs.positive, cond.outputs.negative]
|
|
99
|
+
if (positive == null || negative == null) throw new Error('SeedVR2Conditioning has no positive/negative slots')
|
|
100
|
+
const samples = base(
|
|
101
|
+
wf,
|
|
102
|
+
'KSampler',
|
|
103
|
+
)({
|
|
104
|
+
model,
|
|
105
|
+
seed: 1,
|
|
106
|
+
steps: 1,
|
|
107
|
+
cfg: 1,
|
|
108
|
+
sampler_name: 'euler',
|
|
109
|
+
scheduler: 'simple',
|
|
110
|
+
positive,
|
|
111
|
+
negative,
|
|
112
|
+
latent_image: latent,
|
|
113
|
+
denoise: 1,
|
|
114
|
+
})
|
|
115
|
+
return base(
|
|
116
|
+
wf,
|
|
117
|
+
'SeedVR2PostProcessing',
|
|
118
|
+
)({
|
|
119
|
+
images: base(wf, 'VAEDecodeTiled')({ samples, vae, ...tiles }),
|
|
120
|
+
original_resized_images: resized,
|
|
121
|
+
color_correction_method: 'none',
|
|
122
|
+
})
|
|
123
|
+
},
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** an ESRGAN era model (64 MB each), found again by its file name on OpenModelDB */
|
|
128
|
+
function classic(
|
|
129
|
+
id: string,
|
|
130
|
+
file: string,
|
|
131
|
+
label: string,
|
|
132
|
+
family: string,
|
|
133
|
+
date: string,
|
|
134
|
+
native: number,
|
|
135
|
+
blurb: string,
|
|
136
|
+
speed = '~5 s',
|
|
137
|
+
): UpscalerEntry {
|
|
138
|
+
return spandrel({
|
|
139
|
+
id,
|
|
140
|
+
label,
|
|
141
|
+
family,
|
|
142
|
+
year: Number(date.slice(0, 4)),
|
|
143
|
+
date,
|
|
144
|
+
size: '64 MB',
|
|
145
|
+
quality: 2,
|
|
146
|
+
speed,
|
|
147
|
+
tier: 'classic',
|
|
148
|
+
arch: 'ESRGAN',
|
|
149
|
+
native,
|
|
150
|
+
license: 'see its model card',
|
|
151
|
+
blurb,
|
|
152
|
+
file,
|
|
153
|
+
url: 'https://openmodeldb.info',
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const HF = 'https://huggingface.co'
|
|
158
|
+
const JANAI = 'https://github.com/the-database/MangaJaNai/releases/download/3.0.0'
|
|
159
|
+
|
|
160
|
+
export const MODELS: UpscalerEntry[] = [
|
|
161
|
+
// ── the baseline ───────────────────────────────────────────────
|
|
162
|
+
{
|
|
163
|
+
id: 'lanczos',
|
|
164
|
+
label: 'Lanczos',
|
|
165
|
+
family: 'resample',
|
|
166
|
+
year: 1979,
|
|
167
|
+
date: '1979',
|
|
168
|
+
size: 'none',
|
|
169
|
+
quality: 1,
|
|
170
|
+
speed: '~3 s',
|
|
171
|
+
kind: 'baseline',
|
|
172
|
+
tier: 'modern',
|
|
173
|
+
arch: 'Lanczos 3',
|
|
174
|
+
native: 0,
|
|
175
|
+
license: 'none',
|
|
176
|
+
blurb: 'the source enlarged with no model: what every upscaler must beat',
|
|
177
|
+
nodes: ['ImageScaleBy'],
|
|
178
|
+
files: [],
|
|
179
|
+
build: (wf, image, p) => lanczos(wf, image, p.scale),
|
|
180
|
+
},
|
|
181
|
+
// ── models, modern ─────────────────────────────────────────────
|
|
182
|
+
spandrel({
|
|
183
|
+
id: 'ultrasharp-v2',
|
|
184
|
+
label: 'UltraSharp V2',
|
|
185
|
+
family: 'DAT2',
|
|
186
|
+
year: 2025,
|
|
187
|
+
date: '2025-05',
|
|
188
|
+
size: '140 MB',
|
|
189
|
+
quality: 5,
|
|
190
|
+
speed: '~19 s',
|
|
191
|
+
tier: 'modern',
|
|
192
|
+
arch: 'DAT2',
|
|
193
|
+
native: 4,
|
|
194
|
+
license: 'CC BY-NC-SA 4.0',
|
|
195
|
+
blurb: 'Kim2091, the general upscaler of 2025: photos, illustration and text, crisp edges',
|
|
196
|
+
file: '4x-UltraSharpV2.safetensors',
|
|
197
|
+
url: `${HF}/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2.safetensors`,
|
|
198
|
+
}),
|
|
199
|
+
spandrel({
|
|
200
|
+
id: 'ultrasharp-v2-lite',
|
|
201
|
+
label: 'UltraSharp V2 Lite',
|
|
202
|
+
family: 'RealPLKSR',
|
|
203
|
+
year: 2025,
|
|
204
|
+
date: '2025-05',
|
|
205
|
+
size: '30 MB',
|
|
206
|
+
quality: 4,
|
|
207
|
+
speed: '~4 s',
|
|
208
|
+
tier: 'modern',
|
|
209
|
+
arch: 'RealPLKSR',
|
|
210
|
+
native: 4,
|
|
211
|
+
license: 'CC BY-NC-SA 4.0',
|
|
212
|
+
blurb: 'the fast UltraSharp V2, a lighter network on the same data',
|
|
213
|
+
file: '4x-UltraSharpV2_Lite.safetensors',
|
|
214
|
+
url: `${HF}/Kim2091/UltraSharpV2/resolve/main/4x-UltraSharpV2_Lite.safetensors`,
|
|
215
|
+
}),
|
|
216
|
+
spandrel({
|
|
217
|
+
id: 'janai-detail-dat2',
|
|
218
|
+
label: 'IllustrationJaNai V3',
|
|
219
|
+
family: 'detail DAT2',
|
|
220
|
+
year: 2025,
|
|
221
|
+
date: '2025-11',
|
|
222
|
+
size: '140 MB',
|
|
223
|
+
quality: 4,
|
|
224
|
+
speed: '~18 s',
|
|
225
|
+
tier: 'modern',
|
|
226
|
+
arch: 'DAT2',
|
|
227
|
+
native: 4,
|
|
228
|
+
license: 'CC BY-NC-SA 4.0',
|
|
229
|
+
blurb: 'the-database, made for digital art and illustration; keeps the fine detail',
|
|
230
|
+
file: '4x_IllustrationJaNai_V3detail_DAT2_28k_bf16.safetensors',
|
|
231
|
+
url: `${JANAI}/IllustrationJaNai_V3detail.zip`,
|
|
232
|
+
}),
|
|
233
|
+
spandrel({
|
|
234
|
+
id: 'janai-detail-hat',
|
|
235
|
+
label: 'IllustrationJaNai V3',
|
|
236
|
+
family: 'detail HAT-L',
|
|
237
|
+
year: 2025,
|
|
238
|
+
date: '2025-11',
|
|
239
|
+
size: '160 MB',
|
|
240
|
+
quality: 4,
|
|
241
|
+
speed: '~15 s',
|
|
242
|
+
tier: 'modern',
|
|
243
|
+
arch: 'HAT-L',
|
|
244
|
+
native: 4,
|
|
245
|
+
license: 'CC BY-NC-SA 4.0',
|
|
246
|
+
blurb: 'the same training on the heavier HAT-L transformer',
|
|
247
|
+
file: '4x_IllustrationJaNai_V3detail_HAT_L_28k_bf16.safetensors',
|
|
248
|
+
url: `${JANAI}/IllustrationJaNai_V3detail.zip`,
|
|
249
|
+
}),
|
|
250
|
+
spandrel({
|
|
251
|
+
id: 'janai-denoise-dat2',
|
|
252
|
+
label: 'IllustrationJaNai V3',
|
|
253
|
+
family: 'denoise DAT2',
|
|
254
|
+
year: 2025,
|
|
255
|
+
date: '2025-11',
|
|
256
|
+
size: '140 MB',
|
|
257
|
+
quality: 3,
|
|
258
|
+
speed: '~19 s',
|
|
259
|
+
tier: 'modern',
|
|
260
|
+
arch: 'DAT2',
|
|
261
|
+
native: 4,
|
|
262
|
+
license: 'CC BY-NC-SA 4.0',
|
|
263
|
+
blurb: 'the illustration model that also cleans scan noise and compression',
|
|
264
|
+
file: '4x_IllustrationJaNai_V3denoise_DAT2_27k_bf16.safetensors',
|
|
265
|
+
url: `${JANAI}/IllustrationJaNai_V3denoise.zip`,
|
|
266
|
+
}),
|
|
267
|
+
spandrel({
|
|
268
|
+
id: 'nomos2-hq-dat2',
|
|
269
|
+
label: 'Nomos2 hq',
|
|
270
|
+
family: 'DAT2',
|
|
271
|
+
year: 2024,
|
|
272
|
+
date: '2024-10',
|
|
273
|
+
size: '140 MB',
|
|
274
|
+
quality: 4,
|
|
275
|
+
speed: '~20 s',
|
|
276
|
+
tier: 'modern',
|
|
277
|
+
arch: 'DAT2',
|
|
278
|
+
native: 4,
|
|
279
|
+
license: 'CC BY 4.0',
|
|
280
|
+
blurb: 'Phhofm, for clean (non degraded) photos: faithful, little invention',
|
|
281
|
+
file: '4xNomos2_hq_dat2.safetensors',
|
|
282
|
+
url: `${HF}/Phips/4xNomos2_hq_dat2/resolve/main/4xNomos2_hq_dat2.safetensors`,
|
|
283
|
+
}),
|
|
284
|
+
spandrel({
|
|
285
|
+
id: 'animesharp-v4',
|
|
286
|
+
label: 'AnimeSharp V4',
|
|
287
|
+
family: 'RCAN ×2',
|
|
288
|
+
year: 2025,
|
|
289
|
+
date: '2025-01',
|
|
290
|
+
size: '31 MB',
|
|
291
|
+
quality: 3,
|
|
292
|
+
speed: '~4 s',
|
|
293
|
+
tier: 'modern',
|
|
294
|
+
arch: 'RCAN',
|
|
295
|
+
native: 2,
|
|
296
|
+
license: 'CC BY-NC-SA 4.0',
|
|
297
|
+
blurb: 'Kim2091, line art and flat colour at ×2 (Lanczos ×2 after it at ×4)',
|
|
298
|
+
file: '2x-AnimeSharpV4_RCAN.safetensors',
|
|
299
|
+
url: `${HF}/Kim2091/2x-AnimeSharpV4/resolve/main/2x-AnimeSharpV4_RCAN.safetensors`,
|
|
300
|
+
}),
|
|
301
|
+
// ── diffusion ──────────────────────────────────────────────────
|
|
302
|
+
seedvr2({
|
|
303
|
+
id: 'seedvr2-7b-sharp',
|
|
304
|
+
label: 'SeedVR2',
|
|
305
|
+
family: '7B sharp int8',
|
|
306
|
+
year: 2025,
|
|
307
|
+
date: '2025-06',
|
|
308
|
+
size: '8.3 GB',
|
|
309
|
+
quality: 5,
|
|
310
|
+
speed: '~18 s',
|
|
311
|
+
tier: 'modern',
|
|
312
|
+
arch: 'SeedVR2 DiT',
|
|
313
|
+
license: 'Apache 2.0',
|
|
314
|
+
blurb: 'ByteDance, one step diffusion restoration; the sharp 7B (may redraw tiny glyphs)',
|
|
315
|
+
unet: 'seedvr2_7b_sharp_int8_convrot.safetensors',
|
|
316
|
+
}),
|
|
317
|
+
seedvr2({
|
|
318
|
+
id: 'seedvr2-3b',
|
|
319
|
+
label: 'SeedVR2',
|
|
320
|
+
family: '3B int8',
|
|
321
|
+
year: 2025,
|
|
322
|
+
date: '2025-06',
|
|
323
|
+
size: '3.5 GB',
|
|
324
|
+
quality: 4,
|
|
325
|
+
speed: '~17 s',
|
|
326
|
+
tier: 'modern',
|
|
327
|
+
arch: 'SeedVR2 DiT',
|
|
328
|
+
license: 'Apache 2.0',
|
|
329
|
+
blurb: 'the 3B SeedVR2, as the Comfy-Org template ships it',
|
|
330
|
+
unet: 'seedvr2_3b_int8_convrot.safetensors',
|
|
331
|
+
}),
|
|
332
|
+
// ── models, classic (2018 to 2022, on the box already) ─────────
|
|
333
|
+
classic('ultrasharp', '4x-UltraSharp.pth', 'UltraSharp', 'ESRGAN', '2022-01', 4, 'Kim2091, the sharp default of the SD era'),
|
|
334
|
+
classic('animesharp', '4x-AnimeSharp.pth', 'AnimeSharp', 'ESRGAN', '2022-02', 4, 'Kim2091, anime and line art'),
|
|
335
|
+
classic('siax', '4x_NMKD-Siax_200k.pth', 'NMKD Siax', 'ESRGAN', '2021', 4, 'Nmkd, a soft general upscaler'),
|
|
336
|
+
classic('remacri', '4x_foolhardy_Remacri.pth', 'Remacri', 'ESRGAN', '2021', 4, 'foolhardy, an interpolation tuned for detail'),
|
|
337
|
+
classic('superscale', '8x_NMKD-Superscale_150000_G.pth', 'NMKD Superscale', 'ESRGAN ×8', '2021', 8, 'Nmkd, ×8 then Lanczos down to the scale', '~11 s'),
|
|
338
|
+
classic('realesrgan-x4', 'RealESRGAN_x4.pth', 'Real-ESRGAN', 'x4plus', '2021-07', 4, 'xinntao, the classic for degraded photos'),
|
|
339
|
+
classic('realesrgan-x2', 'RealESRGAN_x2.pth', 'Real-ESRGAN', 'x2plus', '2021-07', 2, 'xinntao, ×2 (Lanczos ×2 after it at ×4)'),
|
|
340
|
+
classic('esrgan', 'ESRGAN_4x.pth', 'ESRGAN', 'original', '2018-09', 4, 'the 2018 original, for reference'),
|
|
341
|
+
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// upscale explorer: drop any image, run every upscaler the host has at one scale, compare them
|
|
2
|
+
// where print shows it: a synced loupe at 100 % pixels, and a pair in five compare modes.
|
|
3
|
+
// bun examples/upscale-explorer/serve.ts [--samples <dir>] → http://127.0.0.1:8294
|
|
4
|
+
import { serveExplorer } from '../explorer-kit/server.ts'
|
|
5
|
+
import { MODELS, type Scale } from './models.ts'
|
|
6
|
+
import page from './web/index.html'
|
|
7
|
+
|
|
8
|
+
await serveExplorer({
|
|
9
|
+
name: 'upscale explorer',
|
|
10
|
+
port: 8294,
|
|
11
|
+
page,
|
|
12
|
+
catalog: MODELS,
|
|
13
|
+
card: (m) => ({ kind: m.kind, tier: m.tier, arch: m.arch, native: m.native, license: m.license }),
|
|
14
|
+
readParams: (raw): { scale: Scale } => {
|
|
15
|
+
if (raw.scale === 2 || raw.scale === 4) return { scale: raw.scale }
|
|
16
|
+
throw new Error('body needs { scale: 2 | 4 }')
|
|
17
|
+
},
|
|
18
|
+
build: (wf, image, m, p) => m.build(wf, image, p),
|
|
19
|
+
})
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { observer } from 'mobx-react-lite'
|
|
2
|
+
import { useEffect, useRef } from 'react'
|
|
3
|
+
import { RunBody, Seg, SourcePicker, timeOf } from '../../explorer-kit/web/ui.tsx'
|
|
4
|
+
import { Pair } from './compare.tsx'
|
|
5
|
+
import type { AppSt, ModelInfo } from './state.ts'
|
|
6
|
+
import { Layer, Viewport, ZoomBar } from './viewport.tsx'
|
|
7
|
+
|
|
8
|
+
const mb = (bytes: number): string => `${(bytes / 1e6).toFixed(1)} MB`
|
|
9
|
+
|
|
10
|
+
const Card = observer(function Card(p: { st: AppSt; model: ModelInfo }) {
|
|
11
|
+
const { st, model } = p
|
|
12
|
+
const r = st.result(model.id)
|
|
13
|
+
const done = r?.status === 'done'
|
|
14
|
+
const thumb = st.thumb(model.id)
|
|
15
|
+
const aspect = st.source != null ? `${st.source.width} / ${st.source.height}` : '1'
|
|
16
|
+
return (
|
|
17
|
+
<div className={`card ${done ? 'done' : ''} ${model.ok ? '' : 'off'}`}>
|
|
18
|
+
<div className="cardHead">
|
|
19
|
+
<span className="name">
|
|
20
|
+
{model.label} <span className="fam">{model.family}</span>
|
|
21
|
+
</span>
|
|
22
|
+
<span className="meta">{done ? timeOf(r) : model.date}</span>
|
|
23
|
+
</div>
|
|
24
|
+
<div
|
|
25
|
+
className="frame"
|
|
26
|
+
style={{ aspectRatio: aspect }}
|
|
27
|
+
title={done ? 'click: compare at 100 % where you clicked' : undefined}
|
|
28
|
+
onClick={(e) => {
|
|
29
|
+
if (!done) return
|
|
30
|
+
const b = e.currentTarget.getBoundingClientRect()
|
|
31
|
+
st.openPair(model.id, undefined, false, { u: (e.clientX - b.left) / b.width, v: (e.clientY - b.top) / b.height })
|
|
32
|
+
}}
|
|
33
|
+
>
|
|
34
|
+
{done && thumb != null ? (
|
|
35
|
+
<img src={thumb} alt={model.label} draggable={false} />
|
|
36
|
+
) : done ? (
|
|
37
|
+
<span className="dim">…</span>
|
|
38
|
+
) : (
|
|
39
|
+
<RunBody model={model} run={r} now={st.runs.now} canRun={st.source != null} onRun={() => st.enqueue(model.id)} />
|
|
40
|
+
)}
|
|
41
|
+
</div>
|
|
42
|
+
<div className="facts">
|
|
43
|
+
<span className="chip">{model.arch}</span>
|
|
44
|
+
{model.native > 0 && <span className="chip">×{model.native} native</span>}
|
|
45
|
+
{done && <span className="chip out">{`${r.width}×${r.height} · ${mb(r.bytes)}`}</span>}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="blurb">
|
|
48
|
+
{model.blurb}
|
|
49
|
+
{model.kind !== 'baseline' && <span className="dim"> · {model.size} · {model.license}</span>}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const Grid = observer(function Grid(p: { st: AppSt }) {
|
|
56
|
+
const { st } = p
|
|
57
|
+
const groups: [string, ModelInfo[]][] = [
|
|
58
|
+
['models', st.visibleModels.filter((m) => m.kind === 'baseline' || (m.kind === 'model' && m.tier === 'modern'))],
|
|
59
|
+
['diffusion', st.visibleModels.filter((m) => m.kind === 'diffusion')],
|
|
60
|
+
['classic models (2018 to 2022)', st.visibleModels.filter((m) => m.kind === 'model' && m.tier === 'classic')],
|
|
61
|
+
]
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
{groups.map(([title, models]) =>
|
|
65
|
+
models.length === 0 ? null : (
|
|
66
|
+
<section key={title}>
|
|
67
|
+
<h2>{title}</h2>
|
|
68
|
+
<div className="grid">
|
|
69
|
+
{models.map((m) => (
|
|
70
|
+
<Card key={m.id} st={st} model={m} />
|
|
71
|
+
))}
|
|
72
|
+
</div>
|
|
73
|
+
</section>
|
|
74
|
+
),
|
|
75
|
+
)}
|
|
76
|
+
</>
|
|
77
|
+
)
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
/** every finished result on the same crop, at the same zoom: the place to judge text and symbols */
|
|
81
|
+
const Loupe = observer(function Loupe(p: { st: AppSt }) {
|
|
82
|
+
const { st } = p
|
|
83
|
+
if (st.done.length === 0) return <div className="dim">run some models first: the loupe shows the finished ones</div>
|
|
84
|
+
return (
|
|
85
|
+
<div className="loupe" style={{ gridTemplateColumns: `repeat(auto-fill, minmax(${st.tile}px, 1fr))` }}>
|
|
86
|
+
{st.done.map((m) => {
|
|
87
|
+
const r = st.result(m.id)
|
|
88
|
+
if (r?.url == null) return null
|
|
89
|
+
return (
|
|
90
|
+
<div key={m.id} className="tile">
|
|
91
|
+
<div className="tileHead" title="compare it with another" onClick={() => st.openPair(m.id)}>
|
|
92
|
+
<span className="name">
|
|
93
|
+
{m.label} <span className="fam">{m.family}</span>
|
|
94
|
+
</span>
|
|
95
|
+
<span className="meta">{timeOf(r)}</span>
|
|
96
|
+
</div>
|
|
97
|
+
<Viewport st={st} className="tileView">
|
|
98
|
+
{(box) => <Layer url={r.url ?? ''} box={box} alt={m.label} />}
|
|
99
|
+
</Viewport>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
})}
|
|
103
|
+
</div>
|
|
104
|
+
)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
/** the source with the loupe's crop on it: click or drag to move the crop */
|
|
108
|
+
const Navigator = observer(function Navigator(p: { st: AppSt }) {
|
|
109
|
+
const { st } = p
|
|
110
|
+
const src = st.source
|
|
111
|
+
const drag = useRef(false)
|
|
112
|
+
if (src == null) return null
|
|
113
|
+
const s = st.zoomIn(st.frame.w, st.frame.h) / devicePixelRatio
|
|
114
|
+
const fw = st.outW * s > 0 ? Math.min(1, st.frame.w / (st.outW * s)) : 1
|
|
115
|
+
const fh = st.outH * s > 0 ? Math.min(1, st.frame.h / (st.outH * s)) : 1
|
|
116
|
+
const cx = st.view.z === 'fit' ? 0.5 : st.view.cx
|
|
117
|
+
const cy = st.view.z === 'fit' ? 0.5 : st.view.cy
|
|
118
|
+
const go = (e: React.PointerEvent<HTMLDivElement>): void => {
|
|
119
|
+
const b = e.currentTarget.getBoundingClientRect()
|
|
120
|
+
st.setView({ cx: (e.clientX - b.left) / b.width, cy: (e.clientY - b.top) / b.height, z: st.zoomIn(st.frame.w, st.frame.h) })
|
|
121
|
+
}
|
|
122
|
+
return (
|
|
123
|
+
<div
|
|
124
|
+
className="nav"
|
|
125
|
+
style={{ aspectRatio: `${src.width} / ${src.height}` }}
|
|
126
|
+
onPointerDown={(e) => {
|
|
127
|
+
drag.current = true
|
|
128
|
+
e.currentTarget.setPointerCapture(e.pointerId)
|
|
129
|
+
go(e)
|
|
130
|
+
}}
|
|
131
|
+
onPointerMove={(e) => drag.current && go(e)}
|
|
132
|
+
onPointerUp={() => (drag.current = false)}
|
|
133
|
+
>
|
|
134
|
+
<img src={src.url} alt="" draggable={false} />
|
|
135
|
+
<div
|
|
136
|
+
className="navBox"
|
|
137
|
+
style={{ left: `${(cx - fw / 2) * 100}%`, top: `${(cy - fh / 2) * 100}%`, width: `${fw * 100}%`, height: `${fh * 100}%` }}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
)
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
const Sidebar = observer(function Sidebar(p: { st: AppSt }) {
|
|
144
|
+
const { st } = p
|
|
145
|
+
return (
|
|
146
|
+
<aside>
|
|
147
|
+
{st.layout === 'loupe' && (
|
|
148
|
+
<>
|
|
149
|
+
<label className="first">the loupe's crop: click or drag</label>
|
|
150
|
+
<Navigator st={st} />
|
|
151
|
+
</>
|
|
152
|
+
)}
|
|
153
|
+
<SourcePicker
|
|
154
|
+
source={st.source}
|
|
155
|
+
samples={st.samples}
|
|
156
|
+
onFile={(f, name) => void st.setSource(f, name)}
|
|
157
|
+
onSample={(name) => void st.loadSample(name)}
|
|
158
|
+
/>
|
|
159
|
+
<label>scale</label>
|
|
160
|
+
<Seg
|
|
161
|
+
value={st.scale}
|
|
162
|
+
options={[
|
|
163
|
+
[2, '×2'],
|
|
164
|
+
[4, '×4'],
|
|
165
|
+
]}
|
|
166
|
+
tips={['twice the source: about 600 dpi at card size for a 744 px wide scan', 'four times the source: about 1200 dpi']}
|
|
167
|
+
onChange={(v) => st.set('scale', v)}
|
|
168
|
+
/>
|
|
169
|
+
<div className="dim small">
|
|
170
|
+
{st.source != null ? `every result is ${st.outW}×${st.outH}: a model of another factor is brought to it with Lanczos` : ''}
|
|
171
|
+
</div>
|
|
172
|
+
<label className="check">
|
|
173
|
+
<input type="checkbox" checked={st.showClassic} onChange={(e) => st.set('showClassic', e.target.checked)} />
|
|
174
|
+
show classic models (2018 to 2022)
|
|
175
|
+
</label>
|
|
176
|
+
<label className="check">
|
|
177
|
+
<input type="checkbox" checked={st.showMissing} onChange={(e) => st.set('showMissing', e.target.checked)} />
|
|
178
|
+
show models this host lacks
|
|
179
|
+
</label>
|
|
180
|
+
<button className="primary" disabled={st.source == null || st.runnable.length === 0} onClick={() => st.runAll()}>
|
|
181
|
+
{st.busy ? 'running…' : `run all ${st.runnable.length}`}
|
|
182
|
+
</button>
|
|
183
|
+
<div className="dim small">one prompt at a time on {st.host}</div>
|
|
184
|
+
</aside>
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
export const App = observer(function App(p: { st: AppSt }) {
|
|
189
|
+
const { st } = p
|
|
190
|
+
useEffect(() => {
|
|
191
|
+
const onKey = (e: KeyboardEvent): void => {
|
|
192
|
+
const t = e.target
|
|
193
|
+
if (t instanceof HTMLInputElement || t instanceof HTMLSelectElement || e.metaKey || e.ctrlKey) return
|
|
194
|
+
if (e.key === 'Escape') st.closePair()
|
|
195
|
+
else if ((e.key === 'd' || e.key === 'D') && st.after != null) st.cycleMode(e.shiftKey ? -1 : 1)
|
|
196
|
+
else if (e.key === '+' || e.key === '=') st.step(1.5)
|
|
197
|
+
else if (e.key === '-' || e.key === '_') st.step(1 / 1.5)
|
|
198
|
+
else if (e.key === '0') st.fit()
|
|
199
|
+
else if (e.key === '1') st.actual()
|
|
200
|
+
else return
|
|
201
|
+
e.preventDefault()
|
|
202
|
+
}
|
|
203
|
+
window.addEventListener('keydown', onKey)
|
|
204
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
205
|
+
}, [st])
|
|
206
|
+
return (
|
|
207
|
+
<div className="app">
|
|
208
|
+
<header>
|
|
209
|
+
<h1>upscale explorer</h1>
|
|
210
|
+
<span className="dim">every upscaler on {st.host || '…'}, one image, judged at 100 % pixels</span>
|
|
211
|
+
</header>
|
|
212
|
+
{st.loadError != null && <div className="err">server: {st.loadError}</div>}
|
|
213
|
+
<div className="body">
|
|
214
|
+
<Sidebar st={st} />
|
|
215
|
+
<main>
|
|
216
|
+
<div className="toolbar">
|
|
217
|
+
<Seg
|
|
218
|
+
value={st.layout}
|
|
219
|
+
options={[
|
|
220
|
+
['grid', 'grid'],
|
|
221
|
+
['loupe', 'loupe'],
|
|
222
|
+
]}
|
|
223
|
+
tips={['every model, whole', 'every finished model on the same crop at the same zoom']}
|
|
224
|
+
onChange={(v) => st.set('layout', v)}
|
|
225
|
+
/>
|
|
226
|
+
{st.layout === 'loupe' && (
|
|
227
|
+
<>
|
|
228
|
+
<ZoomBar st={st} />
|
|
229
|
+
<Seg
|
|
230
|
+
value={st.tile}
|
|
231
|
+
options={[
|
|
232
|
+
[260, 'S'],
|
|
233
|
+
[360, 'M'],
|
|
234
|
+
[520, 'L'],
|
|
235
|
+
]}
|
|
236
|
+
tips={['small tiles', 'medium tiles', 'large tiles']}
|
|
237
|
+
onChange={(v) => st.set('tile', v)}
|
|
238
|
+
/>
|
|
239
|
+
<span className="dim small">wheel: zoom · drag: pan, every tile follows · click a name to compare</span>
|
|
240
|
+
</>
|
|
241
|
+
)}
|
|
242
|
+
{st.layout === 'grid' && <span className="dim small">click a result: compare it with Lanczos at 100 % where you clicked</span>}
|
|
243
|
+
</div>
|
|
244
|
+
{st.layout === 'grid' ? <Grid st={st} /> : <Loupe st={st} />}
|
|
245
|
+
</main>
|
|
246
|
+
</div>
|
|
247
|
+
<Pair st={st} />
|
|
248
|
+
</div>
|
|
249
|
+
)
|
|
250
|
+
})
|