comfy-ts 1.0.0 → 1.2.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/README.md +60 -11
- package/dist/cli.js +4 -4439
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +445 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7439 -340
- package/dist/index.d.ts +7457 -358
- package/dist/index.js +444 -172
- package/dist/index.js.map +1 -1
- package/dist/{run-tui-BFhba_oG.js → run-tui-BAdizWsO.js} +1244 -201
- package/dist/run-tui-BAdizWsO.js.map +1 -0
- package/dist/state-BYbxDgfr.js +5258 -0
- package/dist/state-BYbxDgfr.js.map +1 -0
- package/examples/README.md +32 -0
- package/examples/comfy-cloud/ace-step-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/anima-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/boogu-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/capybara-i2i.cflow.ts +85 -0
- package/examples/comfy-cloud/capybara-i2v.cflow.ts +90 -0
- package/examples/comfy-cloud/capybara-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/chatterbox-t2a.cflow.ts +79 -0
- package/examples/comfy-cloud/chroma-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/cloudHost.ts +41 -0
- package/examples/comfy-cloud/ernie-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/firered-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/flux1-i2i.cflow.ts +76 -0
- package/examples/comfy-cloud/flux1-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/flux2-i2i.cflow.ts +80 -0
- package/examples/comfy-cloud/flux2-t2i.cflow.ts +57 -0
- package/examples/comfy-cloud/hidream-i2i.cflow.ts +89 -0
- package/examples/comfy-cloud/hidream-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/hunyuan-video-i2v.cflow.ts +93 -0
- package/examples/comfy-cloud/hunyuan-video-t2v.cflow.ts +74 -0
- package/examples/comfy-cloud/ideogram4-t2i.cflow.ts +80 -0
- package/examples/comfy-cloud/kandinsky5-i2v.cflow.ts +95 -0
- package/examples/comfy-cloud/kandinsky5-t2i.cflow.ts +60 -0
- package/examples/comfy-cloud/kandinsky5-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/krea2-t2i.cflow.ts +59 -0
- package/examples/comfy-cloud/lens-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/longcat-i2i.cflow.ts +74 -0
- package/examples/comfy-cloud/longcat-t2i.cflow.ts +65 -0
- package/examples/comfy-cloud/ltxv-i2v.cflow.ts +92 -0
- package/examples/comfy-cloud/ltxv-t2v.cflow.ts +78 -0
- package/examples/comfy-cloud/newbie-t2i.cflow.ts +67 -0
- package/examples/comfy-cloud/omnigen2-i2i.cflow.ts +86 -0
- package/examples/comfy-cloud/omnigen2-t2i.cflow.ts +62 -0
- package/examples/comfy-cloud/ovis-t2i.cflow.ts +56 -0
- package/examples/comfy-cloud/pixeldit-t2i.cflow.ts +63 -0
- package/examples/comfy-cloud/qwen-image-i2i.cflow.ts +69 -0
- package/examples/comfy-cloud/qwen-image-t2i.cflow.ts +55 -0
- package/examples/comfy-cloud/sd35-t2i.cflow.ts +48 -0
- package/examples/comfy-cloud/sdk.d.ts +445 -57
- package/examples/comfy-cloud/sdxl-t2i.cflow.ts +69 -0
- package/examples/comfy-cloud/stable-audio-t2a.cflow.ts +53 -0
- package/examples/comfy-cloud/svd-i2v.cflow.ts +75 -0
- package/examples/comfy-cloud/wan21-i2v.cflow.ts +83 -0
- package/examples/comfy-cloud/wan21-t2v.cflow.ts +64 -0
- package/examples/comfy-cloud/wan22-5b-t2v.cflow.ts +69 -0
- package/examples/comfy-cloud/wan22-i2v.cflow.ts +107 -0
- package/examples/comfy-cloud/wan22-t2v.cflow.ts +98 -0
- package/examples/comfy-cloud/z-image-t2i.cflow.ts +62 -0
- package/examples/images/README.md +18 -0
- package/examples/images/bear_1024x1024.jpg +0 -0
- package/examples/images/deer_768x1344.jpg +0 -0
- package/examples/images/dog_512x512.jpg +0 -0
- package/examples/images/lioness_768x768.jpg +0 -0
- package/examples/images/pug_200x300.jpg +0 -0
- package/examples/images/walrus_1344x768.jpg +0 -0
- package/examples/{01-txt2img.cflow.ts → rvion/01-txt2img.cflow.ts} +1 -1
- package/examples/{02-img2img-upload.cflow.ts → rvion/02-img2img-upload.cflow.ts} +7 -18
- package/examples/{03-export-workflow-json.cflow.ts → rvion/03-export-workflow-json.cflow.ts} +1 -1
- package/examples/{04-krea2-turbo-t2i.cflow.ts → rvion/04-krea2-turbo-t2i.cflow.ts} +2 -2
- package/examples/rvion/05-comfy-cloud.cflow.ts +51 -0
- package/examples/rvion/06-qwen-image-edit.cflow.ts +89 -0
- package/guide-for-agents.md +7 -1
- package/package.json +18 -4
- package/src/cli/tui/components/CopyOverlay.tsx +25 -0
- package/src/cli/tui/components/Header.tsx +9 -4
- package/src/cli/tui/components/HostPanel.tsx +3 -2
- package/src/cli/tui/components/HostsOverlay.tsx +33 -0
- package/src/cli/tui/components/PreviewPanel.tsx +9 -8
- package/src/cli/tui/components/StatusBar.tsx +39 -9
- package/src/cli/tui/components/TreePanel.tsx +17 -7
- package/src/cli/tui/components/TuiApp.tsx +65 -5
- package/src/cli/tui/discoverWorkflows.ts +7 -41
- package/src/cli/tui/imagePicker/ImagePickerOverlay.tsx +72 -0
- package/src/cli/tui/imagePicker/ImagePickerSt.ts +288 -0
- package/src/cli/tui/imagePicker/fsListing.ts +48 -0
- package/src/cli/tui/imagePicker/pickerPrefs.ts +78 -0
- package/src/cli/tui/run-tui.tsx +49 -8
- package/src/cli/tui/state/DraftsSt.ts +3 -2
- package/src/cli/tui/state/ExecSt.ts +108 -12
- package/src/cli/tui/state/HostSt.ts +94 -10
- package/src/cli/tui/state/LorasSt.ts +14 -36
- package/src/cli/tui/state/PickerSt.ts +8 -2
- package/src/cli/tui/state/PreviewSt.ts +28 -2
- package/src/cli/tui/state/QueueSt.ts +2 -2
- package/src/cli/tui/state/SettingsSt.ts +25 -7
- package/src/cli/tui/state/TreeSt.ts +139 -36
- package/src/cli/tui/state/TuiSt.ts +53 -6
- package/src/cli/tui/state/WorkflowsSt.ts +14 -2
- package/src/cli/tui/treeRows.ts +165 -0
- package/src/exampleAssets.ts +56 -0
- package/src/graph/ComfyNode.ts +4 -1
- package/src/host/ComfyHost.ts +7 -0
- package/src/index.ts +7 -0
- package/src/manager/ComfyRegistry.ts +37 -9
- package/src/manager/generated/KnownComfyCustomNodeName.ts +23852 -1926
- package/src/manager/generated/KnownComfyPluginTitle.ts +6854 -236
- package/src/manager/generated/KnownComfyPluginURL.ts +3425 -111
- package/src/manager/generated/KnownModel_Base.ts +23 -7
- package/src/manager/generated/KnownModel_FileName.ts +421 -0
- package/src/manager/generated/KnownModel_Name.ts +421 -0
- package/src/manager/generated/KnownModel_SavePath.ts +34 -8
- package/src/manager/generated/KnownModel_Type.ts +18 -14
- package/src/manager/json/alter-list.json +221 -221
- package/src/manager/json/custom-node-list.json +61020 -21946
- package/src/manager/json/extension-node-map.json +81077 -31176
- package/src/manager/json/github-stats.json +29321 -12601
- package/src/manager/json/model-list.json +5935 -4997
- package/src/manager/loaders/parseReport.ts +55 -0
- package/src/manager/loaders/step1_downloadComfyManagerJSONs.ts +15 -49
- package/src/manager/loaders/step2_custom-node-list-loader.ts +38 -83
- package/src/manager/loaders/step3_extension-node-map-loader.ts +36 -142
- package/src/manager/loaders/step4_model-list-loader.ts +25 -36
- package/src/manager/loaders/step5_alter-list-loader.ts +29 -0
- package/src/manager/loaders/step6_github-stats-loader.ts +23 -0
- package/src/manager/script-update-manager.bun.ts +9 -1
- package/src/manager/types/ComfyManagerAlterInfo.ts +13 -0
- package/src/manager/types/ComfyManagerFileModelInfo.ts +7 -3
- package/src/manager/types/ComfyManagerFilePluginContent.ts +6 -9
- package/src/manager/types/ComfyManagerFilePluginList.ts +3 -3
- package/src/manager/types/ComfyManagerGithubStats.ts +9 -0
- package/src/manager/types/ComfyManagerPluginContentMetadata.ts +2 -3
- package/src/manager/types/ComfyManagerPluginInfo.ts +48 -34
- package/src/runner/ComfyWorkflowLayout.ts +6 -4
- package/src/sdk-generator/ComfySchema.ts +14 -1
- package/src/sdk-generator/comfyui-sdk-codegen.ts +15 -0
- package/src/sdk-generator/inputWidgetKind.ts +17 -0
- package/src/state.ts +7 -1
- package/src/vars/ComfyVars.ts +106 -5
- package/src/vars/DefinedWorkflow.ts +28 -10
- package/dist/DefinedWorkflow-O3ynII3Y.js +0 -598
- package/dist/DefinedWorkflow-O3ynII3Y.js.map +0 -1
- package/dist/run-tui-BFhba_oG.js.map +0 -1
- package/examples/05-comfy-cloud.cflow.ts +0 -67
- package/src/utils/tryExtracting.ts +0 -41
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// ernie t2i on Comfy Cloud — ERNIE Image Turbo (Baidu), 8-step distilled text to image (cfg 1, flux2 vae)
|
|
2
|
+
// source template: image_ernie_image_turbo.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/ernie-t2i.cflow.ts ["prompt"] [seed]
|
|
5
|
+
import { v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
export const ernieT2i = host.defineWorkflow({
|
|
11
|
+
id: 'ernie-t2i',
|
|
12
|
+
vars: {
|
|
13
|
+
// ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
|
|
14
|
+
prompt: v.prompt(
|
|
15
|
+
'side-profile portrait of a young woman with sleek dark hair in a low bun, white ruffled-collar shirt, deep indigo twilight sky, neon pink-orange rim light tracing her profile, cinematic color blocking',
|
|
16
|
+
),
|
|
17
|
+
seed: v.seed(42),
|
|
18
|
+
steps: v.int(8, { min: 1, max: 40 }),
|
|
19
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
20
|
+
},
|
|
21
|
+
build: (b, vars) => {
|
|
22
|
+
const model = b.UNETLoader({ unet_name: 'ernie-image-turbo.safetensors', weight_dtype: 'default' })
|
|
23
|
+
const clip = b.CLIPLoader({ clip_name: 'ministral-3-3b.safetensors', type: 'flux2', device: 'default' })
|
|
24
|
+
const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
25
|
+
// turbo distill: no negative lines → zeroed-out conditioning (the template's own default)
|
|
26
|
+
const negative =
|
|
27
|
+
vars.prompt.negative === ''
|
|
28
|
+
? b.ConditioningZeroOut({ conditioning: positive })
|
|
29
|
+
: b.CLIPTextEncode({ clip, text: vars.prompt.negative })
|
|
30
|
+
const samples = b.KSampler({
|
|
31
|
+
model,
|
|
32
|
+
positive,
|
|
33
|
+
negative,
|
|
34
|
+
latent_image: b.EmptyFlux2LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
35
|
+
seed: vars.seed,
|
|
36
|
+
steps: vars.steps,
|
|
37
|
+
cfg: 1,
|
|
38
|
+
sampler_name: 'euler',
|
|
39
|
+
scheduler: 'simple',
|
|
40
|
+
denoise: 1,
|
|
41
|
+
})
|
|
42
|
+
b.SaveImage({
|
|
43
|
+
images: b.VAEDecode({ samples, vae: b.VAELoader({ vae_name: 'flux2-vae.safetensors' }) }),
|
|
44
|
+
filename_prefix: 'comfy-ts-zoo/ernie-t2i',
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export default ernieT2i
|
|
50
|
+
|
|
51
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
52
|
+
if (import.meta.main) {
|
|
53
|
+
requireCloudKey()
|
|
54
|
+
if (process.argv[2]) ernieT2i.vars.prompt.set(process.argv[2])
|
|
55
|
+
if (process.argv[3]) ernieT2i.vars.seed.set(Number(process.argv[3]))
|
|
56
|
+
const execution = await ernieT2i.run({ log: true })
|
|
57
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
58
|
+
host.disconnect()
|
|
59
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// firered i2i on Comfy Cloud — FireRed Image Edit 1.1, instruction-driven image editing (qwen-image-edit lineage)
|
|
2
|
+
// source template: image_firered_image_edit1_1.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/firered-i2i.cflow.ts [path/to/image.png] ["edit instruction"]
|
|
5
|
+
import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
// bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
|
|
11
|
+
const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
|
|
12
|
+
|
|
13
|
+
export const fireredI2i = host.defineWorkflow({
|
|
14
|
+
id: 'firered-i2i',
|
|
15
|
+
vars: {
|
|
16
|
+
image,
|
|
17
|
+
prompt: v.prompt(
|
|
18
|
+
'restyle the outfit into sheer frosted white fabric with glowing fiber-optic threads, photorealistic',
|
|
19
|
+
),
|
|
20
|
+
seed: v.seed(43),
|
|
21
|
+
// template defaults: 40 steps / cfg 4 (its optional 8-step Lightning lora branch ships off, dropped here)
|
|
22
|
+
steps: v.int(40, { min: 1, max: 60 }),
|
|
23
|
+
cfg: v.float(4, { min: 0, max: 30 }),
|
|
24
|
+
},
|
|
25
|
+
// async build: the input image is uploaded (hash-named, deduped) per run
|
|
26
|
+
build: async (b, vars, wf) => {
|
|
27
|
+
const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
|
|
28
|
+
const scaled = b.ImageScaleToTotalPixels({
|
|
29
|
+
image: await img.loadInWorkflow_viaLoadImageNode(wf),
|
|
30
|
+
upscale_method: 'lanczos',
|
|
31
|
+
megapixels: 1,
|
|
32
|
+
})
|
|
33
|
+
const clip = b.CLIPLoader({ clip_name: 'qwen_2.5_vl_7b_fp8_scaled.safetensors', type: 'qwen_image' })
|
|
34
|
+
const vae = b.VAELoader({ vae_name: 'qwen_image_vae.safetensors' })
|
|
35
|
+
// edit conditioning reads the input image itself: both branches reference it
|
|
36
|
+
const encode = (text: string) => b.TextEncodeQwenImageEditPlus({ prompt: text, clip, vae, image1: scaled })
|
|
37
|
+
const model = b.CFGNorm({
|
|
38
|
+
model: b.ModelSamplingAuraFlow({
|
|
39
|
+
model: b.UNETLoader({
|
|
40
|
+
unet_name: 'FireRed-Image-Edit-1.1-transformer.safetensors',
|
|
41
|
+
weight_dtype: 'default',
|
|
42
|
+
}),
|
|
43
|
+
shift: 3.1,
|
|
44
|
+
}),
|
|
45
|
+
strength: 1,
|
|
46
|
+
pre_cfg: false,
|
|
47
|
+
})
|
|
48
|
+
const samples = b.KSampler({
|
|
49
|
+
model,
|
|
50
|
+
positive: encode(vars.prompt.positive),
|
|
51
|
+
negative: encode(vars.prompt.negative),
|
|
52
|
+
latent_image: b.VAEEncode({ pixels: scaled, vae }),
|
|
53
|
+
seed: vars.seed,
|
|
54
|
+
steps: vars.steps,
|
|
55
|
+
cfg: vars.cfg,
|
|
56
|
+
sampler_name: 'euler',
|
|
57
|
+
scheduler: 'simple',
|
|
58
|
+
denoise: 1,
|
|
59
|
+
})
|
|
60
|
+
b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/firered-i2i' })
|
|
61
|
+
},
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
export default fireredI2i
|
|
65
|
+
|
|
66
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
67
|
+
if (import.meta.main) {
|
|
68
|
+
requireCloudKey()
|
|
69
|
+
if (process.argv[2]) fireredI2i.vars.image.set(process.argv[2])
|
|
70
|
+
if (process.argv[3]) fireredI2i.vars.prompt.set(process.argv[3])
|
|
71
|
+
const execution = await fireredI2i.run({ log: true })
|
|
72
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
73
|
+
host.disconnect()
|
|
74
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// flux1 i2i on Comfy Cloud — Flux.1 Kontext Dev image editing: reference latent steers the edit
|
|
2
|
+
// source template: flux_kontext_dev_basic.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/flux1-i2i.cflow.ts [path/to/image.png] ["prompt"]
|
|
5
|
+
import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
// bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
|
|
11
|
+
const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
|
|
12
|
+
|
|
13
|
+
export const flux1I2i = host.defineWorkflow({
|
|
14
|
+
id: 'flux1-i2i',
|
|
15
|
+
vars: {
|
|
16
|
+
image,
|
|
17
|
+
prompt: v.prompt('turn this into a watercolor painting, keep the composition'),
|
|
18
|
+
seed: v.seed(42),
|
|
19
|
+
steps: v.int(20, { min: 1, max: 50 }),
|
|
20
|
+
guidance: v.float(2.5, { min: 0, max: 10 }),
|
|
21
|
+
},
|
|
22
|
+
// async build: the input image is uploaded (hash-named, deduped) per run
|
|
23
|
+
build: async (b, vars, wf) => {
|
|
24
|
+
const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
|
|
25
|
+
const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
|
|
26
|
+
|
|
27
|
+
const model = b.UNETLoader({ unet_name: 'flux1-dev-kontext_fp8_scaled.safetensors', weight_dtype: 'default' })
|
|
28
|
+
const clip = b.DualCLIPLoader({
|
|
29
|
+
clip_name1: 'clip_l.safetensors',
|
|
30
|
+
clip_name2: 't5xxl_fp8_e4m3fn_scaled.safetensors',
|
|
31
|
+
type: 'flux',
|
|
32
|
+
device: 'default',
|
|
33
|
+
})
|
|
34
|
+
const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
|
|
35
|
+
|
|
36
|
+
// kontext wants its reference at a supported resolution; the edit denoises
|
|
37
|
+
// fully (denoise 1) — the input steers through the reference latent
|
|
38
|
+
const latent = b.VAEEncode({ pixels: b.FluxKontextImageScale({ image: loaded }), vae })
|
|
39
|
+
|
|
40
|
+
const encoded = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
41
|
+
const positive = b.FluxGuidance({
|
|
42
|
+
conditioning: b.ReferenceLatent({ conditioning: encoded, latent }),
|
|
43
|
+
guidance: vars.guidance,
|
|
44
|
+
})
|
|
45
|
+
const negative =
|
|
46
|
+
vars.prompt.negative === ''
|
|
47
|
+
? b.ConditioningZeroOut({ conditioning: encoded })
|
|
48
|
+
: b.CLIPTextEncode({ clip, text: vars.prompt.negative })
|
|
49
|
+
|
|
50
|
+
const samples = b.KSampler({
|
|
51
|
+
model,
|
|
52
|
+
positive,
|
|
53
|
+
negative,
|
|
54
|
+
latent_image: latent,
|
|
55
|
+
seed: vars.seed,
|
|
56
|
+
steps: vars.steps,
|
|
57
|
+
cfg: 1,
|
|
58
|
+
sampler_name: 'euler',
|
|
59
|
+
scheduler: 'simple',
|
|
60
|
+
denoise: 1,
|
|
61
|
+
})
|
|
62
|
+
b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/flux1-i2i' })
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export default flux1I2i
|
|
67
|
+
|
|
68
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
69
|
+
if (import.meta.main) {
|
|
70
|
+
requireCloudKey()
|
|
71
|
+
if (process.argv[2]) flux1I2i.vars.image.set(process.argv[2])
|
|
72
|
+
if (process.argv[3]) flux1I2i.vars.prompt.set(process.argv[3])
|
|
73
|
+
const execution = await flux1I2i.run({ log: true })
|
|
74
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
75
|
+
host.disconnect()
|
|
76
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// flux1 t2i on Comfy Cloud — Flux.1 Dev (UNET + dual CLIP), guidance-distilled: cfg 1, zeroed negative
|
|
2
|
+
// source template: flux_dev_checkpoint_example.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/flux1-t2i.cflow.ts ["prompt"] [seed]
|
|
5
|
+
import { v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
export const flux1T2i = host.defineWorkflow({
|
|
11
|
+
id: 'flux1-t2i',
|
|
12
|
+
vars: {
|
|
13
|
+
prompt: v.prompt(
|
|
14
|
+
'photography portrait of an artist, messy casual bun, smiling at the camera, cinematic soft daylight, shallow depth of field, film grain, high detail',
|
|
15
|
+
),
|
|
16
|
+
seed: v.seed(42),
|
|
17
|
+
steps: v.int(20, { min: 1, max: 50 }),
|
|
18
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
19
|
+
},
|
|
20
|
+
build: (b, vars) => {
|
|
21
|
+
const model = b.UNETLoader({ unet_name: 'flux1-dev.safetensors', weight_dtype: 'default' })
|
|
22
|
+
const clip = b.DualCLIPLoader({
|
|
23
|
+
clip_name1: 'clip_l.safetensors',
|
|
24
|
+
clip_name2: 't5xxl_fp16.safetensors',
|
|
25
|
+
type: 'flux',
|
|
26
|
+
device: 'default',
|
|
27
|
+
})
|
|
28
|
+
const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
|
|
29
|
+
|
|
30
|
+
const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
31
|
+
// distilled model ignores cfg: empty negative stays zeroed out, like the template
|
|
32
|
+
const negative =
|
|
33
|
+
vars.prompt.negative === ''
|
|
34
|
+
? b.ConditioningZeroOut({ conditioning: positive })
|
|
35
|
+
: b.CLIPTextEncode({ clip, text: vars.prompt.negative })
|
|
36
|
+
|
|
37
|
+
const samples = b.KSampler({
|
|
38
|
+
model,
|
|
39
|
+
positive,
|
|
40
|
+
negative,
|
|
41
|
+
latent_image: b.EmptySD3LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
42
|
+
seed: vars.seed,
|
|
43
|
+
steps: vars.steps,
|
|
44
|
+
cfg: 1,
|
|
45
|
+
sampler_name: 'euler',
|
|
46
|
+
scheduler: 'simple',
|
|
47
|
+
denoise: 1,
|
|
48
|
+
})
|
|
49
|
+
b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/flux1-t2i' })
|
|
50
|
+
},
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
export default flux1T2i
|
|
54
|
+
|
|
55
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
56
|
+
if (import.meta.main) {
|
|
57
|
+
requireCloudKey()
|
|
58
|
+
if (process.argv[2]) flux1T2i.vars.prompt.set(process.argv[2])
|
|
59
|
+
if (process.argv[3]) flux1T2i.vars.seed.set(Number(process.argv[3]))
|
|
60
|
+
const execution = await flux1T2i.run({ log: true })
|
|
61
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
62
|
+
host.disconnect()
|
|
63
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// flux2 i2i on Comfy Cloud — FLUX.2 Klein 4B distilled image edit (prompt-driven, 4 steps, cfg 1)
|
|
2
|
+
// source template: image_flux2_klein_image_edit_4b_distilled.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/flux2-i2i.cflow.ts [path/to/image.png] ["edit prompt"] [seed]
|
|
5
|
+
import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
// bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
|
|
11
|
+
const image = v.image(exampleImagePath('dog_512x512.jpg'))
|
|
12
|
+
|
|
13
|
+
export const flux2I2i = host.defineWorkflow({
|
|
14
|
+
id: 'flux2-i2i',
|
|
15
|
+
vars: {
|
|
16
|
+
image,
|
|
17
|
+
prompt: v.prompt('Change the color to blue.'),
|
|
18
|
+
seed: v.seed(7),
|
|
19
|
+
steps: v.int(4, { min: 1, max: 60 }),
|
|
20
|
+
},
|
|
21
|
+
// async build: the input image is uploaded (hash-named, deduped) per run
|
|
22
|
+
build: async (b, vars, wf) => {
|
|
23
|
+
const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
|
|
24
|
+
const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
|
|
25
|
+
|
|
26
|
+
const model = b.UNETLoader({ unet_name: 'flux-2-klein-4b-fp8.safetensors', weight_dtype: 'default' })
|
|
27
|
+
const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'flux2', device: 'default' })
|
|
28
|
+
const vae = b.VAELoader({ vae_name: 'flux2-vae.safetensors' })
|
|
29
|
+
|
|
30
|
+
// reference image → ~1MP; its size drives both the latent and the scheduler
|
|
31
|
+
const scaled = b.ImageScaleToTotalPixels({
|
|
32
|
+
image: loaded,
|
|
33
|
+
upscale_method: 'nearest-exact',
|
|
34
|
+
megapixels: 1,
|
|
35
|
+
resolution_steps: 1,
|
|
36
|
+
})
|
|
37
|
+
const size = b.GetImageSize({ image: scaled })
|
|
38
|
+
const reference = b.VAEEncode({ pixels: scaled, vae })
|
|
39
|
+
|
|
40
|
+
// distilled: prompt only, the negative branch is the zeroed-out positive
|
|
41
|
+
const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
42
|
+
const samples = b.SamplerCustomAdvanced({
|
|
43
|
+
noise: b.RandomNoise({ noise_seed: vars.seed }),
|
|
44
|
+
guider: b.CFGGuider({
|
|
45
|
+
model,
|
|
46
|
+
positive: b.ReferenceLatent({ conditioning: positive, latent: reference }),
|
|
47
|
+
negative: b.ReferenceLatent({
|
|
48
|
+
conditioning: b.ConditioningZeroOut({ conditioning: positive }),
|
|
49
|
+
latent: reference,
|
|
50
|
+
}),
|
|
51
|
+
cfg: 1,
|
|
52
|
+
}),
|
|
53
|
+
sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
|
|
54
|
+
sigmas: b.Flux2Scheduler({ steps: vars.steps, width: size.outputs.width, height: size.outputs.height }),
|
|
55
|
+
latent_image: b.EmptyFlux2LatentImage({
|
|
56
|
+
width: size.outputs.width,
|
|
57
|
+
height: size.outputs.height,
|
|
58
|
+
batch_size: 1,
|
|
59
|
+
}),
|
|
60
|
+
})
|
|
61
|
+
b.SaveImage({
|
|
62
|
+
images: b.VAEDecode({ samples: samples.outputs.output, vae }),
|
|
63
|
+
filename_prefix: 'comfy-ts-zoo/flux2-i2i',
|
|
64
|
+
})
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
export default flux2I2i
|
|
69
|
+
|
|
70
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
71
|
+
if (import.meta.main) {
|
|
72
|
+
requireCloudKey()
|
|
73
|
+
if (process.argv[2]) flux2I2i.vars.image.set(process.argv[2])
|
|
74
|
+
if (process.argv[3]) flux2I2i.vars.prompt.set(process.argv[3])
|
|
75
|
+
if (process.argv[4]) flux2I2i.vars.seed.set(Number(process.argv[4]))
|
|
76
|
+
|
|
77
|
+
const execution = await flux2I2i.run({ log: true })
|
|
78
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
79
|
+
host.disconnect()
|
|
80
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// flux2 t2i on Comfy Cloud — FLUX.2 Klein base 4B, CFG-guided text to image
|
|
2
|
+
// source template: image_flux2_klein_text_to_image.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/flux2-t2i.cflow.ts ["prompt"] [seed]
|
|
5
|
+
import { v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
export const flux2T2i = host.defineWorkflow({
|
|
11
|
+
id: 'flux2-t2i',
|
|
12
|
+
vars: {
|
|
13
|
+
// ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
|
|
14
|
+
prompt: v.prompt(
|
|
15
|
+
'A hedgehog wearing a tiny party hat surrounded by confetti, early digital camera style, slight noise, flash photography, candid moment, 2000s digicam aesthetic, festive birthday celebration atmosphere',
|
|
16
|
+
),
|
|
17
|
+
seed: v.seed(0),
|
|
18
|
+
steps: v.int(20, { min: 1, max: 60 }),
|
|
19
|
+
cfg: v.float(5, { min: 0, max: 30 }),
|
|
20
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
21
|
+
},
|
|
22
|
+
build: (b, vars) => {
|
|
23
|
+
const model = b.UNETLoader({ unet_name: 'flux-2-klein-base-4b.safetensors', weight_dtype: 'default' })
|
|
24
|
+
const clip = b.CLIPLoader({ clip_name: 'qwen_3_4b.safetensors', type: 'flux2', device: 'default' })
|
|
25
|
+
const vae = b.VAELoader({ vae_name: 'flux2-vae.safetensors' })
|
|
26
|
+
|
|
27
|
+
const samples = b.SamplerCustomAdvanced({
|
|
28
|
+
noise: b.RandomNoise({ noise_seed: vars.seed }),
|
|
29
|
+
guider: b.CFGGuider({
|
|
30
|
+
model,
|
|
31
|
+
positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
|
|
32
|
+
negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
|
|
33
|
+
cfg: vars.cfg,
|
|
34
|
+
}),
|
|
35
|
+
sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
|
|
36
|
+
sigmas: b.Flux2Scheduler({ steps: vars.steps, width: vars.size.width, height: vars.size.height }),
|
|
37
|
+
latent_image: b.EmptyFlux2LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
38
|
+
})
|
|
39
|
+
b.SaveImage({
|
|
40
|
+
images: b.VAEDecode({ samples: samples.outputs.output, vae }),
|
|
41
|
+
filename_prefix: 'comfy-ts-zoo/flux2-t2i',
|
|
42
|
+
})
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
export default flux2T2i
|
|
47
|
+
|
|
48
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
49
|
+
if (import.meta.main) {
|
|
50
|
+
requireCloudKey()
|
|
51
|
+
if (process.argv[2]) flux2T2i.vars.prompt.set(process.argv[2])
|
|
52
|
+
if (process.argv[3]) flux2T2i.vars.seed.set(Number(process.argv[3]))
|
|
53
|
+
|
|
54
|
+
const execution = await flux2T2i.run({ log: true })
|
|
55
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
56
|
+
host.disconnect()
|
|
57
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// hidream i2i on Comfy Cloud — HiDream E1.1 instruction-driven image editing (ip2p conditioning + dual-cfg guider)
|
|
2
|
+
// source template: hidream_e1_1.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/hidream-i2i.cflow.ts [path/to/image.png] ["edit instruction"]
|
|
5
|
+
import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
// bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
|
|
11
|
+
const image = v.image(exampleImagePath('bear_1024x1024.jpg'))
|
|
12
|
+
|
|
13
|
+
export const hidreamI2i = host.defineWorkflow({
|
|
14
|
+
id: 'hidream-i2i',
|
|
15
|
+
vars: {
|
|
16
|
+
image,
|
|
17
|
+
prompt: v.prompt('turn this into a watercolor painting\n- low quality, blurry, distorted'),
|
|
18
|
+
seed: v.seed(42),
|
|
19
|
+
steps: v.int(20, { min: 1, max: 60 }),
|
|
20
|
+
// the template promotes both guider cfgs as top-level tweakables: cfg → cfg_conds, cfg2 → cfg_cond2_negative
|
|
21
|
+
cfg: v.float(3, { min: 0, max: 20 }),
|
|
22
|
+
cfg2: v.float(1.5, { min: 0, max: 20 }),
|
|
23
|
+
},
|
|
24
|
+
// async build: the input image is uploaded (hash-named, deduped) per run
|
|
25
|
+
build: async (b, vars, wf) => {
|
|
26
|
+
const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
|
|
27
|
+
const pixels = b.ImageScaleToTotalPixels({
|
|
28
|
+
image: await img.loadInWorkflow_viaLoadImageNode(wf),
|
|
29
|
+
upscale_method: 'area',
|
|
30
|
+
megapixels: 1,
|
|
31
|
+
resolution_steps: 1,
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const clip = b.QuadrupleCLIPLoader({
|
|
35
|
+
clip_name1: 'clip_g_hidream.safetensors',
|
|
36
|
+
clip_name2: 'clip_l_hidream.safetensors',
|
|
37
|
+
clip_name3: 't5xxl_fp8_e4m3fn_scaled.safetensors',
|
|
38
|
+
clip_name4: 'llama_3.1_8b_instruct_fp8_scaled.safetensors',
|
|
39
|
+
})
|
|
40
|
+
const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
|
|
41
|
+
const model = b.CFGNorm({
|
|
42
|
+
model: b.UNETLoader({ unet_name: 'hidream_e1_1_bf16.safetensors', weight_dtype: 'fp8_e4m3fn_fast' }),
|
|
43
|
+
strength: 1,
|
|
44
|
+
pre_cfg: false,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
48
|
+
// ip2p conditioning appends the input image latent to both text branches
|
|
49
|
+
const cond = b.InstructPixToPixConditioning({
|
|
50
|
+
positive,
|
|
51
|
+
negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
|
|
52
|
+
vae,
|
|
53
|
+
pixels,
|
|
54
|
+
})
|
|
55
|
+
// the guider's unconditional branch is the PLAIN positive encode (no image), exactly like the template
|
|
56
|
+
const guider = b.DualCFGGuider({
|
|
57
|
+
model,
|
|
58
|
+
cond1: cond.outputs.positive,
|
|
59
|
+
cond2: cond.outputs.negative,
|
|
60
|
+
negative: positive,
|
|
61
|
+
cfg_conds: vars.cfg,
|
|
62
|
+
cfg_cond2_negative: vars.cfg2,
|
|
63
|
+
style: 'regular',
|
|
64
|
+
})
|
|
65
|
+
const samples = b.SamplerCustomAdvanced({
|
|
66
|
+
noise: b.RandomNoise({ noise_seed: vars.seed }),
|
|
67
|
+
guider,
|
|
68
|
+
sampler: b.KSamplerSelect({ sampler_name: 'euler' }),
|
|
69
|
+
sigmas: b.BasicScheduler({ model, scheduler: 'simple', steps: vars.steps, denoise: 1 }),
|
|
70
|
+
latent_image: cond.outputs.latent,
|
|
71
|
+
})
|
|
72
|
+
b.SaveImage({
|
|
73
|
+
images: b.VAEDecode({ samples: samples.outputs.output, vae }),
|
|
74
|
+
filename_prefix: 'comfy-ts-zoo/hidream-i2i',
|
|
75
|
+
})
|
|
76
|
+
},
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
export default hidreamI2i
|
|
80
|
+
|
|
81
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
82
|
+
if (import.meta.main) {
|
|
83
|
+
requireCloudKey()
|
|
84
|
+
if (process.argv[2]) hidreamI2i.vars.image.set(process.argv[2])
|
|
85
|
+
if (process.argv[3]) hidreamI2i.vars.prompt.set(process.argv[3])
|
|
86
|
+
const execution = await hidreamI2i.run({ log: true })
|
|
87
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
88
|
+
host.disconnect()
|
|
89
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// hidream t2i on Comfy Cloud — HiDream I1 Fast fp8, 16-step distilled (cfg 1, lcm), quadruple text encoder
|
|
2
|
+
// source template: hidream_i1_fast.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/hidream-t2i.cflow.ts ["prompt"] [seed]
|
|
5
|
+
import { v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
export const hidreamT2i = host.defineWorkflow({
|
|
11
|
+
id: 'hidream-t2i',
|
|
12
|
+
vars: {
|
|
13
|
+
prompt: v.prompt(
|
|
14
|
+
'a lo-fi grungy wide shot of a ragged large red tree leaning slightly to one side, Polaroid aesthetic, alone in a desolate landscape, lit by a red light, pitch black background\n- bad ugly jpeg artifacts',
|
|
15
|
+
),
|
|
16
|
+
seed: v.seed(42),
|
|
17
|
+
steps: v.int(16, { min: 1, max: 50 }),
|
|
18
|
+
size: v.size({ width: 1024, height: 1024 }),
|
|
19
|
+
},
|
|
20
|
+
build: (b, vars) => {
|
|
21
|
+
// hidream stacks four text encoders: clip-l, clip-g, t5xxl, llama 3.1 8b
|
|
22
|
+
const clip = b.QuadrupleCLIPLoader({
|
|
23
|
+
clip_name1: 'clip_l_hidream.safetensors',
|
|
24
|
+
clip_name2: 'clip_g_hidream.safetensors',
|
|
25
|
+
clip_name3: 't5xxl_fp8_e4m3fn_scaled.safetensors',
|
|
26
|
+
clip_name4: 'llama_3.1_8b_instruct_fp8_scaled.safetensors',
|
|
27
|
+
})
|
|
28
|
+
const vae = b.VAELoader({ vae_name: 'ae.safetensors' })
|
|
29
|
+
const model = b.ModelSamplingSD3({
|
|
30
|
+
model: b.UNETLoader({ unet_name: 'hidream_i1_fast_fp8.safetensors', weight_dtype: 'default' }),
|
|
31
|
+
shift: 3,
|
|
32
|
+
})
|
|
33
|
+
const positive = b.CLIPTextEncode({ clip, text: vars.prompt.positive })
|
|
34
|
+
// distilled model runs cfg 1: empty negative stays zeroed out
|
|
35
|
+
const negative =
|
|
36
|
+
vars.prompt.negative === ''
|
|
37
|
+
? b.ConditioningZeroOut({ conditioning: positive })
|
|
38
|
+
: b.CLIPTextEncode({ clip, text: vars.prompt.negative })
|
|
39
|
+
const samples = b.KSampler({
|
|
40
|
+
model,
|
|
41
|
+
positive,
|
|
42
|
+
negative,
|
|
43
|
+
latent_image: b.EmptySD3LatentImage({ width: vars.size.width, height: vars.size.height, batch_size: 1 }),
|
|
44
|
+
seed: vars.seed,
|
|
45
|
+
steps: vars.steps,
|
|
46
|
+
cfg: 1,
|
|
47
|
+
sampler_name: 'lcm',
|
|
48
|
+
scheduler: 'normal',
|
|
49
|
+
denoise: 1,
|
|
50
|
+
})
|
|
51
|
+
b.SaveImage({ images: b.VAEDecode({ samples, vae }), filename_prefix: 'comfy-ts-zoo/hidream-t2i' })
|
|
52
|
+
},
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
export default hidreamT2i
|
|
56
|
+
|
|
57
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
58
|
+
if (import.meta.main) {
|
|
59
|
+
requireCloudKey()
|
|
60
|
+
if (process.argv[2]) hidreamT2i.vars.prompt.set(process.argv[2])
|
|
61
|
+
if (process.argv[3]) hidreamT2i.vars.seed.set(Number(process.argv[3]))
|
|
62
|
+
const execution = await hidreamT2i.run({ log: true })
|
|
63
|
+
for (const img of execution.images) console.log(`🟢 ${img.absPath}`)
|
|
64
|
+
host.disconnect()
|
|
65
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// hunyuan-video i2v on Comfy Cloud — HunyuanVideo 1.5 720p image to video, 5s @ 24fps from a start image
|
|
2
|
+
// source template: video_hunyuan_video_1.5_720p_i2v.json (official workflow-templates)
|
|
3
|
+
// needs COMFY_CLOUD_API_KEY (https://cloud.comfy.org, paid tiers)
|
|
4
|
+
// run directly: bun examples/comfy-cloud/hunyuan-video-i2v.cflow.ts [path/to/image.png] ["prompt"]
|
|
5
|
+
import { asAbsolutePath, exampleImagePath, MediaImage, v } from 'comfy-ts'
|
|
6
|
+
import { cloudHost, requireCloudKey } from './cloudHost.ts'
|
|
7
|
+
|
|
8
|
+
const host = await cloudHost()
|
|
9
|
+
|
|
10
|
+
// bundled default input (examples/images/, ships in the tarball) — the TUI picker or argv[2] swap it
|
|
11
|
+
const image = v.image(exampleImagePath('walrus_1344x768.jpg'))
|
|
12
|
+
|
|
13
|
+
export const hunyuanVideoI2v = host.defineWorkflow({
|
|
14
|
+
id: 'hunyuan-video-i2v',
|
|
15
|
+
vars: {
|
|
16
|
+
image,
|
|
17
|
+
// ONE prompt var: `- ` lines are the NEGATIVE prompt, `//` lines are comments
|
|
18
|
+
prompt: v.prompt(
|
|
19
|
+
'A feathered young dinosaur with ruffled brown and white plumage moves alertly through a sun-dappled coniferous forest, sunbeams filtering through the tall canopy over mossy undergrowth and ferns, soft glowing mist, dappled light dancing across its textured feathers, lush ancient wilderness, lifelike detail',
|
|
20
|
+
),
|
|
21
|
+
seed: v.seed(42),
|
|
22
|
+
steps: v.int(20, { min: 1, max: 60 }),
|
|
23
|
+
cfg: v.float(6, { min: 0, max: 30 }),
|
|
24
|
+
length: v.int(121, { min: 1, max: 241 }),
|
|
25
|
+
fps: v.int(24, { min: 1, max: 60 }),
|
|
26
|
+
},
|
|
27
|
+
// async build: the input image is uploaded (hash-named, deduped) per run
|
|
28
|
+
build: async (b, vars, wf) => {
|
|
29
|
+
const img = new MediaImage({ path: asAbsolutePath(image.absPath()) })
|
|
30
|
+
const loaded = await img.loadInWorkflow_viaLoadImageNode(wf)
|
|
31
|
+
|
|
32
|
+
const model = b.ModelSamplingSD3({
|
|
33
|
+
model: b.UNETLoader({ unet_name: 'hunyuanvideo1.5_720p_i2v_fp16.safetensors', weight_dtype: 'default' }),
|
|
34
|
+
shift: 7,
|
|
35
|
+
})
|
|
36
|
+
const clip = b.DualCLIPLoader({
|
|
37
|
+
clip_name1: 'qwen_2.5_vl_7b_fp8_scaled.safetensors',
|
|
38
|
+
clip_name2: 'byt5_small_glyphxl_fp16.safetensors',
|
|
39
|
+
type: 'hunyuan_video_15',
|
|
40
|
+
device: 'default',
|
|
41
|
+
})
|
|
42
|
+
const vae = b.VAELoader({ vae_name: 'hunyuanvideo15_vae_fp16.safetensors' })
|
|
43
|
+
|
|
44
|
+
// the start image feeds both the packaged conditioning+latent and a clip vision pass
|
|
45
|
+
const video = b.HunyuanVideo15ImageToVideo({
|
|
46
|
+
positive: b.CLIPTextEncode({ clip, text: vars.prompt.positive }),
|
|
47
|
+
negative: b.CLIPTextEncode({ clip, text: vars.prompt.negative }),
|
|
48
|
+
vae,
|
|
49
|
+
start_image: loaded,
|
|
50
|
+
clip_vision_output: b.CLIPVisionEncode({
|
|
51
|
+
clip_vision: b.CLIPVisionLoader({ clip_name: 'sigclip_vision_patch14_384.safetensors' }),
|
|
52
|
+
image: loaded,
|
|
53
|
+
crop: 'center',
|
|
54
|
+
}),
|
|
55
|
+
width: 1280,
|
|
56
|
+
height: 720,
|
|
57
|
+
length: vars.length,
|
|
58
|
+
batch_size: 1,
|
|
59
|
+
})
|
|
60
|
+
// template's SamplerCustomAdvanced pipeline collapsed to KSampler (euler/simple/cfg survive)
|
|
61
|
+
const samples = b.KSampler({
|
|
62
|
+
model,
|
|
63
|
+
positive: video.outputs.positive,
|
|
64
|
+
negative: video.outputs.negative,
|
|
65
|
+
latent_image: video.outputs.latent,
|
|
66
|
+
seed: vars.seed,
|
|
67
|
+
steps: vars.steps,
|
|
68
|
+
cfg: vars.cfg,
|
|
69
|
+
sampler_name: 'euler',
|
|
70
|
+
scheduler: 'simple',
|
|
71
|
+
denoise: 1,
|
|
72
|
+
})
|
|
73
|
+
b.SaveVideo({
|
|
74
|
+
video: b.CreateVideo({ images: b.VAEDecode({ samples, vae }), fps: vars.fps }),
|
|
75
|
+
filename_prefix: 'comfy-ts-zoo/hunyuan-video-i2v',
|
|
76
|
+
format: 'mp4',
|
|
77
|
+
codec: 'h264',
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export default hunyuanVideoI2v
|
|
83
|
+
|
|
84
|
+
// standalone run (skipped when another driver — e.g. the TUI — imports this module)
|
|
85
|
+
if (import.meta.main) {
|
|
86
|
+
requireCloudKey()
|
|
87
|
+
if (process.argv[2]) hunyuanVideoI2v.vars.image.set(process.argv[2])
|
|
88
|
+
if (process.argv[3]) hunyuanVideoI2v.vars.prompt.set(process.argv[3])
|
|
89
|
+
const execution = await hunyuanVideoI2v.run({ log: true })
|
|
90
|
+
// SaveVideo outputs land host side (no auto-download for video yet)
|
|
91
|
+
console.log(`🟢 ${execution.status}: video saved on the host under comfy-ts-zoo/hunyuan-video-i2v`)
|
|
92
|
+
host.disconnect()
|
|
93
|
+
}
|