The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Restore 2: Fuobe Restore on both engines, the tiled-fusion graph and the window plan
Claude4aba5a051ff0
diff --git a/docs/research/fuobe-originals-recipes-5.json b/docs/research/fuobe-originals-recipes-5.jsonindex 681a1165..b9b1dfaa 100644--- a/docs/research/fuobe-originals-recipes-5.json+++ b/docs/research/fuobe-originals-recipes-5.json@@ -19264,7 +19264,10 @@"stage2": "none: the Detail Refine IC-LoRA is an LTX-2.5 LoRA and no host serves LTX-2.5 with LoRAs (open engine only)","lora": "the Restore IC-LoRA's mirror on fal storage (Fuobe downloads the gated file once with the user's HF token)","unverified": "whether fal's IC-LoRA path treats a custom IC-LoRA exactly as the card's reference guide (no live call made); ic_lora_type none keeps fal's own union/detailer IC-LoRA out",- "steps": "the endpoint's own (40, acceleration regular): fal runs LTX-2.3 22B dev with its distill LoRA, not the 2.5 distilled transformer the card's 8 steps are for"+ "steps": "the endpoint's own (40, acceleration regular): fal runs LTX-2.3 22B dev with its distill LoRA, not the 2.5 distilled transformer the card's 8 steps are for",+ "defaults": {+ "negative_prompt": "modern cars, modern buildings, shipping containers, mobile phones, logos, signage, lettering, graffiti, satellite dishes, plastic furniture, blocky compression, banding, mosquito noise, ringing, blurry, smeared, ghosting, low resolution"+ }},"licence": {"weights": "LTX-2.x Community License (free under US$10M annual revenue)",diff --git a/scripts/comfy/build-library.mjs b/scripts/comfy/build-library.mjsindex 00a45559..8008ae31 100644--- a/scripts/comfy/build-library.mjs+++ b/scripts/comfy/build-library.mjs@@ -67,6 +67,8 @@ export const LOADER_FOLDERS = {// comfyui-oss-4 additionsOpticalFlowLoader: { model_name: 'optical_flow' },LoadMoGeModel: { model_name: 'geometry_estimation' },+ // archive-restore: Lightricks' IC-LoRA loader (ComfyUI-LTXVideo)+ LTXICLoRALoaderModelOnly: { lora_name: 'loras' },};// Nodes that fetch their own weights at runtime (no manual download needed; listed in the entry's autoDownloads).const SELF_DOWNLOADING = new Set(['RIFE VFI', 'DownloadAndLoadWav2VecModel', 'RMBG', 'AILab_Qwen3ASRSubtitle', 'Apply Whisper', 'ClothesSegment', 'LatentSyncNode']);@@ -94,6 +96,8 @@ const NUMERIC_DEFAULT_KEYS = ['megapixels',// Originals O11'motionFrame', 'audioCfg', 'threshold', 'mosaicScale',+ // archive-restore+ 'windowStart', 'windowFrames', 'prefixFrames', 'canvasWidth', 'canvasHeight', 'tileWidth', 'tileHeight', 'tileFrames',];export const BINDING_KEYS = new Set(['prompt', 'negativePrompt', 'image', 'image2', 'image3', 'image4', 'mask', 'endImage', 'video', 'audio',@@ -134,6 +138,8 @@ export const BINDING_KEYS = new Set(['separationModel', 'channels',// MOSS-Image (docs/research/new-models-7.md §4.6): the KSampler's sampler and the UNET file its Quality / Fast settings pick'sampler', 'unet',+ // archive-restore (Restore & colourise): the window, the canvas, the prefix hand-off, deinterlacing and the fusion tiles+ 'windowStart', 'canvasWidth', 'canvasHeight', 'fieldWidth', 'fieldHeight', 'prefixFrom', 'prefixFrames', 'tileWidth', 'tileHeight', 'streaming', 'tileFrames',]);// Sizes in GB: two decimals, and three where two would read 0 (a 4 MB DBS model), so no other entry's size changes.@@ -354,7 +360,7 @@ async function main() {const size = await hfSize(known.url, sizeCache);if (size && typeof size === 'object' && size.error) errs.push(`model ${file}: ${known.url} -> ${size.error}`);const bytes = typeof size === 'number' ? size : size?.size;- models.set(file, { file, folder: known.folder, url: known.url, sizeGb: bytes ? gb(bytes) : null, ...(optional && { optional: true }) });+ models.set(file, { file, folder: known.folder, url: known.url, sizeGb: bytes ? gb(bytes) : null, ...(size?.gated && { gated: true }), ...(optional && { optional: true }) });}// ---- custom nodesdiff --git a/scripts/comfy/hand-built/video-restore-ltx25-tiled.json b/scripts/comfy/hand-built/video-restore-ltx25-tiled.jsonnew file mode 100644index 00000000..444e8bb3--- /dev/null+++ b/scripts/comfy/hand-built/video-restore-ltx25-tiled.json@@ -0,0 +1,429 @@+{+ "source": {+ "class_type": "VHS_LoadVideo",+ "inputs": {+ "video": "archive.mp4",+ "force_rate": 0,+ "custom_width": 0,+ "custom_height": 0,+ "frame_load_cap": 97,+ "skip_first_frames": 0,+ "select_every_nth": 1,+ "format": "None"+ },+ "_meta": {+ "title": "the window: frame_load_cap frames from skip_first_frames, at the clip's own rate (no resample, no 8n+1 cut: the plan's windows are 8n+1)"+ }+ },+ "field": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "source",+ 0+ ],+ "upscale_method": "nearest-exact",+ "width": 640,+ "height": 240,+ "crop": "disabled"+ },+ "_meta": {+ "title": "deinterlace (optional): one field, every other row (nearest, no blending); the canvas resize rebuilds the height. The provider removes it when off"+ }+ },+ "canvas": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "field",+ 0+ ],+ "upscale_method": "lanczos",+ "width": 1440,+ "height": 1088,+ "crop": "disabled"+ },+ "_meta": {+ "title": "lanczos to the working canvas (1440 wide for 4:3, 1920x1088 for 16:9; the shape kept, multiples of 32): the guide never sees the small scan"+ }+ },+ "unet": {+ "class_type": "UNETLoader",+ "inputs": {+ "unet_name": "ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",+ "weight_dtype": "default"+ },+ "_meta": {+ "title": "LTX-2.5 22B distilled"+ }+ },+ "lora": {+ "class_type": "LTXICLoRALoaderModelOnly",+ "inputs": {+ "model": [+ "unet",+ 0+ ],+ "lora_name": "ltx-2.5-22b-ic-lora-restore-1.0.safetensors",+ "strength_model": 1.0+ },+ "_meta": {+ "title": "the Restore IC-LoRA at 1.0 (a switch: 0.7 stays monochrome, 1.4 over-tints); the Detail Refine IC-LoRA for stage 2. Its latent_downscale_factor (1) feeds the guides"+ }+ },+ "vae": {+ "class_type": "VAELoader",+ "inputs": {+ "vae_name": "ltx-2.5-video-vae-bf16.safetensors"+ },+ "_meta": {+ "title": "LTX-2.5 video VAE"+ }+ },+ "text": {+ "class_type": "CLIPLoader",+ "inputs": {+ "clip_name": "gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors",+ "type": "ltxv",+ "device": "default"+ },+ "_meta": {+ "title": "Gemma 4 12B text encoder"+ }+ },+ "positive": {+ "class_type": "CLIPTextEncode",+ "inputs": {+ "text": "a steam locomotive arriving at a small rural railway station in 1896, passengers in period coats and hats waiting on the platform, wooden station buildings, natural colour",+ "clip": [+ "text",+ 0+ ]+ },+ "_meta": {+ "title": "period, place, light, materials, clothing, natural colour"+ }+ },+ "negative": {+ "class_type": "CLIPTextEncode",+ "inputs": {+ "text": "modern cars, modern buildings, shipping containers, logos, signage, lettering, graffiti, blocky compression, banding, mosquito noise, ringing, blurry, smeared, ghosting, low resolution",+ "clip": [+ "text",+ 0+ ]+ },+ "_meta": {+ "title": "what it must not invent, and the damage"+ }+ },+ "conditioning": {+ "class_type": "LTXVConditioning",+ "inputs": {+ "positive": [+ "positive",+ 0+ ],+ "negative": [+ "negative",+ 0+ ],+ "frame_rate": 24.0+ },+ "_meta": {+ "title": "the clip's own frame rate"+ }+ },+ "empty": {+ "class_type": "EmptyLTXVLatentVideo",+ "inputs": {+ "width": 1440,+ "height": 1088,+ "length": 97,+ "batch_size": 1+ },+ "_meta": {+ "title": "the canvas, the window's frames (8n+1)"+ }+ },+ "guide": {+ "class_type": "LTXAddVideoICLoRAGuide",+ "inputs": {+ "positive": [+ "conditioning",+ 0+ ],+ "negative": [+ "conditioning",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "empty",+ 0+ ],+ "image": [+ "canvas",+ 0+ ],+ "frame_idx": 0,+ "strength": 1.0,+ "latent_downscale_factor": [+ "lora",+ 1+ ],+ "crop": "disabled",+ "use_tiled_encode": false,+ "tile_size": 256,+ "tile_overlap": 64,+ "use_streaming": false,+ "tile_frames": 97+ },+ "_meta": {+ "title": "the archive clip as the frame-aligned IC-LoRA reference (downscale 1, untiled encode); use_streaming only for a whole clip past 97 frames"+ }+ },+ "prefix_source": {+ "class_type": "VHS_LoadVideo",+ "inputs": {+ "video": "previous_window.mp4",+ "force_rate": 0,+ "custom_width": 0,+ "custom_height": 0,+ "frame_load_cap": 17,+ "skip_first_frames": 80,+ "select_every_nth": 1,+ "format": "None"+ },+ "_meta": {+ "title": "the window before's last 17 restored frames (prefix hand-off); the provider removes this branch on the first window"+ }+ },+ "prefix": {+ "class_type": "LTXVAddGuide",+ "inputs": {+ "positive": [+ "guide",+ 0+ ],+ "negative": [+ "guide",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "guide",+ 2+ ],+ "image": [+ "prefix_source",+ 0+ ],+ "frame_idx": 0,+ "strength": 1.0+ },+ "_meta": {+ "title": "prefix at frame 0: the model continues from the restored frames, so colour holds across windows"+ }+ },+ "reference": {+ "class_type": "LoadImage",+ "inputs": {+ "image": "reference.png"+ },+ "_meta": {+ "title": "reference picture (optional): native crops of faces, signs or true colours on grey, or a colour photo framed like the clip"+ }+ },+ "reference_fit": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "reference",+ 0+ ],+ "upscale_method": "lanczos",+ "width": 1440,+ "height": 1088,+ "crop": "center"+ },+ "_meta": {+ "title": "the reference on the canvas (it is cropped per tile like the clip)"+ }+ },+ "reference_guide": {+ "class_type": "LTXAddVideoICLoRAGuide",+ "inputs": {+ "positive": [+ "prefix",+ 0+ ],+ "negative": [+ "prefix",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "prefix",+ 2+ ],+ "image": [+ "reference_fit",+ 0+ ],+ "frame_idx": -1,+ "strength": 1.0,+ "latent_downscale_factor": [+ "lora",+ 1+ ],+ "crop": "disabled",+ "use_tiled_encode": false,+ "tile_size": 256,+ "tile_overlap": 64,+ "use_streaming": false,+ "tile_frames": 97+ },+ "_meta": {+ "title": "a second IC-LoRA guide at frame_idx -1 (before the clip, not in its first slot); the provider removes this branch without a reference"+ }+ },+ "sigmas": {+ "class_type": "ManualSigmas",+ "inputs": {+ "sigmas": "1.0, 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0"+ },+ "_meta": {+ "title": "the card's 8 distilled steps"+ }+ },+ "sampler_select": {+ "class_type": "KSamplerSelect",+ "inputs": {+ "sampler_name": "euler"+ },+ "_meta": {+ "title": "euler (fusion owns the sigma loop)"+ }+ },+ "sample": {+ "class_type": "LTXVTiledFusionSampler",+ "inputs": {+ "model": [+ "lora",+ 0+ ],+ "positive": [+ "reference_guide",+ 0+ ],+ "negative": [+ "reference_guide",+ 1+ ],+ "latents": [+ "reference_guide",+ 2+ ],+ "sigmas": [+ "sigmas",+ 0+ ],+ "sampler": [+ "sampler_select",+ 0+ ],+ "seed": 42,+ "cfg": 1.0,+ "tile_width": 960,+ "tile_height": 544,+ "overlap_frac": 0.5,+ "blend_var": 0.05,+ "grid_cycle": 1,+ "tile_frames": 0,+ "vae": [+ "vae",+ 0+ ],+ "canvas_device": "auto"+ },+ "_meta": {+ "title": "per-step tiled latent fusion: 960x544 tiles at 50% overlap (1024x576 for stage 2), guidance 1.0; tile_frames 97 only with a streaming guide"+ }+ },+ "decode": {+ "class_type": "VAEDecodeTiled",+ "inputs": {+ "samples": [+ "sample",+ 0+ ],+ "vae": [+ "vae",+ 0+ ],+ "tile_size": 512,+ "overlap": 64,+ "temporal_size": 64,+ "temporal_overlap": 8+ },+ "_meta": {+ "title": "tiled decode"+ }+ },+ "keep": {+ "class_type": "ImageFromBatch",+ "inputs": {+ "image": [+ "decode",+ 0+ ],+ "batch_index": 0,+ "length": 4096+ },+ "_meta": {+ "title": "the window's own frames: from prefixFrames on (the prefix the window before already made is dropped)"+ }+ },+ "video": {+ "class_type": "CreateVideo",+ "inputs": {+ "images": [+ "keep",+ 0+ ],+ "fps": 24.0,+ "bit_depth": "auto",+ "color_space": "sRGB",+ "codec": "none"+ },+ "_meta": {+ "title": "silent: the pipeline puts the clip's own sound back after the join"+ }+ },+ "save": {+ "class_type": "SaveVideo",+ "inputs": {+ "video": [+ "video",+ 0+ ],+ "filename_prefix": "fuobe/video-restore-ltx25-tiled",+ "format": "auto",+ "format.codec": "auto",+ "codec": "auto"+ },+ "_meta": {+ "title": "SaveVideo"+ }+ }+}diff --git a/scripts/comfy/library.spec.mjs b/scripts/comfy/library.spec.mjsindex 4b3e77d7..f47fe30d 100644--- a/scripts/comfy/library.spec.mjs+++ b/scripts/comfy/library.spec.mjs@@ -152,6 +152,8 @@ export const CUSTOM_NODE_REPOS = {'h3-relay': 'https://github.com/akatz-ai/h3-relay/tree/e2a7665b6eb8ea37a88c0de2c9c6b69a8f7c9220',// DBS soundtrack separation (docs/research/dbs-separation-7.md §4): pinned in install-comfyui.sh, not on the validation server.'ComfyUI-DBS': 'https://github.com/hiroki-abe-58/ComfyUI-DBS/tree/f656e53434b5485c148a2866fbd6ddc6b6152ed6',+ // Restore & colourise (package archive-restore): Lightricks' LTX nodes, pinned in install-comfyui.sh, not on the validation server.+ 'ComfyUI-LTXVideo': 'https://github.com/Lightricks/ComfyUI-LTXVideo/tree/220e1d45aa0469f518e982102fca4dca92a61862',};// Node classes of the packs entries list in `packs` (packs the validation server doesn't have installed): the build@@ -160,11 +162,14 @@ export const PACK_CLASSES = {h3_character_swap: /^H3CharacterSwap/,'h3-relay': /^(H3Relay|LabsH3)/,'ComfyUI-DBS': /^DBS(Loader|Separate)$/,+ 'ComfyUI-LTXVideo': /^(LTXICLoRALoaderModelOnly|LTXAddVideoICLoRAGuide|LTXVTiledFusionSampler)$/,};// Model download locations for files that the source workflow does not annotate// (UI templates usually carry node.properties.models; custom-node examples do not).export const KNOWN_MODELS = {+ // archive-restore: Lightricks' Detail Refine IC-LoRA (stage 2 of Restore & colourise), gated, at the researched commit.+ 'ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors': { folder: 'loras', url: 'https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Refine-Details/resolve/4912c478b35dd96b6cdcc5f7c7ff9d72c2c57929/ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors' },'ltx-2.3-22b-distilled-fp8.safetensors': { folder: 'checkpoints', url: 'https://huggingface.co/Lightricks/LTX-2.3-fp8/resolve/main/ltx-2.3-22b-distilled-fp8.safetensors' },'gemma_3_12B_it_fp4_mixed.safetensors': { folder: 'text_encoders', url: 'https://huggingface.co/Comfy-Org/ltx-2/resolve/main/split_files/text_encoders/gemma_3_12B_it_fp4_mixed.safetensors' },'RealESRGAN_x4plus.safetensors': { folder: 'upscale_models', url: 'https://huggingface.co/Comfy-Org/Real-ESRGAN_repackaged/resolve/main/RealESRGAN_x4plus.safetensors' },@@ -2228,6 +2233,57 @@ export const SPEC = ['Not used by a catalog model yet (build plan O4 lists it for LTX camera LoRAs without a start frame).',},+ // ---- Restore & colourise (package archive-restore): Lightricks' Restore IC-LoRA, tiled latent fusion --------------+ {+ id: 'video-restore-ltx25-tiled',+ title: 'Restore & colourise archive footage: LTX-2.5 22B distilled + the Restore IC-LoRA, tiled latent fusion, one 97-frame window with the 17-frame prefix hand-off (stage 2: the Detail Refine IC-LoRA) (ComfyUI-LTXVideo pack)',+ capability: 'restore-video',+ handBuilt: 'hand-built/video-restore-ltx25-tiled.json',+ packs: ['ComfyUI-LTXVideo'],+ modelUrls: {+ // The LTX-2.5 files ltx25-i2v / ltx25-t2v load (their template's links), and the Restore IC-LoRA at the researched commit.+ 'ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors': 'https://huggingface.co/Lightricks/LTX-2.5/resolve/main/diffusion_models/ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors',+ 'ltx-2.5-video-vae-bf16.safetensors': 'https://huggingface.co/Lightricks/LTX-2.5/resolve/main/vae/ltx-2.5-video-vae-bf16.safetensors',+ 'gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors': 'https://huggingface.co/Lightricks/LTX-2.5/resolve/main/text_encoders/gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors',+ 'ltx-2.5-22b-ic-lora-restore-1.0.safetensors': 'https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Restore/resolve/79245e197a6cd3251e77d178dc380b0e9f2d6563/ltx-2.5-22b-ic-lora-restore-1.0.safetensors',+ },+ optionalModels: ['ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors'],+ bindings: {+ video: [b('source', 'video')], video2: [b('prefix_source', 'video')], image: [b('reference', 'image')],+ prompt: [b('positive', 'text')], negativePrompt: [b('negative', 'text')], seed: [b('sample', 'seed')], cfg: [b('sample', 'cfg')],+ fps: [b('conditioning', 'frame_rate'), b('video', 'fps')],+ windowStart: [b('source', 'skip_first_frames')], windowFrames: [b('source', 'frame_load_cap'), b('empty', 'length')],+ canvasWidth: [b('canvas', 'width'), b('empty', 'width'), b('reference_fit', 'width')],+ canvasHeight: [b('canvas', 'height'), b('empty', 'height'), b('reference_fit', 'height')],+ fieldWidth: [b('field', 'width')], fieldHeight: [b('field', 'height')],+ prefixFrom: [b('prefix_source', 'skip_first_frames')], prefixFrames: [b('keep', 'batch_index')],+ lora: [b('lora', 'lora_name')], loraStrength: [b('lora', 'strength_model')],+ tileWidth: [b('sample', 'tile_width')], tileHeight: [b('sample', 'tile_height')],+ streaming: [b('guide', 'use_streaming')], tileFrames: [b('sample', 'tile_frames')],+ filenamePrefix: [b('save', 'filename_prefix')],+ },+ outputs: [{ node: 'save', kind: 'video' }],+ defaults: {+ lora: 'ltx-2.5-22b-ic-lora-restore-1.0.safetensors', windowStart: 0, windowFrames: 97, prefixFrames: 0, prefixFrom: 80, canvasWidth: 1440, canvasHeight: 1088,+ fieldWidth: 640, fieldHeight: 240, tileWidth: 960, tileHeight: 544, streaming: false, tileFrames: 0,+ },+ limits: { maxWidth: 3840, maxHeight: 3840, maxFrames: 481, dimensionMultiple: 32, frameStep: 8 },+ vramGb: 24,+ license:+ 'LTX-2.x Community License (LTX-2.5 22B distilled, its video VAE, and Lightricks\' Restore and Detail Refine IC-LoRAs, both gated on Hugging Face: free under US$10M annual revenue); ' ++ 'Gemma 4 text encoder packaged by Lightricks; ComfyUI-LTXVideo nodes under the LTX-2 Community License (its LICENSE file)',+ notes:+ 'Built from the Restore IC-LoRA card\'s recipe (Hugging Face Lightricks/LTX-2.5-22b-IC-LoRA-Restore at 79245e1, read as data) and the node definitions of ComfyUI-LTXVideo at 220e1d4 ' ++ '(its LTX-2.5_V2V_TiledFusion_Upscale example wires the same nodes): the window (windowStart, windowFrames: 8n+1, at most 97) read at the clip\'s own rate, lanczos to the canvas ' ++ '(canvasWidth x canvasHeight: 1440x1088 for 4:3, 1920x1088 for 16:9), the frame-aligned IC-LoRA guide at downscale 1, LTXVTiledFusionSampler with 960x544 tiles at 50% overlap ' ++ 'and the 8 distilled sigmas (euler, cfg 1), tiled decode, silent H.264 (the pipeline puts the sound back after the join). ' ++ 'video2 = the window before\'s saved frames; its last 17 (prefixFrom) go in as LTXVAddGuide at frame 0, and prefixFrames (17) drops them from this window\'s output; absent on the ' ++ 'first window (the provider removes that branch). image = an optional reference picture at frame_idx -1 (a second IC-LoRA guide; removed without one). deinterlace keeps one field ' ++ '(fieldWidth x fieldHeight, nearest rows: no blending; ComfyUI has no fieldmatch/yadif/decimate node), removed when off. Stage 2 (Restore to 4K): the same graph on the restored clip ' ++ 'with the Detail Refine IC-LoRA, a 2x canvas and 1024x576 tiles. A single generation of a whole clip past 97 frames streams: streaming on the guide and tileFrames 97 on the sampler ' ++ '(the card\'s other long-clip path; no reference picture there). Needs the ComfyUI-LTXVideo pack. Not validated here: the pack is not installed on this server.',+ },+// ---- Shorts Studio / Mixed Media: trim, segment, restyle ------------------------{id: 'video-trim',diff --git a/scripts/comfy/validation-state.json b/scripts/comfy/validation-state.jsonindex 478c0b26..cf8fb20c 100644--- a/scripts/comfy/validation-state.json+++ b/scripts/comfy/validation-state.json@@ -791,6 +791,12 @@"error": null,"at": "2026-10-16T23:33:15.433Z"},+ "video-restore-ltx25-tiled": {+ "sha256": "5da276f2353f7394c408dee24bf62110f74061efde401a9ba5741f85aa6d7c85",+ "validated": false,+ "error": "HTTP 400: missing_node_type: Node 'the archive clip as the frame-aligned IC-LoRA reference (downscale 1, untiled encode); use_streaming only for a whole clip past 97 frames' not found. The custom node may not be installed. (Node ID '#guide')",+ "at": "2026-10-30T14:25:45.648Z"+ },"video-restyle-wan22-fun-vace": {"sha256": "e11ef47ba766cc4ce8bda70c6e16b6c4736a683b88f8cf86e6c569e56eaed1c6","validated": true,diff --git a/scripts/gen-cloud-models.py b/scripts/gen-cloud-models.pyindex f65d136a..2272b2ff 100644--- a/scripts/gen-cloud-models.py+++ b/scripts/gen-cloud-models.py@@ -704,7 +704,7 @@ RESTORE_MP = per_megapixel(RESTORE_O["endpoint"])RESTORE_PER_SECOND = {t: round(s["4:3"][0] * s["4:3"][1] * 24 / 1e6 * RESTORE_MP, 4) for t, s in CINEMA_SIZES.items() if t != "480p"}model("fuobe-restore", "Fuobe Restore", "Fuobe Original", "fuobe-restore", "video","Restore and colourise archive footage: Lightricks' Restore IC-LoRA on LTX-2.3, one untiled pass a piece",- [("restore-video", RESTORE_O["endpoint"], "fal", {"fixed": RESTORE_O["fixed"]})],+ [("restore-video", RESTORE_O["endpoint"], "fal", {"fixed": RESTORE_O["fixed"], "defaults": RESTORE_O["defaults"]})],original=True, sizes={t: s for t, s in CINEMA_SIZES.items() if t != "480p"},pricing=("second", RESTORE_PER_SECOND["720p"],f"${RESTORE_MP} per megapixel of video (width × height × frames): about ${round(RESTORE_PER_SECOND['720p'] * 4, 2)} for 4 s of a 4:3 clip at 720p",diff --git a/src/lib/catalog/cloud-models.generated.ts b/src/lib/catalog/cloud-models.generated.tsindex 197f4bba..6b46f038 100644--- a/src/lib/catalog/cloud-models.generated.ts+++ b/src/lib/catalog/cloud-models.generated.ts@@ -19781,6 +19781,9 @@ export const ORIGINAL_CLOUD: ModelDef[] = ["match_video_length": true,"match_input_fps": true},+ "defaults": {+ "negative_prompt": "modern cars, modern buildings, shipping containers, mobile phones, logos, signage, lettering, graffiti, satellite dishes, plastic furniture, blocky compression, banding, mosquito noise, ringing, blurry, smeared, ghosting, low resolution"+ },"loras": {"shape": "items","key": "loras",diff --git a/src/lib/catalog/models.ts b/src/lib/catalog/models.tsindex 31b72ecb..48d01881 100644--- a/src/lib/catalog/models.ts+++ b/src/lib/catalog/models.ts@@ -5,6 +5,7 @@ import { ASR_LANGUAGES, WHISPER_LANGUAGES } from "../speech-languages";import { loraEntry, loraRef } from "./loras";import { ANGLES_LORA, MOSAIC_SCALE, MOSAIC_TARGET, SPEAK_GRAPH, SPEAK_LORA, SPEAK_PROMPT } from "./open-tools";import { CINEMA_CROP, SOUL_ASPECTS, SOUL_TIERS } from "./soul";+import { RESTORE, offlineRestorePrompt } from "./restore";import { CLOUD_SHAPES, denoiseFor, EVOLUTION, EVOLUTION_DEFAULT_RESOLUTION, EVOLUTION_RESOLUTIONS, INTENSITIES, videoStrengthFor, type Intensity } from "./evolution";import { LAST_FRAME_CHAIN, type ModelDef, type ModelOptions, type ModelRoute, type Operation } from "./types";@@ -47,6 +48,11 @@ const VIDEO_UPSCALE_TIERS = ["720p", "1080p", "1440p", "2160p"];// ---------------------------------------------------------------------------// Open source · ComfyUI+/** Fuobe Restore's LoRA in the cloud (research adapterLoras): Lightricks' Restore IC-LoRA, gated, sent as Fuobe's mirror. */+const RESTORE_LORA = (() => {+ const e = loraEntry("ltx-2-5-22b-ic-lora-restore-1-0");+ return e ? loraRef(e) : undefined;+})();/** Fuobe Try-On's LoRA (research adapterLoras): xocialize's try-on LoRA for FLUX.2 [klein] 4B, Apache-2.0. */const TRYON_LORA = loraEntry("tryon-klein-4b");/** The try-on LoRA card's own instruction, for a run with no words. */@@ -1937,6 +1943,36 @@ const originals: ModelDef[] = [engineDefaults: { open: { aspectRatio: "9:16" } },engineOptions: { open: { aspectRatios: VID_AR, resolutions: ["480p", "720p"] } },},+ // Fuobe Restore (package archive-restore): Restore & colourise archive footage with Lightricks' Restore IC-LoRA. On your GPU+ // LTX-2.5 22B distilled with per-step tiled fusion (src/lib/restore-graph.ts: a whole clip in one pass up to 20 s; Video+ // tools → Restore runs any clip in chained 97-frame windows, src/lib/catalog/restore.ts); in the cloud fal's LTX-2.3 22B+ // reference video to video with the same LoRA by Fuobe's mirror, one untiled pass. The GPU graph loads its LoRA itself.+ {+ ...original({+ id: RESTORE.model,+ open: [comfy("restore-video", RESTORE.workflow, "LTX-2.5 22B distilled + the Restore IC-LoRA, 960x544 tiles fused every step, 8 steps; stage 2 the Detail Refine IC-LoRA")],+ tagline:+ "Old, faded or black-and-white footage back in colour and sharp · Lightricks' Restore IC-LoRA on LTX-2.5, free on your GPU (24 GB class), or on LTX-2.3 hosted on fal",+ options: {+ promptOptional: true,+ defaultPrompt: offlineRestorePrompt().prompt,+ negativePrompt: true,+ seed: true,+ maxImages: 1,+ imageLabels: ["reference picture: true colours, a face or a sign (optional)"],+ },+ }),+ // The cloud renders at a tier's size for the clip's shape, and its image is the first frame (already in colour).+ engineDefaults: { cloud: { aspectRatio: "4:3", resolution: RESTORE.cloudResolution } },+ engineOptions: {+ cloud: {+ aspectRatios: ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"],+ resolutions: [...RESTORE.cloudResolutions],+ imageLabels: ["first frame, already in colour (optional)"],+ ...(RESTORE_LORA && { loras: [RESTORE_LORA] }),+ },+ },+ },];/**diff --git a/src/lib/catalog/plan.ts b/src/lib/catalog/plan.tsindex 954e7cf3..0f435124 100644--- a/src/lib/catalog/plan.ts+++ b/src/lib/catalog/plan.ts@@ -629,7 +629,7 @@ export function pricingAt(p: Pricing, now = Date.now()): Pricing {* price counts the clip's seconds (params.sourceDuration) when the caller knows them, and slow motion bills* the whole stretched result.*/-const CLIP_LENGTH_OPS = new Set<Operation>(["upscale-video", "interpolate", "sdr-to-hdr", "export-video"]);+const CLIP_LENGTH_OPS = new Set<Operation>(["upscale-video", "interpolate", "sdr-to-hdr", "export-video", "restore-video"]);/*** The seconds a clip edit that keeps the clip's length is billed for (Happy Horse, Runway Aleph, Lucy Edit, Kling O3 4Kdiff --git a/src/lib/catalog/restore.ts b/src/lib/catalog/restore.tsnew file mode 100644index 00000000..d2a862c6--- /dev/null+++ b/src/lib/catalog/restore.ts@@ -0,0 +1,581 @@+/**+ * Fuobe Restore (package archive-restore): Restore & colourise archive footage with Lightricks' Restore IC-LoRA, the+ * owner's request of 2026-10-29. The recipe is the model card's (Hugging Face Lightricks/LTX-2.5-22b-IC-LoRA-Restore,+ * read as data; research studios[archive-restore] in docs/research/fuobe-originals-recipes-5.json):+ *+ * - On your GPU: the clip lanczos-resized to the working canvas (1440 wide for 4:3, 1920x1088 for 16:9, multiples of 32,+ * the shape kept), the frame-aligned reference of the IC-LoRA at 1.0 on LTX-2.5 22B distilled, per-step tiled latent+ * fusion with 960x544 tiles at 50% overlap (at every size), 8 distilled steps (euler, guidance 1.0). Clips past 97+ * frames run as 97-frame windows, each starting from the previous window's last 17 restored frames (the card's prefix+ * hand-off: colour stays consistent). An optional reference picture at frame_idx -1 (true colours, faces, signs);+ * deinterlacing first for interlaced sources. Stage 2 (optional, "Restore to 4K"): lanczos x2 and the Detail Refine+ * IC-LoRA with 1024x576 tiles, restore first, refine second.+ * - In the cloud (only because fal hosts the base model with IC-LoRAs): LTX-2.3 22B reference video to video with the+ * Restore LoRA by Fuobe's mirror URL, one untiled pass a piece at the tier's size for the clip's shape, pieces of up+ * to 97 frames, each after the first starting from the previous piece's last restored frame (fal's first-frame input).+ * No stage 2 there: the Detail Refine LoRA is an LTX-2.5 LoRA and nobody hosts LTX-2.5 with LoRAs.+ * - Then the pieces are joined and the clip's own sound put back.+ *+ * Pure module, shared by the page, the server (src/server/restore.ts), the ComfyUI provider and the tests.+ */+import { frameWindows, planFrameCuts, REMOVE_TOOLS, wholeClip, type FrameWindow } from "./remove-object";+import { joinGroups, type PlanStep } from "./shorts";+import type { ChainSlot, Engine, GenerationRequest } from "./types";++export const RESTORE = {+ model: "fuobe-restore",+ feature: "restore",+ /** Windows, cut pieces, hand-off frames and joins: kept apart from the finished videos. */+ stepFeature: "restore-step",+ /** The open graph (stage 1 and, with the Detail Refine LoRA, stage 2). */+ workflow: "video-restore-ltx25-tiled",+ /** The two IC-LoRAs (research adapterLoras), both gated on Hugging Face. */+ loras: {+ restore: { key: "ltx-2-5-22b-ic-lora-restore-1-0", file: "ltx-2.5-22b-ic-lora-restore-1.0.safetensors", page: "https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Restore", sizeGb: 1.71 },+ refine: { key: "ltx-2-5-22b-ic-lora-refine-details-1-0", file: "ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors", page: "https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Refine-Details", sizeGb: 1.31 },+ },+ /** LTX works in 8n+1 frames: the trained window, the prefix hand-off (17 = 8·2 + 1) and the shortest pass. */+ window: 97,+ prefix: 17,+ minFrames: 9,+ /** The trained tiles (stage 1) and the Detail Refine tiles (stage 2), at 50% overlap. */+ tile: { width: 960, height: 544 },+ refineTile: { width: 1024, height: 576 },+ overlap: 0.5,+ /** The card's 8 distilled steps. */+ sigmas: [1.0, 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0],+ /** One run takes up to two minutes of footage (the windows add up fast on a GPU, the pieces in the cloud). */+ maxSeconds: 120,+ /** A single generation (Canvas, the API) makes one pass: up to fal's 481 frames, or 20 s of the GPU's streaming windows. */+ singleFrames: 481,+ maxBytes: 1024 * 1024 * 1024,+ accept: "video/mp4,video/quicktime,video/webm,video/x-matroska,video/x-msvideo,.mp4,.mov,.m4v,.webm,.mkv,.avi",+ /** Cloud tiers (Fuobe Cinema's size table) and the default. */+ cloudResolutions: ["720p", "1080p"],+ cloudResolution: "720p",+} as const;++/** The card's canvas widths: 1440 for 4:3-ish scans, 1920 for 16:9 and wider (the threshold is halfway, in log terms). */+const WIDE = Math.sqrt((4 / 3) * (16 / 9));+const r32 = (n: number) => Math.max(32, Math.round(n / 32) * 32);++export interface Size {+ width: number;+ height: number;+}++/**+ * The working canvas: the longer side 1440 (up to about 3:2) or 1920 (wider), the shorter one from the clip's own shape,+ * both multiples of 32, never shorter than a tile. 640x480 and 720x544 scans → 1440x1088; 16:9 → 1920x1088; portrait+ * clips the other way round. Unknown size: the 4:3 canvas (most archive scans).+ */+export function restoreCanvas(width?: number, height?: number): Size {+ if (!width || !height || !(width > 0) || !(height > 0)) return { width: 1440, height: 1088 };+ const portrait = height > width;+ const ratio = portrait ? height / width : width / height;+ let long = ratio >= WIDE ? 1920 : 1440;+ let short = r32(long / ratio);+ // Very wide shapes (4:1): a tile must still fit across the short side.+ if (short < RESTORE.tile.height) {+ short = RESTORE.tile.height;+ long = r32(short * ratio);+ }+ return portrait ? { width: short, height: long } : { width: long, height: short };+}++/** Stage 2's canvas: twice the restored one (2880x2176 from 1440x1088). */+export const refineCanvas = (c: Size): Size => ({ width: c.width * 2, height: c.height * 2 });++/** How a canvas splits into overlapping tiles: columns × rows (1440x1088 at 960x544 and 50% is 2 × 3). */+export function tileGrid(canvas: Size, tile: Size = RESTORE.tile, overlap: number = RESTORE.overlap): { columns: number; rows: number; tiles: number } {+ const count = (side: number, t: number) => (side <= t ? 1 : Math.ceil((side - t) / (t * (1 - overlap)) - 1e-9) + 1);+ const columns = count(canvas.width, tile.width);+ const rows = count(canvas.height, tile.height);+ return { columns, rows, tiles: columns * rows };+}++// ---------------------------------------------------------------------------+// Windows (GPU) and pieces (cloud)++export interface RestoreWindow {+ index: number;+ /** The first source frame the window reads (the prefix's, for a window after the first). */+ start: number;+ /** Frames it reads and renders: 8n+1, at most 97. */+ frames: number;+ /** Frames at its start the window before already restored (given as the prefix, then dropped): 0 or 17. */+ prefix: number;+ /** The frames it adds to the result: frames − prefix. */+ keep: number;+ /** Where the prefix starts in the window before's saved output (its kept frames less 17). */+ prefixFrom?: number;+}++/**+ * The card's chained windows over `total` frames: the first one up to 97 frames, each next one 17 frames of the one+ * before (as its prefix, LTXVAddGuide at frame 0) plus up to 80 new ones, in steps of 8 so every window stays 8n+1.+ * The windows cover all but fewer than 8 frames at the end (the sound is cut to the picture).+ */+export function restoreWindows(total: number): RestoreWindow[] {+ const { window: W, prefix: P, minFrames } = RESTORE;+ if (!(total >= minFrames)) return [];+ const first = Math.min(W, 8 * Math.floor((total - 1) / 8) + 1);+ const out: RestoreWindow[] = [{ index: 0, start: 0, frames: first, prefix: 0, keep: first }];+ let end = first;+ for (;;) {+ const fresh = Math.min(W - P, 8 * Math.floor((total - end) / 8));+ if (fresh < 8) break;+ const prev = out[out.length - 1];+ out.push({ index: out.length, start: end - P, frames: P + fresh, prefix: P, keep: fresh, prefixFrom: prev.keep - P });+ end += fresh;+ }+ return out;+}++/** Frames the windows (or pieces) leave out at the end: fewer than 8. */+export const framesCovered = (w: { keep?: number; frames: number }[]): number => w.reduce((n, x) => n + (x.keep ?? x.frames), 0);++/** Cloud pieces: back to back, each 8n+1 frames and at most 97, as even as possible (the fewest that fit). */+export const CLOUD_PIECE: FrameWindow = { cap: RESTORE.window, step: 8, base: 1, min: RESTORE.minFrames };++/** Stage 2's windows over the restored clip: back to back, 8n+1, at most 97 (no prefix: the Detail Refine LoRA keeps the colour). */+export const REFINE_WINDOW: FrameWindow = { cap: RESTORE.window, step: 8, base: 1, min: RESTORE.minFrames };++export const cloudPieceFrames = (total: number): number[] => frameWindows(total, CLOUD_PIECE);++// ---------------------------------------------------------------------------+// Words: the prompt and the negative++/** What the model must not invent, by default (the card's train example plus the obvious modern things). */+export const MODERN_OBJECTS = [+ "modern cars",+ "modern buildings",+ "shipping containers",+ "mobile phones",+ "logos",+ "signage",+ "lettering",+ "graffiti",+ "satellite dishes",+ "plastic furniture",+];++/** The damage the card's runs named in their negative (the model must not reproduce it). */+export const ARTEFACTS = ["blocky compression", "banding", "mosquito noise", "ringing", "blurry", "smeared", "ghosting", "low resolution"];++export interface SceneWords {+ /** "1950s", "1896", "the 1930s". */+ period?: string;+ /** "a railway station in rural France". */+ place?: string;+ /** "overcast daylight", "soft window light". */+ light?: string;+ /** "wooden station buildings, steam". */+ materials?: string;+ /** "period coats and hats". */+ clothing?: string;+ /** What happens or who is there ("a steam locomotive arriving"). */+ subject?: string;+}++const tidy = (s: string | undefined) => (s ?? "").replace(/\s+/g, " ").trim().replace(/[.,;\s]+$/, "");+const decade = (p: string) => (/^(1[89]|20)\d0s$/.test(p) || /^(1[89]|20)\d\d$/.test(p) ? `in ${p}` : p);++/**+ * The card's prompt from the scene's words: what happens, the period and place, the light, the materials and what people+ * wear, ending in "natural colour". Kept generic across the frame (every tile reads the whole prompt).+ */+export function restorePrompt(w: SceneWords): string {+ const subject = tidy(w.subject) || "the scene as it was filmed";+ const period = tidy(w.period);+ const place = tidy(w.place);+ const lead = [subject, place && (/^(in|at|on|by|near|inside|outside)\b/i.test(place) ? place : `in ${place}`), period && decade(period)].filter(Boolean).join(" ");+ const parts = [lead, tidy(w.light), tidy(w.materials), tidy(w.clothing)].filter(Boolean);+ return `${parts.join(", ")}, natural colour`;+}++/** The negative: what must not be invented (modern objects by default), then the artefacts. */+export function restoreNegative(prohibitions: string[] = MODERN_OBJECTS): string {+ const seen = new Set<string>();+ const out: string[] = [];+ for (const p of [...prohibitions, ...ARTEFACTS]) {+ const t = tidy(p).toLowerCase();+ if (t && !seen.has(t)) {+ seen.add(t);+ out.push(t);+ }+ }+ return out.join(", ");+}++/** Fuobe's offline writer: the template filled with what the user typed (no LLM, demo mode, or the text model off). */+export function offlineRestorePrompt(hint?: string): { prompt: string; negative: string } {+ const h = tidy(hint);+ const year = /\b(1[89]\d0s|20[0-2]0s|1[89]\d\d|20[0-2]\d)\b/.exec(h)?.[1];+ const subject = h ? h.replace(/\b(in|from)\s+(the\s+)?(1[89]\d0s|20[0-2]0s|1[89]\d\d|20[0-2]\d)\b/i, "").replace(/\s+/g, " ").trim().replace(/[,\s]+$/, "") : "";+ const prompt = restorePrompt({+ subject: subject || undefined,+ period: year,+ light: "natural daylight",+ materials: "period materials and surfaces",+ clothing: "people in clothing of the period",+ });+ return { prompt: `${prompt}, sharp photographic detail, natural grain`, negative: restoreNegative() };+}++/** The LLM's brief (Fuobe's own words): it sees a few frames of the clip and the user's hint. */+export const PROMPT_SYSTEM = `You write the prompts for a video restoration model that turns archive footage (black and white, sepia, tape, low-resolution web rips) into a clean colour clip of the same shot. Colour is inferred from your words, so describe what the frames show as it would have looked in colour.+Reply with exactly two lines and nothing else:+PROMPT: one sentence of 25 to 60 words: what happens and who is there, the period (a decade or year), the place, the light, the materials and what people wear, ending with "natural colour". Keep it generic across the frame: no positions, no text on signs, no names of people.+NEGATIVE: a comma-separated list of 6 to 14 modern things the model must not invent in this scene (vehicles, buildings, objects, logos, signage, lettering…), lower case.`;++/** The LLM's question: the user's words and how many frames are attached. */+export function promptRequest(o: { hint?: string; frames: number; seconds?: number }): string {+ const lines = [o.hint?.trim() ? `What the user knows about the footage: ${tidy(o.hint).slice(0, 600)}` : "The user gave no details: infer the period and place from the frames."];+ if (o.frames) lines.push(`Attached: ${o.frames} frame${o.frames > 1 ? "s" : ""} of the clip, in order.`);+ if (o.seconds) lines.push(`The clip is ${Math.round(o.seconds)} s long.`);+ return lines.join("\n");+}++/** An LLM's answer as a prompt and a negative; null when the prompt line is missing or too short. */+export function parsePromptAnswer(text: string | null | undefined): { prompt: string; negative: string } | null {+ if (!text) return null;+ const line = (label: string) => new RegExp(`^\\s*\\**${label}\\**\\s*:\\s*(.+)$`, "im").exec(text)?.[1]?.trim().replace(/^["“]|["”]$/g, "");+ let prompt = tidy(line("PROMPT"));+ if (prompt.length < 12) return null;+ if (!/natural colou?r$/i.test(prompt)) prompt = `${prompt}, natural colour`;+ const negative = line("NEGATIVE");+ const items = (negative ?? "")+ .split(",")+ .map((s) => tidy(s).toLowerCase())+ .filter((s) => s && s.length < 60);+ return { prompt: prompt.slice(0, 600), negative: restoreNegative(items.length ? items : MODERN_OBJECTS) };+}++// ---------------------------------------------------------------------------+// Checks++export interface RestoreSource {+ url: string;+ duration?: number;+ fps?: number;+ width?: number;+ height?: number;+ hasAudio?: boolean;+ /** Frames in the clip, when its header says (else duration × fps). */+ frames?: number;+}++/** The clip's frame count: its header's, else its length at its rate. */+export function sourceFrames(s: Pick<RestoreSource, "frames" | "duration" | "fps">): number | undefined {+ if (s.frames && s.frames > 0) return Math.floor(s.frames);+ if (s.duration && s.fps) return Math.floor(s.duration * s.fps + 1e-6);+ return undefined;+}++/** Why this run can't start, or null. */+export function restoreProblem(o: { engine: Engine; source: Pick<RestoreSource, "duration" | "fps" | "frames">; refine?: boolean; resolution?: string }): string | null {+ const d = o.source.duration;+ if (d === undefined || !o.source.fps) return "Reading the clip… try again in a moment";+ if (d > RESTORE.maxSeconds + 0.05) return `Restore takes up to ${RESTORE.maxSeconds / 60} minutes at a time: trim the clip first (Video tools → Trim)`;+ if ((sourceFrames(o.source) ?? 0) < RESTORE.minFrames) return "The clip is too short to restore: it needs at least 9 frames";+ if (o.refine && o.engine === "cloud") return "Restore to 4K runs on your GPU: the Detail Refine IC-LoRA is an LTX-2.5 LoRA, and no cloud host runs LTX-2.5 with LoRAs";+ if (o.engine === "cloud" && o.resolution && !(RESTORE.cloudResolutions as readonly string[]).includes(o.resolution)) return `Pick ${RESTORE.cloudResolutions.join(" or ")}`;+ return null;+}++// ---------------------------------------------------------------------------+// The pipeline: steps for createPipeline (src/server/chains.ts)++export interface RestorePlanInput {+ engine: Engine;+ title: string;+ source: RestoreSource;+ prompt: string;+ negative: string;+ /** GPU only: a second pass to 4K class with the Detail Refine IC-LoRA. */+ refine?: boolean;+ /** GPU only: keep one field of interlaced frames before restoring. */+ deinterlace?: boolean;+ /** A reference picture: true colours, faces, signs (GPU: at frame_idx -1 on every window). */+ reference?: string;+ /** Cloud tier (720p or 1080p). */+ resolution?: string;+ seed?: number;+}++export interface RestorePlan {+ steps: PlanStep[];+ final: string;+ /** Windows (GPU) or pieces (cloud). */+ pieces: number;+ /** The working canvas (GPU), or the size the cloud renders. */+ canvas: Size;+ /** Stage 2's canvas, when it runs. */+ refined?: Size;+ /** Frames left out at the end (fewer than 8: whole 8n+1 windows). */+ dropped: number;+ sound: boolean;+}++const r6 = (n: number) => Math.round(n * 1e6) / 1e6;+const label = (i: number, n: number, what: string) => ({ label: n > 1 ? `Piece ${i + 1} of ${n} · ${what}` : what[0].toUpperCase() + what.slice(1), index: i, of: n });++/** The tier and shape fal renders a clip of this size at (Fuobe Cinema's table): the shape nearest the clip's own. */+export const CLOUD_SHAPES = ["21:9", "16:9", "4:3", "1:1", "3:4", "9:16"] as const;+export function cloudShape(width?: number, height?: number): (typeof CLOUD_SHAPES)[number] {+ if (!width || !height) return "4:3";+ const r = Math.log(width / height);+ return CLOUD_SHAPES.reduce((best, s) => {+ const [a, b] = s.split(":").map(Number);+ const [c, d] = best.split(":").map(Number);+ return Math.abs(Math.log(a / b) - r) < Math.abs(Math.log(c / d) - r) ? s : best;+ }, "4:3" as (typeof CLOUD_SHAPES)[number]);+}++/** fal's size for a tier and shape (Fuobe Cinema's table, as the cloud half's FieldMap.size sends it). */+export const CLOUD_SIZES: Record<string, Record<(typeof CLOUD_SHAPES)[number], [number, number]>> = {+ "720p": { "21:9": [1504, 640], "16:9": [1280, 704], "4:3": [1024, 768], "1:1": [960, 960], "3:4": [768, 1024], "9:16": [704, 1280] },+ "1080p": { "21:9": [2240, 960], "16:9": [1920, 1088], "4:3": [1440, 1088], "1:1": [1088, 1088], "3:4": [1088, 1440], "9:16": [1088, 1920] },+};++/**+ * The whole job. GPU: the windows, chained by their 17-frame prefix (each reads the source itself and the window before's+ * output), then (Restore to 4K) the restored clip again in 97-frame windows with the Detail Refine LoRA. Cloud: 8n+1-frame+ * pieces of up to 97 frames cut from the clip, each after the first given the last restored frame of the one before.+ * Then the pieces are joined and the clip's own sound put back.+ */+export function planRestore(input: RestorePlanInput): RestorePlan {+ const { engine, source } = input;+ const total = sourceFrames(source) ?? 0;+ const fps = source.fps ?? 24;+ const base = { feature: RESTORE.feature, batchTitle: input.title };+ const helper = { feature: RESTORE.stepFeature, batchTitle: input.title };+ const seed = input.seed !== undefined ? { seed: input.seed } : {};+ const sound = !!source.hasAudio;+ const words = { prompt: input.prompt, negativePrompt: input.negative };+ const steps: PlanStep[] = [];+ const own = (last: boolean) => (last && !sound ? { ...base, title: input.title } : helper);++ if (engine === "open") {+ const canvas = restoreCanvas(source.width, source.height);+ const windows = restoreWindows(total);+ if (!windows.length) throw new Error("The clip is too short to restore: it needs at least 9 frames");+ const n = windows.length;+ const refine = !!input.refine;+ const keys: string[] = [];+ for (const w of windows) {+ const key = `restore${w.index}`;+ const lone = n === 1 && !refine;+ steps.push({+ key,+ request: {+ ...own(lone),+ modelId: RESTORE.model,+ engine: "open",+ op: "restore-video",+ ...words,+ inputs: { video: source.url, ...(input.reference ? { images: [input.reference] } : {}) },+ params: {+ fps,+ sourceDuration: r6(w.keep / fps),+ extra: {+ stage: "restore",+ windowStart: w.start,+ windowFrames: w.frames,+ prefixFrames: w.prefix,+ ...(w.prefixFrom !== undefined ? { prefixFrom: w.prefixFrom } : {}),+ canvasWidth: canvas.width,+ canvasHeight: canvas.height,+ ...(input.deinterlace ? { deinterlace: true } : {}),+ },+ ...seed,+ },+ step: label(w.index, n, "restore"),+ },+ ...(w.index > 0 ? { after: [`restore${w.index - 1}`], chain: [{ slot: "videos" as const, position: "first" as const }] } : {}),+ });+ keys.push(key);+ }+ let picture = joinEncoded(steps, keys, "join", refine || sound ? helper : { ...base, title: input.title }, "Join the windows");+ let refined: Size | undefined;+ if (refine) {+ refined = refineCanvas(canvas);+ const restored = framesCovered(windows);+ const cuts = frameWindows(restored, REFINE_WINDOW);+ let at = 0;+ const rkeys: string[] = [];+ cuts.forEach((frames, i) => {+ const key = `refine${i}`;+ steps.push({+ key,+ request: {+ ...own(cuts.length === 1),+ modelId: RESTORE.model,+ engine: "open",+ op: "restore-video",+ ...words,+ params: {+ fps,+ sourceDuration: r6(frames / fps),+ extra: { stage: "refine", windowStart: at, windowFrames: frames, prefixFrames: 0, canvasWidth: refined!.width, canvasHeight: refined!.height },+ ...seed,+ },+ step: label(i, cuts.length, "detail pass (4K)"),+ },+ after: [picture],+ chain: [{ slot: "video" }],+ });+ rkeys.push(key);+ at += frames;+ });+ picture = joinEncoded(steps, rkeys, "join4k", sound ? helper : { ...base, title: input.title }, "Join the 4K windows");+ }+ const final = sound ? putSoundBack(steps, picture, base, input.title, source, "open") : picture;+ const covered = refine ? frameWindows(framesCovered(windows), REFINE_WINDOW).reduce((a, b) => a + b, 0) : framesCovered(windows);+ return { steps, final, pieces: n, canvas, refined, dropped: total - covered, sound };+ }++ // Cloud: frame-exact pieces, each restored in one untiled pass; a piece after the first starts from the last restored+ // frame of the one before (fal's image_url, the first frame of the video).+ const resolution = input.resolution && (RESTORE.cloudResolutions as readonly string[]).includes(input.resolution) ? input.resolution : RESTORE.cloudResolution;+ const shape = cloudShape(source.width, source.height);+ const [cw, ch] = CLOUD_SIZES[resolution][shape];+ const duration = source.duration ?? total / fps;+ const pieces = planFrameCuts({ start: 0, end: duration }, fps, CLOUD_PIECE);+ if (!pieces.length) throw new Error("The clip is too short to restore: it needs at least 9 frames");+ const n = pieces.length;+ const whole = n === 1 && wholeClip({ start: 0, end: pieces[0].end }, duration);+ const keys: string[] = [];+ pieces.forEach((p, i) => {+ const after: string[] = [];+ const chain: ChainSlot[] = [];+ if (!whole) {+ steps.push({+ key: `cut${i}`,+ request: { ...helper, modelId: REMOVE_TOOLS.cloud.cut, op: "trim", inputs: { video: source.url }, params: { startTime: p.start, endTime: p.end }, step: label(i, n, "cut") },+ });+ after.push(`cut${i}`);+ chain.push({ slot: "video" });+ }+ if (i > 0) {+ steps.push({+ key: `hand${i}`,+ request: { ...helper, modelId: "extract-frame", op: "frame", step: label(i, n, "hand-off frame") },+ after: [`restore${i - 1}`],+ chain: [{ slot: "video" }],+ });+ after.push(`hand${i}`);+ chain.push({ slot: "images" });+ }+ const seconds = r6((p.frames ?? Math.round((p.end - p.start) * fps)) / fps);+ const lone = n === 1;+ const request: GenerationRequest = {+ ...own(lone),+ modelId: RESTORE.model,+ engine: "cloud",+ op: "restore-video",+ ...words,+ ...(whole ? { inputs: { video: source.url } } : {}),+ params: { aspectRatio: shape, resolution, fps, duration: seconds, sourceDuration: seconds, ...seed },+ step: label(i, n, "restore"),+ };+ steps.push({ key: `restore${i}`, request, ...(after.length ? { after, chain } : {}) });+ keys.push(`restore${i}`);+ });+ let picture = keys[0];+ if (n > 1) picture = foldJoin(steps, keys, sound ? helper : { ...base, title: input.title });+ const end = pieces[n - 1].end;+ const final = sound ? putSoundBack(steps, picture, base, input.title, source, "cloud", end) : picture;+ const covered = pieces.reduce((a, p) => a + (p.frames ?? 0), 0);+ return { steps, final, pieces: n, canvas: { width: cw, height: ch }, dropped: Math.max(0, total - covered), sound };+}++/** The open join: the windows share one size and frame rate, so they're joined packet by packet (no decode, no resize). */+function joinEncoded(steps: PlanStep[], keys: string[], key: string, who: Pick<GenerationRequest, "feature" | "batchTitle" | "title">, what: string): string {+ if (keys.length === 1) return keys[0];+ steps.push({+ key,+ request: { ...who, modelId: "oss-join-encoded", op: "concat", step: { label: what, index: 1000, of: 1000 } },+ after: keys,+ chain: keys.map(() => ({ slot: "videos" as const })),+ });+ return key;+}++/** The cloud join, folded when there are more pieces than fal's merge takes. */+function foldJoin(steps: PlanStep[], keys: string[], last: Pick<GenerationRequest, "feature" | "batchTitle" | "title">): string {+ const t = REMOVE_TOOLS.cloud;+ let level = keys;+ let depth = 0;+ while (level.length > 1) {+ const groups = joinGroups(level.length, t.joinMax);+ const top = groups.length === 1;+ level = groups.map((g, gi) => {+ const after = g.map((i) => level[i]);+ const key = top ? "join" : `join-${depth}-${gi}`;+ steps.push({+ key,+ request: { ...(top ? last : { feature: RESTORE.stepFeature, batchTitle: last.batchTitle }), modelId: t.join, op: "concat", step: { label: top ? "Join the pieces" : "Joining", index: 1000 + depth, of: 1000 } },+ after,+ chain: after.map(() => ({ slot: "videos" as const })),+ });+ return key;+ });+ depth++;+ }+ return level[0];+}++/**+ * The clip's own sound back under the restored picture. The open mux trims it to the picture; in the cloud the sound is+ * cut to where the last piece ends first (whole 8n+1 pieces leave out fewer than 8 frames).+ */+function putSoundBack(steps: PlanStep[], picture: string, base: { feature: string; batchTitle: string }, title: string, source: RestoreSource, engine: Engine, end?: number): string {+ const t = REMOVE_TOOLS[engine];+ const after = [picture];+ const chain: ChainSlot[] = [{ slot: "video" }];+ let inputs: GenerationRequest["inputs"] = { audio: source.url };+ if (engine === "cloud" && end !== undefined && source.duration !== undefined && end < source.duration - 0.05) {+ steps.push({+ key: "sound",+ request: { feature: RESTORE.stepFeature, batchTitle: base.batchTitle, modelId: t.cut, op: "trim", inputs: { video: source.url }, params: { startTime: 0, endTime: end }, step: { label: "Original sound", index: 1100, of: 1000 } },+ });+ after.push("sound");+ chain.push({ slot: "audio" });+ inputs = undefined;+ }+ steps.push({+ key: "final",+ request: { ...base, title, modelId: t.mux, op: "mux", ...(inputs ? { inputs } : {}), step: { label: "Put the sound back", index: 1200, of: 1000 } },+ after,+ chain,+ });+ return "final";+}++/** A short name for the run: the prompt's first words and the clip's name. */+export function restoreTitle(prompt: string, clipName?: string): string {+ const words = tidy(prompt)+ .replace(/,?\s*natural colou?r.*$/i, "")+ .split(/[,.]/)[0]+ .split(" ")+ .slice(0, 6)+ .join(" ");+ const head = words ? `Restored · ${words[0].toUpperCase()}${words.slice(1)}` : "Restored";+ const name = clipName?.replace(/\.[a-z0-9]{2,4}$/i, "").trim().slice(0, 40);+ return name ? `${head} · ${name}` : head;+}++// ---------------------------------------------------------------------------+// Words for the page++/** The hardware line under the GPU choice (no measurement here: the CPU server only checks the graph). */+export const GPU_NOTE = "LTX-2.5 22B distilled with tiled latent fusion: a 24 GB GPU class, minutes per window. Free on your GPU.";++/** What the cloud does differently (the owner's rule: say plainly what runs where). */+export const CLOUD_NOTE =+ "The cloud runs LTX-2.3 22B on fal with the same Restore IC-LoRA, one untiled pass a piece at the tier's size. The card recommends tiles at every size, so your GPU's tiled run is the reference recipe.";++/** The one-time gated download, as the page says it. */+export const GATED_NOTE = "The Restore IC-LoRA (1.7 GB) is gated on Hugging Face: accept its licence there once, then add your Hugging Face token in Settings → LoRAs.";diff --git a/src/lib/restore-graph.ts b/src/lib/restore-graph.tsnew file mode 100644index 00000000..956628b5--- /dev/null+++ b/src/lib/restore-graph.ts@@ -0,0 +1,146 @@+/**+ * Restore & colourise on your GPU (package archive-restore): what one run of the video-restore-ltx25-tiled graph does,+ * from the request (src/lib/catalog/restore.ts plans the windows), and the graph's optional branches taken out when a run+ * doesn't use them: the prefix hand-off (the first window), the reference picture, deinterlacing. Pure: the ComfyUI+ * provider calls it, the tests check it.+ */+import { cloneWorkflow, dropUnused, type ComfyWorkflow } from "./comfy";+import { loraEntry, loraRef } from "./catalog/loras";+import { RESTORE, refineCanvas, restoreCanvas, sourceFrames } from "./catalog/restore";+import type { LoraRef } from "./catalog/types";++export type RestoreStage = "restore" | "refine";++/** What the clip's header says (the provider's media facts). */+export interface ClipFacts {+ width?: number;+ height?: number;+ fps?: number;+ frames?: number;+ duration?: number;+}++export interface RestoreJob {+ /** Values for the graph's bindings (beside prompt, negativePrompt, seed, video, video2, image). */+ values: Record<string, string | number | boolean>;+ /** The branches this run keeps. */+ prefix: boolean;+ reference: boolean;+ deinterlace: boolean;+ stage: RestoreStage;+}++const int = (v: unknown): number | undefined => (typeof v === "number" && Number.isFinite(v) ? Math.round(v) : typeof v === "string" && v.trim() && Number.isFinite(Number(v)) ? Math.round(Number(v)) : undefined);+const r32 = (n: number) => Math.max(32, Math.round(n / 32) * 32);++/** The extra keys a restore run reads (the provider takes them out of params.extra once used). */+export const RESTORE_EXTRA_KEYS = ["stage", "windowStart", "windowFrames", "prefixFrames", "prefixFrom", "canvasWidth", "canvasHeight", "deinterlace"] as const;++/**+ * One run of the graph:+ * - a window of the restore pipeline (params.extra.windowStart / windowFrames / canvas…, set by planRestore), with the+ * window before's output as videos[0] for the prefix;+ * - or a whole clip on its own (Canvas, the API, Assist): up to 97 frames in one pass, longer clips with the sampler's own+ * 97-frame streaming windows (the card's other long-clip path), up to RESTORE.singleFrames.+ * Stage "refine" is the Detail Refine pass: its LoRA, 1024x576 tiles, a canvas twice the clip's.+ * Throws a sentence the user can act on.+ */+export function restoreJob(o: { extra: Record<string, unknown>; clip?: ClipFacts; fps?: number; prefixVideo?: string; reference?: string }): RestoreJob {+ const { extra, clip } = o;+ const stage: RestoreStage = extra.stage === "refine" ? "refine" : "restore";+ const fps = o.fps && o.fps > 0 ? o.fps : clip?.fps && clip.fps > 0 ? clip.fps : undefined;+ if (!fps) throw new Error("Couldn't read the clip's frame rate, so it can't be restored frame for frame. Re-save it as MP4 and try again");+ const planned = int(extra.windowFrames);+ let frames: number;+ let start = 0;+ let streaming = false;+ if (planned !== undefined) {+ if (planned < RESTORE.minFrames || planned > RESTORE.window || (planned - 1) % 8) throw new Error(`A restore window is 9 to 97 frames, 8n+1 (got ${planned})`);+ frames = planned;+ start = Math.max(0, int(extra.windowStart) ?? 0);+ } else {+ const total = sourceFrames({ frames: clip?.frames, duration: clip?.duration, fps });+ if (!total) throw new Error("Couldn't read how long the clip is. Re-save it as MP4 and try again");+ if (total > RESTORE.singleFrames) {+ throw new Error(+ `One pass restores up to ${Math.floor(RESTORE.singleFrames / fps)} s of this clip (${RESTORE.singleFrames} frames). Use Video tools → Restore & colourise: it runs longer clips in 97-frame windows that hand their colour on`,+ );+ }+ if (total < RESTORE.minFrames) throw new Error("The clip is too short to restore: it needs at least 9 frames");+ frames = 8 * Math.floor((total - 1) / 8) + 1;+ streaming = frames > RESTORE.window;+ }+ const reference = !!o.reference;+ if (reference && streaming) throw new Error("A reference picture works on one window (up to 4 s) at a time. Use Video tools → Restore & colourise for longer clips: it gives the picture to every window");+ // The canvas: the plan's, else the card's for the clip (stage 1) or twice the clip (stage 2: the clip is the restored one).+ let width = int(extra.canvasWidth);+ let height = int(extra.canvasHeight);+ if (!width || !height) {+ if (stage === "refine") {+ if (!clip?.width || !clip.height) throw new Error("Couldn't read the clip's size for the detail pass");+ ({ width, height } = refineCanvas({ width: r32(clip.width), height: r32(clip.height) }));+ } else ({ width, height } = restoreCanvas(clip?.width, clip?.height));+ }+ if (width % 32 || height % 32 || width > 3840 || height > 3840) throw new Error(`The canvas must be multiples of 32 up to 3840 px (got ${width}x${height})`);+ const deinterlace = stage === "restore" && extra.deinterlace === true;+ if (deinterlace && (!clip?.width || !clip.height)) throw new Error("Couldn't read the clip's size to deinterlace it");+ const prefixFrames = int(extra.prefixFrames) ?? 0;+ const prefix = prefixFrames > 0;+ if (prefix && prefixFrames !== RESTORE.prefix) throw new Error(`The hand-off prefix is ${RESTORE.prefix} frames`);+ if (prefix && !o.prefixVideo) throw new Error("This window continues from the one before, which hasn't finished");+ if (!prefix && o.prefixVideo && planned !== undefined) throw new Error("A first window takes no prefix");+ const prefixFrom = int(extra.prefixFrom);+ if (prefix && (prefixFrom === undefined || prefixFrom < 0)) throw new Error("The hand-off needs where the prefix starts in the window before");+ const tile = stage === "refine" ? RESTORE.refineTile : RESTORE.tile;+ const values: RestoreJob["values"] = {+ fps: Math.round(fps * 1000) / 1000,+ windowStart: start,+ windowFrames: frames,+ canvasWidth: width,+ canvasHeight: height,+ prefixFrames: prefix ? prefixFrames : 0,+ lora: stage === "refine" ? RESTORE.loras.refine.file : RESTORE.loras.restore.file,+ loraStrength: 1,+ tileWidth: tile.width,+ tileHeight: tile.height,+ streaming,+ tileFrames: streaming ? RESTORE.window : 0,+ cfg: 1,+ };+ if (prefix) values.prefixFrom = prefixFrom!;+ if (deinterlace) Object.assign(values, { fieldWidth: clip!.width!, fieldHeight: Math.max(2, Math.round(clip!.height! / 2)) });+ return { values, prefix, reference, deinterlace, stage };+}++/** Take a guide node out: whatever read its (positive, negative, latent) reads what it was given. */+function unguide(wf: ComfyWorkflow, id: string): void {+ const g = wf[id];+ if (!g) return;+ const by = [g.inputs.positive, g.inputs.negative, g.inputs.latent];+ for (const n of Object.values(wf)) {+ for (const [k, v] of Object.entries(n.inputs)) {+ if (Array.isArray(v) && v[0] === id && typeof v[1] === "number" && by[v[1]] !== undefined) n.inputs[k] = by[v[1]] as typeof v;+ }+ }+ delete wf[id];+}++/** The graph as this run uses it: the prefix, the reference and the deinterlace branches out when not used. */+export function restoreGraph(wf: ComfyWorkflow, job: Pick<RestoreJob, "prefix" | "reference" | "deinterlace">, outputs: string[]): ComfyWorkflow {+ const out = cloneWorkflow(wf);+ if (!job.prefix) unguide(out, "prefix");+ if (!job.reference) unguide(out, "reference_guide");+ if (!job.deinterlace && out.field) {+ const src = out.field.inputs.image;+ for (const n of Object.values(out)) for (const [k, v] of Object.entries(n.inputs)) if (Array.isArray(v) && v[0] === "field") n.inputs[k] = src;+ delete out.field;+ }+ return dropUnused(out, outputs);+}++/** The LoRA files the graph loads itself (so a run downloads the ones ComfyUI lacks first): Restore, or Detail Refine for stage 2. */+export function restoreGraphLoras(endpoint: string, extra: Record<string, unknown> | undefined): LoraRef[] {+ if (endpoint !== RESTORE.workflow) return [];+ const e = loraEntry(extra?.stage === "refine" ? RESTORE.loras.refine.key : RESTORE.loras.restore.key);+ return e ? [loraRef(e)] : [];+}diff --git a/src/server/generations.ts b/src/server/generations.tsindex 067d5fb2..2da4a001 100644--- a/src/server/generations.ts+++ b/src/server/generations.ts@@ -52,7 +52,8 @@ import { enhancePrompt, enhanceSoulWords } from "./enhance";import { setResolver, watchGenerations, type LiveEvent } from "./live";import { provider, PROVIDERS, RETIRED_PROVIDER_ERROR } from "./providers";import { comfyLoraFiles, probeComfy } from "./providers/comfyui";-import { graphLoras } from "@/lib/catalog/character-swap";+import { graphLoras as h3GraphLoras } from "@/lib/catalog/character-swap";+import { restoreGraphLoras } from "@/lib/restore-graph";import { ensureLorasOnComfy, prepareCloudLoras, withoutUnreachableCivitai } from "./loras";import { ACCESS_PLACE } from "@/lib/model-access";import { offeredLoras, offeredRoutes, requireOffered } from "./model-access";@@ -636,6 +637,9 @@ function prepare(original: GenerationRequest) {return { req, plan, route, demo, providerId, notes, asked, unreachable, switchedOff: access.dropped, cost: free ? 0 : estimateCost(plan.model, priced, 1, plan.op, withLoras) };}+/** The LoRA files a graph loads itself (not injected), so a run downloads the ones ComfyUI lacks before it starts. */+const graphLoras = (endpoint: string, extra: Record<string, unknown> | undefined) => [...h3GraphLoras(endpoint, extra), ...restoreGraphLoras(endpoint, extra)];+/** Operations whose clip length is the duration picked (made, or added by extend), not an input video's. */const MADE_LENGTH_OPS = new Set<Operation>(["t2v", "i2v", "flf2v", "ref2v", "extend", "keyframes"]);@@ -1273,7 +1277,8 @@ async function submit(if (input.loras?.length && (providerId === "fal" || providerId === "replicate")) {input.loras = await prepareCloudLoras(input.loras, providerId, (data, name) => adapter.prepareFile(data, "application/octet-stream", name, route), (message) => update(id, { message }));} else if (providerId === "comfyui" && (input.loras?.length || graphLoras(route.endpoint, input.extra).length)) {- // A graph that loads its own LoRAs (Genjutsu's Character swap: the Turbo and swap LoRAs) gets them downloaded too.+ // A graph that loads its own LoRAs (Genjutsu's Character swap: the Turbo and swap LoRAs; Restore & colourise: the+ // gated Restore or Detail Refine IC-LoRA) gets them downloaded too.await ensureLorasOnComfy([...(input.loras ?? []), ...graphLoras(route.endpoint, input.extra)], await comfyLoraFiles(route), (message) => update(id, { message }));}const res = await adapter.submit({ generationId: id, model: plan.model, route, input });diff --git a/src/server/providers/comfyui.ts b/src/server/providers/comfyui.tsindex 6bbfb376..d1c042d3 100644--- a/src/server/providers/comfyui.ts+++ b/src/server/providers/comfyui.ts@@ -47,6 +47,7 @@ import { CHARACTER_SWAP, packResolution, samCoords, swapPrompt, SWAP_LORAS, windimport { maskMemoryProblem } from "@/lib/catalog/swap-studio";import { STUDIO_WORKFLOWS } from "@/lib/catalog/swap-studio-plan";import { maskGraph, segmentGraph, type MaskGraphOptions, type SegmentGraphOptions } from "@/lib/swap-studio-graphs";+import { RESTORE_EXTRA_KEYS, restoreGraph, restoreJob, type RestoreJob } from "@/lib/restore-graph";import { getMaker, makerPrompt, OPEN_TARGET_PROBLEM, ORIGINALS, swapTarget } from "@/lib/catalog/genjutsu";import { CLICK_OPEN_PROBLEM, HAND_OFF, REMOVE_SCENE, targetPhrase } from "@/lib/catalog/remove-object";import type { GenInput, MediaKind, ModelRoute, Operation } from "@/lib/catalog/types";@@ -1083,6 +1084,21 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,const tooBig = maskMemoryProblem({ width: clip?.width, height: clip?.height, quality: input.resolution, shotFrames, correcting: prev }, await ctx.serverRam?.());if (tooBig) throw new ProviderError(tooBig);}+ // Restore & colourise (video-restore-ltx25-tiled): the window, canvas, LoRA and tiles of this pass; the prefix (the window+ // before's restored frames, videos[0]), the reference picture (images[0]) and deinterlacing are branches it may leave out.+ let restore: RestoreJob | null = null;+ if (manifest.capability === "restore-video") {+ const prefixVideo = typeof clips[0] === "string" && clips[0] && clips[0] !== values.video ? clips[0] : undefined;+ try {+ restore = restoreJob({ extra, clip: clip ? clipFacts(clip) : undefined, fps: input.fps, prefixVideo, reference: images[0] });+ } catch (e) {+ throw new ProviderError((e as Error).message);+ }+ for (const k of RESTORE_EXTRA_KEYS) delete extra[k];+ Object.assign(values, restore.values, { video2: restore.prefix ? prefixVideo : undefined, image: restore.reference ? images[0] : undefined });+ if (!restore.prefix) studioLeft.push("video2");+ if (!restore.reference) studioLeft.push("image");+ }// Genjutsu's Object swap: SAM 3.1 follows what goes (params.extra.maskPrompt, or the "replace … with" part of the prompt,// as Genjutsu sends it), the reference comes in, the prompt describes the result. Insert: the painted spot and the// reference, the prompt says what appears there. Neither graph takes clicked points.@@ -1219,6 +1235,7 @@ export async function prepareWorkflow(endpointTemplate: string, input: GenInput,if (dropSwapLora && b.lora?.length === 1) wf = bypassNode(wf, b.lora[0].node, "model", outputIds);if (studioSegment) wf = segmentGraph(wf, { ...studioSegment, outputs: outputIds });if (studioMask) wf = maskGraph(wf, { ...studioMask, outputs: outputIds });+ if (restore) wf = restoreGraph(wf, restore, outputIds);// FPS Boost to a lower rate, or one the clip divides into: no interpolation, only every n-th frame.if (finish.bypassInterpolation) {const id = Object.keys(wf).find((k) => wf[k].class_type === "FrameInterpolate");diff --git a/src/server/providers/mock.ts b/src/server/providers/mock.tsindex ac9fc5d3..8f26d1c5 100644--- a/src/server/providers/mock.ts+++ b/src/server/providers/mock.ts@@ -344,6 +344,7 @@ function demoOutputs(op: Operation | undefined, kind: MediaKind, prompt: string,...(meta.master ? [{ url: `sample:${sampleClip(ar)}`, kind: "video" as const, contentType: "video/mp4", meta: { role: "master", demo: true } }] : []),];case "video-insert":+ case "restore-video":case "keyframes":case "still-motion":case "images-to-video":diff --git a/tests/comfy-library-4.test.ts b/tests/comfy-library-4.test.tsindex edc294ec..fbfb185d 100644--- a/tests/comfy-library-4.test.ts+++ b/tests/comfy-library-4.test.ts@@ -86,9 +86,11 @@ describe("round-4 ComfyUI workflows", () => {it("keeps the whole library validated, and every output role is a typed role", () => {expect(manifest.workflows.length).toBeGreaterThanOrEqual(132);expect(new Set(manifest.workflows.map((w) => w.id)).size).toBe(manifest.workflows.length);- // Only the MiniMax H3 graphs wait on node packs this server doesn't have (h3_character_swap, H3 Relay): never- // installed here, so their /prompt check names a missing node (tests/comfy-character-swap.test.ts).+ // Only the MiniMax H3 graphs and Restore & colourise wait on node packs this server doesn't have (h3_character_swap,+ // H3 Relay, ComfyUI-LTXVideo): never installed here, so their /prompt check names a missing node+ // (tests/comfy-character-swap.test.ts, tests/restore-comfy.test.ts).expect(manifest.workflows.filter((w) => !w.validated).map((w) => w.id)).toEqual([+ "video-restore-ltx25-tiled","video-character-swap-h3","video-character-swap-h3-relay","video-person-remove-h3-relay",diff --git a/tests/lora-fetch.test.ts b/tests/lora-fetch.test.tsindex eec74810..a000d97c 100644--- a/tests/lora-fetch.test.ts+++ b/tests/lora-fetch.test.ts@@ -306,6 +306,7 @@ describe("Before a cloud run", () => {const fitted = fitLoras([relight, fpv], ltx);expect(fitted.loras).toEqual([relight, fpv]);expect(fitted.notes).toEqual([]);+ expect(lorasFit({ provider: "replicate", map: { loras: { shape: "single", weights: "w", scale: "s" } } }, [relight, fpv])).toBe(false);// No token: refused by name, with where to accept the licence and where the token goes; nothing is fetched.setSetting("hfToken", "");net = network({});diff --git a/tests/restore-comfy.test.ts b/tests/restore-comfy.test.tsnew file mode 100644index 00000000..75b912dc--- /dev/null+++ b/tests/restore-comfy.test.ts@@ -0,0 +1,140 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, describe, expect, it } from "vitest";+import { getModel, getPreset } from "@/lib/catalog";+import { onEngine } from "@/lib/catalog/engines";+import { loraEntry, loraRef } from "@/lib/catalog/loras";+import { buildPayload } from "@/lib/catalog/payload";+import { planGeneration } from "@/lib/catalog/plan";+import { planRestore, RESTORE, restoreNegative } from "@/lib/catalog/restore";+import type { GenInput } from "@/lib/catalog/types";+import type { MediaInfo } from "@/lib/media-probe";++// Restore & colourise through the ComfyUI provider (the library graph video-restore-ltx25-tiled, bound for real) and+// through fal's payload builder (the cloud half's FieldMap from the research).+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-restore-comfy-"));+process.env.FUOBE_DATA_DIR = tmp;+process.env.COMFYUI_URL = "http://comfy.test:8188";+const { prepareWorkflow } = await import("@/server/providers/comfyui");+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));++const scan: MediaInfo = { container: "mp4", hasVideo: true, hasAudio: true, duration: 545 / 24, videoDuration: 545 / 24, width: 640, height: 480, fps: 24, frames: 545 };+const at = (wf: Record<string, { inputs: Record<string, unknown> }>, node: string, input: string) => wf[node]?.inputs[input];+const ctx = (media: Record<string, MediaInfo>) => ({ generationId: "g1", op: "restore-video" as const, upload: async (_d: Buffer, _t: string, name: string) => `up_${name}`, media: (n: string) => media[n] });+const plan = planRestore({ engine: "open", title: "Restored", source: { url: "/api/files/scan.mp4", duration: scan.duration, fps: 24, width: 640, height: 480, frames: 545, hasAudio: true }, prompt: "a station in 1896, natural colour", negative: restoreNegative(), seed: 5 });++describe("Restore & colourise on the GPU, through the provider", () => {+ it("the first window: its frames from the scan, the canvas, the Restore LoRA, 960x544 tiles; no prefix, no reference, no field", async () => {+ const req = plan.steps.find((s) => s.key === "restore0")!.request;+ const { workflow: wf } = await prepareWorkflow(RESTORE.workflow, { prompt: req.prompt, negativePrompt: req.negativePrompt, video: "scan.mp4", ...req.params } as GenInput, ctx({ "scan.mp4": scan }));+ expect(at(wf, "source", "video")).toBe("scan.mp4");+ expect(at(wf, "source", "skip_first_frames")).toBe(0);+ expect(at(wf, "source", "frame_load_cap")).toBe(97);+ expect(at(wf, "empty", "length")).toBe(97);+ expect([at(wf, "canvas", "width"), at(wf, "canvas", "height"), at(wf, "empty", "width"), at(wf, "empty", "height")]).toEqual([1440, 1088, 1440, 1088]);+ expect(at(wf, "canvas", "image")).toEqual(["source", 0]);+ expect(at(wf, "canvas", "upscale_method")).toBe("lanczos");+ expect(at(wf, "lora", "lora_name")).toBe(RESTORE.loras.restore.file);+ expect(at(wf, "lora", "strength_model")).toBe(1);+ expect(at(wf, "sample", "tile_width")).toBe(960);+ expect(at(wf, "sample", "tile_height")).toBe(544);+ expect(at(wf, "sample", "overlap_frac")).toBe(0.5);+ expect(at(wf, "sample", "cfg")).toBe(1);+ expect(at(wf, "sample", "seed")).toBe(5);+ expect(at(wf, "sample", "tile_frames")).toBe(0);+ expect(at(wf, "guide", "use_streaming")).toBe(false);+ expect(at(wf, "sigmas", "sigmas")).toBe(RESTORE.sigmas.map(String).join(", ").replace(/^1, /, "1.0, ").replace(/, 0$/, ", 0.0"));+ expect(at(wf, "positive", "text")).toBe("a station in 1896, natural colour");+ expect(at(wf, "negative", "text")).toBe(restoreNegative());+ expect([at(wf, "conditioning", "frame_rate"), at(wf, "video", "fps")]).toEqual([24, 24]);+ expect(at(wf, "keep", "batch_index")).toBe(0);+ for (const gone of ["prefix", "prefix_source", "reference", "reference_fit", "reference_guide", "field"]) expect(wf[gone], gone).toBeUndefined();+ expect(at(wf, "sample", "positive")).toEqual(["guide", 0]);+ // Silent: the pipeline puts the scan's own sound back after the join.+ expect(at(wf, "video", "audio")).toBeUndefined();+ });++ it("a later window: the window before's output as the prefix (its last 17 frames), dropped again from this window's output", async () => {+ const step = plan.steps.find((s) => s.key === "restore2")!;+ const prev: MediaInfo = { container: "mp4", hasVideo: true, hasAudio: false, duration: 80 / 24, videoDuration: 80 / 24, width: 1440, height: 1088, fps: 24, frames: 80 };+ const { workflow: wf } = await prepareWorkflow(+ RESTORE.workflow,+ { prompt: step.request.prompt, video: "scan.mp4", videos: ["prev.mp4"], ...step.request.params } as GenInput,+ ctx({ "scan.mp4": scan, "prev.mp4": prev }),+ );+ expect(at(wf, "source", "skip_first_frames")).toBe(160);+ expect(at(wf, "prefix_source", "video")).toBe("prev.mp4");+ expect(at(wf, "prefix_source", "skip_first_frames")).toBe(63);+ expect(at(wf, "prefix_source", "frame_load_cap")).toBe(17);+ expect(at(wf, "prefix", "frame_idx")).toBe(0);+ expect(at(wf, "keep", "batch_index")).toBe(17);+ expect(at(wf, "sample", "positive")).toEqual(["prefix", 0]);+ expect(at(wf, "sample", "latents")).toEqual(["prefix", 2]);+ });++ it("a reference picture and deinterlacing keep their branches; a whole clip past 97 frames streams in the sampler's own windows", async () => {+ const short: MediaInfo = { ...scan, frames: 49, duration: 49 / 24, videoDuration: 49 / 24 };+ const { workflow: wf } = await prepareWorkflow(+ RESTORE.workflow,+ { video: "short.mp4", images: ["ref.png"], extra: { deinterlace: true } } as GenInput,+ ctx({ "short.mp4": short }),+ );+ expect(at(wf, "reference", "image")).toBe("ref.png");+ expect(at(wf, "reference_guide", "frame_idx")).toBe(-1);+ expect(at(wf, "sample", "positive")).toEqual(["reference_guide", 0]);+ expect(at(wf, "field", "image")).toEqual(["source", 0]);+ expect([at(wf, "field", "width"), at(wf, "field", "height"), at(wf, "field", "upscale_method")]).toEqual([640, 240, "nearest-exact"]);+ expect(at(wf, "canvas", "image")).toEqual(["field", 0]);+ expect(at(wf, "source", "frame_load_cap")).toBe(49);+ const long: MediaInfo = { ...scan, frames: 300, duration: 12.5, videoDuration: 12.5 };+ const { workflow: s } = await prepareWorkflow(RESTORE.workflow, { video: "long.mp4" } as GenInput, ctx({ "long.mp4": long }));+ expect([at(s, "guide", "use_streaming"), at(s, "sample", "tile_frames"), at(s, "source", "frame_load_cap")]).toEqual([true, 97, 297]);+ await expect(prepareWorkflow(RESTORE.workflow, { video: "scan.mp4" } as GenInput, ctx({ "scan.mp4": scan }))).rejects.toThrow(/Video tools → Restore & colourise/);+ });++ it("stage 2: the Detail Refine LoRA with 1024x576 tiles on twice the canvas", async () => {+ const restored: MediaInfo = { container: "mp4", hasVideo: true, hasAudio: false, duration: 545 / 24, videoDuration: 545 / 24, width: 1440, height: 1088, fps: 24, frames: 545 };+ const { workflow: wf } = await prepareWorkflow(+ RESTORE.workflow,+ { video: "restored.mp4", extra: { stage: "refine", windowStart: 97, windowFrames: 89, prefixFrames: 0, canvasWidth: 2880, canvasHeight: 2176 } } as GenInput,+ ctx({ "restored.mp4": restored }),+ );+ expect(at(wf, "lora", "lora_name")).toBe(RESTORE.loras.refine.file);+ expect([at(wf, "sample", "tile_width"), at(wf, "sample", "tile_height")]).toEqual([1024, 576]);+ expect([at(wf, "canvas", "width"), at(wf, "canvas", "height")]).toEqual([2880, 2176]);+ expect([at(wf, "source", "skip_first_frames"), at(wf, "source", "frame_load_cap")]).toEqual([97, 89]);+ });+});++describe("Restore & colourise in the cloud: fal's payload", () => {+ it("the scan as the reference video, the Restore LoRA by its mirror, fal's own IC-LoRA and preprocessor off, the tier's size", () => {+ const m = getModel("fuobe-restore")!;+ const cloud = onEngine(m, "cloud");+ const p = planGeneration(+ { feature: "restore", modelId: m.id, op: "restore-video", prompt: "a station in 1896, natural colour", inputs: { video: "https://x/piece.mp4", images: ["https://x/last.png"] }, params: { aspectRatio: "4:3", resolution: "1080p", fps: 24, duration: 97 / 24 } },+ (id) => (id === m.id ? cloud : getModel(id)),+ getPreset,+ );+ expect(p.loras.map((l) => l.file)).toEqual([RESTORE.loras.restore.file]);+ const route = cloud.routes.find((r) => r.op === "restore-video")!;+ const lora = { ...loraRef(loraEntry(RESTORE.loras.restore.key)!), hostedUrl: "https://v3.fal.media/files/restore.safetensors" };+ const body = buildPayload(route.map!, { ...p.params, prompt: p.prompt, video: "https://x/piece.mp4", images: ["https://x/last.png"], loras: [lora] });+ expect(body).toMatchObject({+ prompt: "a station in 1896, natural colour",+ video_url: "https://x/piece.mp4",+ image_url: "https://x/last.png",+ video_size: { width: 1440, height: 1088 },+ ic_lora_type: "none",+ preprocessor: "none",+ generate_audio: false,+ enable_prompt_expansion: false,+ match_video_length: true,+ match_input_fps: true,+ loras: [{ path: "https://v3.fal.media/files/restore.safetensors", scale: 1 }],+ });+ expect(String(body.negative_prompt)).toContain("modern cars");+ // The gated file is never sent as its Hugging Face URL.+ expect(JSON.stringify(body)).not.toContain("huggingface.co");+ });+});diff --git a/tests/restore.test.ts b/tests/restore.test.tsnew file mode 100644index 00000000..bc303697--- /dev/null+++ b/tests/restore.test.ts@@ -0,0 +1,315 @@+import fs from "node:fs";+import path from "node:path";+import { describe, expect, it } from "vitest";+import {+ ARTEFACTS,+ cloudPieceFrames,+ cloudShape,+ framesCovered,+ offlineRestorePrompt,+ parsePromptAnswer,+ planRestore,+ refineCanvas,+ RESTORE,+ restoreCanvas,+ restoreNegative,+ restoreProblem,+ restorePrompt,+ restoreTitle,+ restoreWindows,+ tileGrid,+} from "@/lib/catalog/restore";+import { restoreGraph, restoreGraphLoras, restoreJob } from "@/lib/restore-graph";+import type { ComfyWorkflow } from "@/lib/comfy";+import { getModel, getPreset } from "@/lib/catalog";+import { onEngine } from "@/lib/catalog/engines";+import { estimateCost, planGeneration } from "@/lib/catalog/plan";++const research = JSON.parse(fs.readFileSync(path.join(__dirname, "../docs/research/fuobe-originals-recipes-5.json"), "utf8"));+const record = research.studios.find((s: { id: string }) => s.id === "archive-restore").original;++describe("Restore & colourise: the working canvas (the card's sizes)", () => {+ it("4:3 scans go to 1440x1088 and 16:9 to 1920x1088, multiples of 32, never stretched to another shape", () => {+ expect(restoreCanvas(640, 480)).toEqual({ width: 1440, height: 1088 });+ expect(restoreCanvas(720, 544)).toEqual({ width: 1440, height: 1088 });+ expect(restoreCanvas(720, 576)).toEqual({ width: 1440, height: 1152 }); // PAL 5:4: its own shape, not 4:3's+ expect(restoreCanvas(1920, 1080)).toEqual({ width: 1920, height: 1088 });+ expect(restoreCanvas(1280, 720)).toEqual({ width: 1920, height: 1088 });+ expect(restoreCanvas()).toEqual({ width: 1440, height: 1088 });+ });++ it("odd shapes keep their own: portrait mirrored, 3:2 on the narrow canvas, 2.39:1 on the wide one, 4:1 never under a tile", () => {+ expect(restoreCanvas(480, 640)).toEqual({ width: 1088, height: 1440 });+ expect(restoreCanvas(1080, 1920)).toEqual({ width: 1088, height: 1920 });+ expect(restoreCanvas(1500, 1000)).toEqual({ width: 1440, height: 960 });+ expect(restoreCanvas(1920, 804)).toEqual({ width: 1920, height: 800 });+ expect(restoreCanvas(500, 500)).toEqual({ width: 1440, height: 1440 });+ expect(restoreCanvas(2000, 500)).toEqual({ width: 2176, height: 544 });+ for (const [w, h] of [[352, 240], [768, 576], [1440, 1080], [3840, 1600], [637, 479]]) {+ const c = restoreCanvas(w, h);+ expect(c.width % 32, `${w}x${h}`).toBe(0);+ expect(c.height % 32, `${w}x${h}`).toBe(0);+ expect(Math.abs(Math.log(c.width / c.height) - Math.log(w / h)), `${w}x${h} keeps its shape`).toBeLessThan(0.035);+ }+ });++ it("tiles: 1440x1088 is the card's 2x3 grid of 960x544 tiles at 50%; stage 2 is twice the canvas with 1024x576 tiles", () => {+ expect(tileGrid({ width: 1440, height: 1088 })).toEqual({ columns: 2, rows: 3, tiles: 6 });+ expect(tileGrid({ width: 1920, height: 1088 })).toEqual({ columns: 3, rows: 3, tiles: 9 });+ expect(tileGrid({ width: 960, height: 544 })).toEqual({ columns: 1, rows: 1, tiles: 1 });+ expect(refineCanvas({ width: 1440, height: 1088 })).toEqual({ width: 2880, height: 2176 });+ expect(tileGrid(refineCanvas({ width: 1440, height: 1088 }), RESTORE.refineTile)).toEqual({ columns: 5, rows: 7, tiles: 35 });+ });++ it("holds the card's numbers the research records", () => {+ expect(record.open.tiles).toMatchObject({ width: RESTORE.tile.width, height: RESTORE.tile.height, overlap: RESTORE.overlap });+ expect(record.open.sigmas).toEqual(RESTORE.sigmas);+ expect(record.open.windows).toMatchObject({ frames: RESTORE.window, prefix: RESTORE.prefix });+ expect(record.open.stage2.tiles).toMatchObject(RESTORE.refineTile);+ expect(record.open.stage2.lora).toBe(RESTORE.loras.refine.file);+ expect(record.cloud.endpoint).toBe("fal-ai/ltx-2.3-22b/reference-video-to-video/lora");+ });+});++describe("Restore & colourise: windows and the 17-frame hand-off", () => {+ it("a short clip is one 8n+1 window; the frames past the last whole window (fewer than 8) are left out", () => {+ expect(restoreWindows(8)).toEqual([]);+ expect(restoreWindows(9)).toEqual([{ index: 0, start: 0, frames: 9, prefix: 0, keep: 9 }]);+ expect(restoreWindows(50)).toEqual([{ index: 0, start: 0, frames: 49, prefix: 0, keep: 49 }]);+ expect(restoreWindows(97)).toEqual([{ index: 0, start: 0, frames: 97, prefix: 0, keep: 97 }]);+ expect(framesCovered(restoreWindows(103))).toBe(97);+ });++ it("each next window starts 17 frames back, on the window before's last 17 restored frames, and adds up to 80", () => {+ const w = restoreWindows(545); // the card's measured 545-frame clip+ expect(w.map((x) => [x.start, x.frames, x.prefix, x.keep])).toEqual([+ [0, 97, 0, 97],+ [80, 97, 17, 80],+ [160, 97, 17, 80],+ [240, 97, 17, 80],+ [320, 97, 17, 80],+ [400, 97, 17, 80],+ [480, 65, 17, 48],+ ]);+ expect(framesCovered(w)).toBe(545);+ for (const [i, x] of w.entries()) {+ expect((x.frames - 1) % 8, `window ${i} is 8n+1`).toBe(0);+ expect(x.frames).toBeLessThanOrEqual(97);+ if (i === 0) continue;+ const prev = w[i - 1];+ // The prefix is the window before's own last 17 frames: its saved output (its kept frames) less 17.+ expect(x.start).toBe(prev.start + prev.frames - 17);+ expect(x.prefixFrom).toBe(prev.keep - 17);+ }+ });++ it("a tail of a few frames gets a short window of 17 + 8n, and covers all but fewer than 8 frames", () => {+ for (const n of [98, 105, 113, 200, 333, 1000, 2880]) {+ const w = restoreWindows(n);+ expect(n - framesCovered(w), `${n} frames`).toBeLessThan(8);+ expect(framesCovered(w), `${n} frames`).toBeGreaterThan(n - 8);+ }+ expect(restoreWindows(105).map((x) => x.frames)).toEqual([97, 25]);+ });++ it("cloud pieces are 8n+1 frames of at most 97, as even as possible", () => {+ expect(cloudPieceFrames(97)).toEqual([97]);+ expect(cloudPieceFrames(98)).toEqual([49, 49]);+ expect(cloudPieceFrames(240)).toEqual([81, 81, 73]);+ for (const n of [9, 120, 721]) for (const f of cloudPieceFrames(n)) expect((f - 1) % 8).toBe(0);+ });+});++describe("Restore & colourise: the words", () => {+ it("the card's prompt: what happens, place, period, light, materials, clothing, natural colour", () => {+ expect(+ restorePrompt({ subject: "a steam locomotive arriving at a small rural railway station", period: "1896", light: "overcast daylight", materials: "wooden station buildings", clothing: "passengers in period coats and hats" }),+ ).toBe("a steam locomotive arriving at a small rural railway station in 1896, overcast daylight, wooden station buildings, passengers in period coats and hats, natural colour");+ expect(restorePrompt({ subject: "a family meal", place: "a living room", period: "1950s" })).toBe("a family meal in a living room in 1950s, natural colour");+ expect(restorePrompt({})).toBe("the scene as it was filmed, natural colour");+ });++ it("the negative: modern things first, then the card's artefacts, each once", () => {+ const n = restoreNegative(["modern vehicles", "Logos", "logos", " signage "]);+ expect(n).toBe(["modern vehicles", "logos", "signage", ...ARTEFACTS].join(", "));+ expect(restoreNegative()).toContain("shipping containers");+ });++ it("the offline writer fills the template from a hint, with a year it finds", () => {+ const o = offlineRestorePrompt("A tram on a city street in the 1930s");+ expect(o.prompt).toMatch(/^A tram on a city street in 1930s, natural daylight, .*natural colour, sharp photographic detail, natural grain$/);+ expect(o.negative).toContain("blocky compression");+ expect(offlineRestorePrompt().prompt).toMatch(/^the scene as it was filmed, natural daylight/);+ });++ it("reads an LLM's two lines; a prompt without its ending gets natural colour, a missing one is null", () => {+ const a = parsePromptAnswer("PROMPT: a crowd at a seaside pier in the 1920s, bright summer sun, striped bathing costumes\nNEGATIVE: Cars, mobile phones, plastic chairs");+ expect(a?.prompt).toBe("a crowd at a seaside pier in the 1920s, bright summer sun, striped bathing costumes, natural colour");+ expect(a?.negative.startsWith("cars, mobile phones, plastic chairs, blocky compression")).toBe(true);+ expect(parsePromptAnswer("**PROMPT:** a horse-drawn cart on a cobbled lane, natural colour")?.negative).toContain("modern cars");+ expect(parsePromptAnswer("I can't see the frames.")).toBeNull();+ expect(restoreTitle("a horse-drawn cart on a cobbled lane in 1910, overcast, natural colour", "reel_04.mov")).toBe("Restored · A horse-drawn cart on a cobbled · reel_04");+ });+});++describe("Restore & colourise: what may run", () => {+ const src = { duration: 10, fps: 24 };+ it("refuses a clip it can't read, a clip over two minutes, a 4K pass in the cloud and an unknown cloud tier", () => {+ expect(restoreProblem({ engine: "open", source: {} })).toMatch(/Reading the clip/);+ expect(restoreProblem({ engine: "open", source: { duration: 130, fps: 24 } })).toMatch(/up to 2 minutes/);+ expect(restoreProblem({ engine: "cloud", source: src, refine: true })).toMatch(/runs on your GPU/);+ expect(restoreProblem({ engine: "cloud", source: src, resolution: "4K" })).toMatch(/720p or 1080p/);+ expect(restoreProblem({ engine: "open", source: src, refine: true })).toBeNull();+ expect(restoreProblem({ engine: "open", source: { duration: 0.2, fps: 24 } })).toMatch(/too short/);+ });+});++describe("Restore & colourise: the pipeline", () => {+ const source = { url: "/api/files/reel.mp4", duration: 545 / 24, fps: 24, width: 640, height: 480, hasAudio: true, frames: 545 };+ const words = { prompt: "a station in 1896, natural colour", negative: restoreNegative() };++ it("GPU: windows chained by their prefix, joined packet by packet, the sound put back; each window names its frames", () => {+ const plan = planRestore({ engine: "open", title: "Restored", source, ...words, deinterlace: true, seed: 7 });+ expect(plan.pieces).toBe(7);+ expect(plan.canvas).toEqual({ width: 1440, height: 1088 });+ expect(plan.dropped).toBe(0);+ const keys = plan.steps.map((s) => s.key);+ expect(keys).toEqual(["restore0", "restore1", "restore2", "restore3", "restore4", "restore5", "restore6", "join", "final"]);+ const w1 = plan.steps[1];+ expect(w1.after).toEqual(["restore0"]);+ expect(w1.chain).toEqual([{ slot: "videos", position: "first" }]);+ expect(w1.request).toMatchObject({ modelId: "fuobe-restore", engine: "open", op: "restore-video", inputs: { video: source.url }, negativePrompt: words.negative });+ expect(w1.request.params?.extra).toEqual({ stage: "restore", windowStart: 80, windowFrames: 97, prefixFrames: 17, prefixFrom: 80, canvasWidth: 1440, canvasHeight: 1088, deinterlace: true });+ expect(plan.steps[0].after).toBeUndefined();+ expect(plan.steps[0].request.params?.extra).toMatchObject({ windowStart: 0, windowFrames: 97, prefixFrames: 0 });+ const join = plan.steps.find((s) => s.key === "join")!;+ expect(join.request.modelId).toBe("oss-join-encoded");+ expect(join.after).toHaveLength(7);+ const final = plan.steps.find((s) => s.key === "final")!;+ expect(final.request).toMatchObject({ modelId: "oss-mux", op: "mux", inputs: { audio: source.url }, feature: "restore", title: "Restored" });+ expect(plan.final).toBe("final");+ // Only the finished video is a result; windows and joins are steps.+ expect(plan.steps.filter((s) => s.request.feature === "restore").map((s) => s.key)).toEqual(["final"]);+ });++ it("GPU, Restore to 4K: the joined clip again in 97-frame windows with the Detail Refine pass at twice the canvas", () => {+ const plan = planRestore({ engine: "open", title: "Restored", source: { ...source, hasAudio: false }, ...words, refine: true });+ expect(plan.refined).toEqual({ width: 2880, height: 2176 });+ const refines = plan.steps.filter((s) => s.key.startsWith("refine"));+ expect(refines.map((s) => s.request.params?.extra?.windowFrames)).toEqual([97, 89, 89, 89, 89, 89, 89].slice(0, refines.length));+ for (const r of refines) {+ expect(r.after).toEqual(["join"]);+ expect(r.chain).toEqual([{ slot: "video" }]);+ expect(r.request.params?.extra).toMatchObject({ stage: "refine", prefixFrames: 0, canvasWidth: 2880, canvasHeight: 2176 });+ }+ expect(plan.final).toBe("join4k");+ expect(plan.steps.find((s) => s.key === "join4k")!.request).toMatchObject({ modelId: "oss-join-encoded", feature: "restore" });+ expect(545 - plan.dropped).toBe(refines.reduce((n, r) => n + Number(r.request.params?.extra?.windowFrames), 0));+ });++ it("cloud: frame-exact pieces, each after the first starting from the last restored frame, joined, the sound cut to the picture", () => {+ const plan = planRestore({ engine: "cloud", title: "Restored", source: { ...source, frames: 240, duration: 10 }, ...words, resolution: "1080p" });+ expect(plan.canvas).toEqual({ width: 1440, height: 1088 });+ expect(plan.pieces).toBe(3);+ const r1 = plan.steps.find((s) => s.key === "restore1")!;+ expect(r1.after).toEqual(["cut1", "hand1"]);+ expect(r1.chain).toEqual([{ slot: "video" }, { slot: "images" }]);+ expect(r1.request.params).toMatchObject({ aspectRatio: "4:3", resolution: "1080p", fps: 24 });+ expect(plan.steps.find((s) => s.key === "hand1")!).toMatchObject({ after: ["restore0"], request: { modelId: "extract-frame", op: "frame" } });+ expect(plan.steps.find((s) => s.key === "join")!.request.modelId).toBe("join-clips");+ // 81 + 81 + 73 = 235 of 240 frames: the sound is the first 235 / 24 s.+ expect(plan.dropped).toBe(5);+ const cut = plan.steps.find((s) => s.key === "sound")!.request.params!;+ expect(cut.startTime).toBe(0);+ expect(cut.endTime).toBeCloseTo(235 / 24, 5);+ expect(plan.steps.find((s) => s.key === "final")!.request.modelId).toBe("merge-audio-video");+ });++ it("cloud: a clip of one whole piece runs as it is; its shape picks the tier's size", () => {+ const plan = planRestore({ engine: "cloud", title: "R", source: { url: "/api/files/a.mp4", duration: 97 / 24, frames: 97, fps: 24, width: 1280, height: 720, hasAudio: false }, ...words });+ expect(plan.steps.map((s) => s.key)).toEqual(["restore0"]);+ expect(plan.steps[0].request).toMatchObject({ inputs: { video: "/api/files/a.mp4" }, params: { aspectRatio: "16:9", resolution: "720p" }, feature: "restore" });+ expect(plan.canvas).toEqual({ width: 1280, height: 704 });+ expect(cloudShape(720, 576)).toBe("4:3");+ });++ it("prices a cloud piece per megapixel of video on the LoRA endpoint; free on the GPU", () => {+ const m = getModel("fuobe-restore")!;+ const cloud = onEngine(m, "cloud");+ // 97 frames at 1024x768: 76.3 MP → 77 MP at $0.001805.+ expect(estimateCost(cloud, { aspectRatio: "4:3", resolution: "720p", fps: 24, duration: 97 / 24, sourceDuration: 97 / 24 }, 1, "restore-video", true)).toBeCloseTo(77 * 0.001805, 3);+ expect(estimateCost(onEngine(m, "open"), { sourceDuration: 4 }, 1, "restore-video")).toBe(0);+ });+});++describe("Fuobe Restore in the catalog", () => {+ it("an Original on both engines: the GPU graph and fal's LTX-2.3 reference video to video with the Restore LoRA", () => {+ const m = getModel("fuobe-restore")!;+ expect(m.engines).toEqual(["open", "cloud"]);+ expect(m.routes.map((r) => [r.op, r.provider, r.endpoint])).toEqual([+ ["restore-video", "comfyui", RESTORE.workflow],+ ["restore-video", "fal", "fal-ai/ltx-2.3-22b/reference-video-to-video/lora"],+ ]);+ const fal = m.routes[1].map!;+ expect(fal.video).toBe("video_url");+ expect(fal.image).toBe("image_url");+ expect(fal.fixed).toMatchObject({ ic_lora_type: "none", preprocessor: "none", generate_audio: false, enable_prompt_expansion: false });+ expect(fal.loras).toMatchObject({ shape: "items", key: "loras", required: true });+ // The GPU graph loads its LoRA itself; the cloud carries it as a LoRA (Fuobe's mirror of the gated file).+ expect(onEngine(m, "open").options.loras).toBeUndefined();+ expect(onEngine(m, "cloud").options.loras?.map((l) => l.file)).toEqual([RESTORE.loras.restore.file]);+ });++ it("plans a single run from its clip alone (the words are optional) and says what to add without one", () => {+ const m = getModel("fuobe-restore")!;+ const open = (id: string) => (id === m.id ? onEngine(m, "open") : getModel(id));+ const p = planGeneration({ feature: "restore", modelId: m.id, inputs: { video: "/api/files/a.mp4" } }, open, getPreset);+ expect(p.op).toBe("restore-video");+ expect(p.prompt).toMatch(/natural colour/);+ expect(() => planGeneration({ feature: "restore", modelId: m.id, prompt: "x" }, open, getPreset)).toThrow(/archive clip to restore/);+ });+});++describe("Restore & colourise: one run of the GPU graph", () => {+ const clip = { width: 640, height: 480, fps: 24, frames: 545, duration: 545 / 24 };+ it("a planned window: its frames, the canvas, the prefix from the window before, the Restore LoRA and 960x544 tiles", () => {+ const j = restoreJob({ extra: { windowStart: 80, windowFrames: 97, prefixFrames: 17, prefixFrom: 80, canvasWidth: 1440, canvasHeight: 1088 }, clip, prefixVideo: "prev.mp4" });+ expect(j).toMatchObject({ prefix: true, reference: false, deinterlace: false, stage: "restore" });+ expect(j.values).toMatchObject({ windowStart: 80, windowFrames: 97, prefixFrames: 17, prefixFrom: 80, canvasWidth: 1440, canvasHeight: 1088, lora: RESTORE.loras.restore.file, tileWidth: 960, tileHeight: 544, streaming: false, tileFrames: 0, fps: 24, cfg: 1 });+ });++ it("a whole clip on its own: one pass up to 97 frames, the sampler's streaming windows past that, up to 481", () => {+ expect(restoreJob({ extra: {}, clip: { ...clip, frames: 60 } }).values).toMatchObject({ windowFrames: 57, streaming: false, tileFrames: 0 });+ expect(restoreJob({ extra: {}, clip: { ...clip, frames: 300 } }).values).toMatchObject({ windowFrames: 297, streaming: true, tileFrames: 97 });+ expect(() => restoreJob({ extra: {}, clip })).toThrow(/Video tools → Restore & colourise/);+ expect(() => restoreJob({ extra: {}, clip: { ...clip, frames: 300 }, reference: "ref.png" })).toThrow(/one window/);+ expect(() => restoreJob({ extra: {}, clip: { width: 640, height: 480 } })).toThrow(/frame rate/);+ });++ it("stage 2: the Detail Refine LoRA, 1024x576 tiles, twice the restored clip; deinterlacing keeps one field", () => {+ const r = restoreJob({ extra: { stage: "refine" }, clip: { width: 1440, height: 1088, fps: 24, frames: 97 } });+ expect(r.values).toMatchObject({ lora: RESTORE.loras.refine.file, tileWidth: 1024, tileHeight: 576, canvasWidth: 2880, canvasHeight: 2176 });+ const d = restoreJob({ extra: { deinterlace: true }, clip: { ...clip, frames: 49 } });+ expect(d.values).toMatchObject({ fieldWidth: 640, fieldHeight: 240 });+ expect(() => restoreJob({ extra: { windowFrames: 96 }, clip })).toThrow(/8n\+1/);+ expect(() => restoreJob({ extra: { windowFrames: 97, prefixFrames: 17, prefixFrom: 80 }, clip })).toThrow(/hasn't finished/);+ });++ it("downloads the LoRA the graph loads: Restore, or Detail Refine for stage 2 (both gated, pinned)", () => {+ expect(restoreGraphLoras(RESTORE.workflow, {}).map((l) => [l.file, l.version])).toEqual([[RESTORE.loras.restore.file, "79245e197a6cd3251e77d178dc380b0e9f2d6563"]]);+ expect(restoreGraphLoras(RESTORE.workflow, { stage: "refine" }).map((l) => l.file)).toEqual([RESTORE.loras.refine.file]);+ expect(restoreGraphLoras("ltx25-i2v", {})).toEqual([]);+ });++ it("takes out the branches a run doesn't use and links around them", () => {+ const wf = JSON.parse(fs.readFileSync(path.join(__dirname, "../workflows/comfyui/video-restore-ltx25-tiled.json"), "utf8")) as ComfyWorkflow;+ const first = restoreGraph(wf, { prefix: false, reference: false, deinterlace: false }, ["save"]);+ for (const gone of ["prefix", "prefix_source", "reference", "reference_fit", "reference_guide", "field"]) expect(first[gone], gone).toBeUndefined();+ expect(first.sample.inputs).toMatchObject({ positive: ["guide", 0], negative: ["guide", 1], latents: ["guide", 2] });+ expect(first.canvas.inputs.image).toEqual(["source", 0]);+ const all = restoreGraph(wf, { prefix: true, reference: true, deinterlace: true }, ["save"]);+ expect(Object.keys(all).sort()).toEqual(Object.keys(wf).sort());+ const prefixOnly = restoreGraph(wf, { prefix: true, reference: false, deinterlace: false }, ["save"]);+ expect(prefixOnly.sample.inputs).toMatchObject({ positive: ["prefix", 0], negative: ["prefix", 1], latents: ["prefix", 2] });+ });+});diff --git a/workflows/comfyui/manifest.json b/workflows/comfyui/manifest.jsonindex 1b7421b0..8bfffef3 100644--- a/workflows/comfyui/manifest.json+++ b/workflows/comfyui/manifest.json@@ -1,6 +1,6 @@{"version": 1,- "generatedAt": "2026-10-30T09:34:19.291Z",+ "generatedAt": "2026-10-30T14:26:09.729Z","comfyuiCommit": "fc04da91b2ab12f99e4716371a7e4f98ac982597","comfyuiVersion": "0.41.0","workflowTemplatesVersion": "0.11.86",@@ -9681,6 +9681,261 @@"validated": true,"notes": "ltx23-i2v-lora without the start frame: the empty latent takes width x height directly. LoRAs injected after the CheckpointLoaderSimple. Silent (the audio is not decoded). Not used by a catalog model yet (build plan O4 lists it for LTX camera LoRAs without a start frame)."},+ {+ "id": "video-restore-ltx25-tiled",+ "title": "Restore & colourise archive footage: LTX-2.5 22B distilled + the Restore IC-LoRA, tiled latent fusion, one 97-frame window with the 17-frame prefix hand-off (stage 2: the Detail Refine IC-LoRA) (ComfyUI-LTXVideo pack)",+ "capability": "restore-video",+ "file": "video-restore-ltx25-tiled.json",+ "source": "hand-built (scripts/comfy/hand-built/video-restore-ltx25-tiled.json)",+ "bindings": {+ "video": [+ {+ "node": "source",+ "input": "video"+ }+ ],+ "video2": [+ {+ "node": "prefix_source",+ "input": "video"+ }+ ],+ "image": [+ {+ "node": "reference",+ "input": "image"+ }+ ],+ "prompt": [+ {+ "node": "positive",+ "input": "text"+ }+ ],+ "negativePrompt": [+ {+ "node": "negative",+ "input": "text"+ }+ ],+ "seed": [+ {+ "node": "sample",+ "input": "seed"+ }+ ],+ "cfg": [+ {+ "node": "sample",+ "input": "cfg"+ }+ ],+ "fps": [+ {+ "node": "conditioning",+ "input": "frame_rate"+ },+ {+ "node": "video",+ "input": "fps"+ }+ ],+ "windowStart": [+ {+ "node": "source",+ "input": "skip_first_frames"+ }+ ],+ "windowFrames": [+ {+ "node": "source",+ "input": "frame_load_cap"+ },+ {+ "node": "empty",+ "input": "length"+ }+ ],+ "canvasWidth": [+ {+ "node": "canvas",+ "input": "width"+ },+ {+ "node": "empty",+ "input": "width"+ },+ {+ "node": "reference_fit",+ "input": "width"+ }+ ],+ "canvasHeight": [+ {+ "node": "canvas",+ "input": "height"+ },+ {+ "node": "empty",+ "input": "height"+ },+ {+ "node": "reference_fit",+ "input": "height"+ }+ ],+ "fieldWidth": [+ {+ "node": "field",+ "input": "width"+ }+ ],+ "fieldHeight": [+ {+ "node": "field",+ "input": "height"+ }+ ],+ "prefixFrom": [+ {+ "node": "prefix_source",+ "input": "skip_first_frames"+ }+ ],+ "prefixFrames": [+ {+ "node": "keep",+ "input": "batch_index"+ }+ ],+ "lora": [+ {+ "node": "lora",+ "input": "lora_name"+ }+ ],+ "loraStrength": [+ {+ "node": "lora",+ "input": "strength_model"+ }+ ],+ "tileWidth": [+ {+ "node": "sample",+ "input": "tile_width"+ }+ ],+ "tileHeight": [+ {+ "node": "sample",+ "input": "tile_height"+ }+ ],+ "streaming": [+ {+ "node": "guide",+ "input": "use_streaming"+ }+ ],+ "tileFrames": [+ {+ "node": "sample",+ "input": "tile_frames"+ }+ ],+ "filenamePrefix": [+ {+ "node": "save",+ "input": "filename_prefix"+ }+ ]+ },+ "outputs": [+ {+ "node": "save",+ "kind": "video"+ }+ ],+ "defaults": {+ "fps": 24,+ "cfg": 1,+ "loraStrength": 1,+ "windowStart": 0,+ "windowFrames": 97,+ "prefixFrames": 0,+ "canvasWidth": 1440,+ "canvasHeight": 1088,+ "tileWidth": 960,+ "tileHeight": 544,+ "tileFrames": 0,+ "frameStep": 8,+ "lora": "ltx-2.5-22b-ic-lora-restore-1.0.safetensors",+ "prefixFrom": 80,+ "fieldWidth": 640,+ "fieldHeight": 240,+ "streaming": false+ },+ "limits": {+ "maxWidth": 3840,+ "maxHeight": 3840,+ "maxFrames": 481,+ "dimensionMultiple": 32+ },+ "models": [+ {+ "file": "ltx-2.5-22b-ic-lora-restore-1.0.safetensors",+ "folder": "loras",+ "url": "https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Restore/resolve/79245e197a6cd3251e77d178dc380b0e9f2d6563/ltx-2.5-22b-ic-lora-restore-1.0.safetensors",+ "sizeGb": 1.71,+ "gated": true+ },+ {+ "file": "gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors",+ "folder": "text_encoders",+ "url": "https://huggingface.co/Lightricks/LTX-2.5/resolve/main/text_encoders/gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors",+ "sizeGb": 15.37,+ "gated": true+ },+ {+ "file": "ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",+ "folder": "diffusion_models",+ "url": "https://huggingface.co/Lightricks/LTX-2.5/resolve/main/diffusion_models/ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",+ "sizeGb": 21.5,+ "gated": true+ },+ {+ "file": "ltx-2.5-video-vae-bf16.safetensors",+ "folder": "vae",+ "url": "https://huggingface.co/Lightricks/LTX-2.5/resolve/main/vae/ltx-2.5-video-vae-bf16.safetensors",+ "sizeGb": 1.47,+ "gated": true+ },+ {+ "file": "ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors",+ "folder": "loras",+ "url": "https://huggingface.co/Lightricks/LTX-2.5-22b-IC-LoRA-Refine-Details/resolve/4912c478b35dd96b6cdcc5f7c7ff9d72c2c57929/ltx-2.5-22b-ic-lora-refine-details-1.0.safetensors",+ "sizeGb": 1.31,+ "gated": true,+ "optional": true+ }+ ],+ "customNodes": [+ {+ "name": "ComfyUI-LTXVideo",+ "repo": "https://github.com/Lightricks/ComfyUI-LTXVideo/tree/220e1d45aa0469f518e982102fca4dca92a61862"+ },+ {+ "name": "ComfyUI-VideoHelperSuite",+ "repo": "https://github.com/Kosinkadink/ComfyUI-VideoHelperSuite"+ }+ ],+ "vramGb": 24,+ "license": "LTX-2.x Community License (LTX-2.5 22B distilled, its video VAE, and Lightricks' Restore and Detail Refine IC-LoRAs, both gated on Hugging Face: free under US$10M annual revenue); Gemma 4 text encoder packaged by Lightricks; ComfyUI-LTXVideo nodes under the LTX-2 Community License (its LICENSE file)",+ "validated": false,+ "notes": "Built from the Restore IC-LoRA card's recipe (Hugging Face Lightricks/LTX-2.5-22b-IC-LoRA-Restore at 79245e1, read as data) and the node definitions of ComfyUI-LTXVideo at 220e1d4 (its LTX-2.5_V2V_TiledFusion_Upscale example wires the same nodes): the window (windowStart, windowFrames: 8n+1, at most 97) read at the clip's own rate, lanczos to the canvas (canvasWidth x canvasHeight: 1440x1088 for 4:3, 1920x1088 for 16:9), the frame-aligned IC-LoRA guide at downscale 1, LTXVTiledFusionSampler with 960x544 tiles at 50% overlap and the 8 distilled sigmas (euler, cfg 1), tiled decode, silent H.264 (the pipeline puts the sound back after the join). video2 = the window before's saved frames; its last 17 (prefixFrom) go in as LTXVAddGuide at frame 0, and prefixFrames (17) drops them from this window's output; absent on the first window (the provider removes that branch). image = an optional reference picture at frame_idx -1 (a second IC-LoRA guide; removed without one). deinterlace keeps one field (fieldWidth x fieldHeight, nearest rows: no blending; ComfyUI has no fieldmatch/yadif/decimate node), removed when off. Stage 2 (Restore to 4K): the same graph on the restored clip with the Detail Refine IC-LoRA, a 2x canvas and 1024x576 tiles. A single generation of a whole clip past 97 frames streams: streaming on the guide and tileFrames 97 on the sampler (the card's other long-clip path; no reference picture there). Needs the ComfyUI-LTXVideo pack. Not validated here: the pack is not installed on this server.",+ "validationError": "HTTP 400: missing_node_type: Node 'the archive clip as the frame-aligned IC-LoRA reference (downscale 1, untiled encode); use_streaming only for a whole clip past 97 frames' not found. The custom node may not be installed. (Node ID '#guide')"+ },{"id": "video-trim","title": "Trim a clip by seconds (core Trim Video, keeps fps and audio)",diff --git a/workflows/comfyui/object_info.subset.json b/workflows/comfyui/object_info.subset.jsonindex 2dc751fe..0711f0d0 100644--- a/workflows/comfyui/object_info.subset.json+++ b/workflows/comfyui/object_info.subset.json@@ -8755,6 +8755,8 @@"essentials_category": null,"has_intermediate_output": false},+ "LTXAddVideoICLoRAGuide": null,+ "LTXICLoRALoaderModelOnly": null,"LTXVAddGuide": {"input": {"required": {@@ -9614,6 +9616,7 @@"essentials_category": null,"has_intermediate_output": false},+ "LTXVTiledFusionSampler": null,"LatentBatchSeedBehavior": {"input": {"required": {diff --git a/workflows/comfyui/video-restore-ltx25-tiled.json b/workflows/comfyui/video-restore-ltx25-tiled.jsonnew file mode 100644index 00000000..5b900c00--- /dev/null+++ b/workflows/comfyui/video-restore-ltx25-tiled.json@@ -0,0 +1,429 @@+{+ "canvas": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "field",+ 0+ ],+ "upscale_method": "lanczos",+ "width": 1440,+ "height": 1088,+ "crop": "disabled"+ },+ "_meta": {+ "title": "lanczos to the working canvas (1440 wide for 4:3, 1920x1088 for 16:9; the shape kept, multiples of 32): the guide never sees the small scan"+ }+ },+ "conditioning": {+ "class_type": "LTXVConditioning",+ "inputs": {+ "positive": [+ "positive",+ 0+ ],+ "negative": [+ "negative",+ 0+ ],+ "frame_rate": 24+ },+ "_meta": {+ "title": "the clip's own frame rate"+ }+ },+ "decode": {+ "class_type": "VAEDecodeTiled",+ "inputs": {+ "samples": [+ "sample",+ 0+ ],+ "vae": [+ "vae",+ 0+ ],+ "tile_size": 512,+ "overlap": 64,+ "temporal_size": 64,+ "temporal_overlap": 8+ },+ "_meta": {+ "title": "tiled decode"+ }+ },+ "empty": {+ "class_type": "EmptyLTXVLatentVideo",+ "inputs": {+ "width": 1440,+ "height": 1088,+ "length": 97,+ "batch_size": 1+ },+ "_meta": {+ "title": "the canvas, the window's frames (8n+1)"+ }+ },+ "field": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "source",+ 0+ ],+ "upscale_method": "nearest-exact",+ "width": 640,+ "height": 240,+ "crop": "disabled"+ },+ "_meta": {+ "title": "deinterlace (optional): one field, every other row (nearest, no blending); the canvas resize rebuilds the height. The provider removes it when off"+ }+ },+ "guide": {+ "class_type": "LTXAddVideoICLoRAGuide",+ "inputs": {+ "positive": [+ "conditioning",+ 0+ ],+ "negative": [+ "conditioning",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "empty",+ 0+ ],+ "image": [+ "canvas",+ 0+ ],+ "frame_idx": 0,+ "strength": 1,+ "latent_downscale_factor": [+ "lora",+ 1+ ],+ "crop": "disabled",+ "use_tiled_encode": false,+ "tile_size": 256,+ "tile_overlap": 64,+ "use_streaming": false,+ "tile_frames": 97+ },+ "_meta": {+ "title": "the archive clip as the frame-aligned IC-LoRA reference (downscale 1, untiled encode); use_streaming only for a whole clip past 97 frames"+ }+ },+ "keep": {+ "class_type": "ImageFromBatch",+ "inputs": {+ "image": [+ "decode",+ 0+ ],+ "batch_index": 0,+ "length": 4096+ },+ "_meta": {+ "title": "the window's own frames: from prefixFrames on (the prefix the window before already made is dropped)"+ }+ },+ "lora": {+ "class_type": "LTXICLoRALoaderModelOnly",+ "inputs": {+ "model": [+ "unet",+ 0+ ],+ "lora_name": "ltx-2.5-22b-ic-lora-restore-1.0.safetensors",+ "strength_model": 1+ },+ "_meta": {+ "title": "the Restore IC-LoRA at 1.0 (a switch: 0.7 stays monochrome, 1.4 over-tints); the Detail Refine IC-LoRA for stage 2. Its latent_downscale_factor (1) feeds the guides"+ }+ },+ "negative": {+ "class_type": "CLIPTextEncode",+ "inputs": {+ "text": "modern cars, modern buildings, shipping containers, logos, signage, lettering, graffiti, blocky compression, banding, mosquito noise, ringing, blurry, smeared, ghosting, low resolution",+ "clip": [+ "text",+ 0+ ]+ },+ "_meta": {+ "title": "what it must not invent, and the damage"+ }+ },+ "positive": {+ "class_type": "CLIPTextEncode",+ "inputs": {+ "text": "a steam locomotive arriving at a small rural railway station in 1896, passengers in period coats and hats waiting on the platform, wooden station buildings, natural colour",+ "clip": [+ "text",+ 0+ ]+ },+ "_meta": {+ "title": "period, place, light, materials, clothing, natural colour"+ }+ },+ "prefix": {+ "class_type": "LTXVAddGuide",+ "inputs": {+ "positive": [+ "guide",+ 0+ ],+ "negative": [+ "guide",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "guide",+ 2+ ],+ "image": [+ "prefix_source",+ 0+ ],+ "frame_idx": 0,+ "strength": 1+ },+ "_meta": {+ "title": "prefix at frame 0: the model continues from the restored frames, so colour holds across windows"+ }+ },+ "prefix_source": {+ "class_type": "VHS_LoadVideo",+ "inputs": {+ "video": "previous_window.mp4",+ "force_rate": 0,+ "custom_width": 0,+ "custom_height": 0,+ "frame_load_cap": 17,+ "skip_first_frames": 80,+ "select_every_nth": 1,+ "format": "None"+ },+ "_meta": {+ "title": "the window before's last 17 restored frames (prefix hand-off); the provider removes this branch on the first window"+ }+ },+ "reference": {+ "class_type": "LoadImage",+ "inputs": {+ "image": "reference.png"+ },+ "_meta": {+ "title": "reference picture (optional): native crops of faces, signs or true colours on grey, or a colour photo framed like the clip"+ }+ },+ "reference_fit": {+ "class_type": "ImageScale",+ "inputs": {+ "image": [+ "reference",+ 0+ ],+ "upscale_method": "lanczos",+ "width": 1440,+ "height": 1088,+ "crop": "center"+ },+ "_meta": {+ "title": "the reference on the canvas (it is cropped per tile like the clip)"+ }+ },+ "reference_guide": {+ "class_type": "LTXAddVideoICLoRAGuide",+ "inputs": {+ "positive": [+ "prefix",+ 0+ ],+ "negative": [+ "prefix",+ 1+ ],+ "vae": [+ "vae",+ 0+ ],+ "latent": [+ "prefix",+ 2+ ],+ "image": [+ "reference_fit",+ 0+ ],+ "frame_idx": -1,+ "strength": 1,+ "latent_downscale_factor": [+ "lora",+ 1+ ],+ "crop": "disabled",+ "use_tiled_encode": false,+ "tile_size": 256,+ "tile_overlap": 64,+ "use_streaming": false,+ "tile_frames": 97+ },+ "_meta": {+ "title": "a second IC-LoRA guide at frame_idx -1 (before the clip, not in its first slot); the provider removes this branch without a reference"+ }+ },+ "sample": {+ "class_type": "LTXVTiledFusionSampler",+ "inputs": {+ "model": [+ "lora",+ 0+ ],+ "positive": [+ "reference_guide",+ 0+ ],+ "negative": [+ "reference_guide",+ 1+ ],+ "latents": [+ "reference_guide",+ 2+ ],+ "sigmas": [+ "sigmas",+ 0+ ],+ "sampler": [+ "sampler_select",+ 0+ ],+ "seed": 42,+ "cfg": 1,+ "tile_width": 960,+ "tile_height": 544,+ "overlap_frac": 0.5,+ "blend_var": 0.05,+ "grid_cycle": 1,+ "tile_frames": 0,+ "vae": [+ "vae",+ 0+ ],+ "canvas_device": "auto"+ },+ "_meta": {+ "title": "per-step tiled latent fusion: 960x544 tiles at 50% overlap (1024x576 for stage 2), guidance 1.0; tile_frames 97 only with a streaming guide"+ }+ },+ "sampler_select": {+ "class_type": "KSamplerSelect",+ "inputs": {+ "sampler_name": "euler"+ },+ "_meta": {+ "title": "euler (fusion owns the sigma loop)"+ }+ },+ "save": {+ "class_type": "SaveVideo",+ "inputs": {+ "video": [+ "video",+ 0+ ],+ "filename_prefix": "fuobe/video-restore-ltx25-tiled",+ "format": "auto",+ "format.codec": "auto",+ "codec": "auto"+ },+ "_meta": {+ "title": "SaveVideo"+ }+ },+ "sigmas": {+ "class_type": "ManualSigmas",+ "inputs": {+ "sigmas": "1.0, 0.99375, 0.9875, 0.98125, 0.975, 0.909375, 0.725, 0.421875, 0.0"+ },+ "_meta": {+ "title": "the card's 8 distilled steps"+ }+ },+ "source": {+ "class_type": "VHS_LoadVideo",+ "inputs": {+ "video": "archive.mp4",+ "force_rate": 0,+ "custom_width": 0,+ "custom_height": 0,+ "frame_load_cap": 97,+ "skip_first_frames": 0,+ "select_every_nth": 1,+ "format": "None"+ },+ "_meta": {+ "title": "the window: frame_load_cap frames from skip_first_frames, at the clip's own rate (no resample, no 8n+1 cut: the plan's windows are 8n+1)"+ }+ },+ "text": {+ "class_type": "CLIPLoader",+ "inputs": {+ "clip_name": "gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors",+ "type": "ltxv",+ "device": "default"+ },+ "_meta": {+ "title": "Gemma 4 12B text encoder"+ }+ },+ "unet": {+ "class_type": "UNETLoader",+ "inputs": {+ "unet_name": "ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors",+ "weight_dtype": "default"+ },+ "_meta": {+ "title": "LTX-2.5 22B distilled"+ }+ },+ "vae": {+ "class_type": "VAELoader",+ "inputs": {+ "vae_name": "ltx-2.5-video-vae-bf16.safetensors"+ },+ "_meta": {+ "title": "LTX-2.5 video VAE"+ }+ },+ "video": {+ "class_type": "CreateVideo",+ "inputs": {+ "images": [+ "keep",+ 0+ ],+ "fps": 24,+ "bit_depth": "auto",+ "color_space": "sRGB",+ "codec": "none"+ },+ "_meta": {+ "title": "silent: the pipeline puts the clip's own sound back after the join"+ }+ }+}