@melite/models-h3 0.1.4-alpha → 0.2.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +561 -457
- package/README.md +39 -0
- package/lib/actions.d.ts +91 -17
- package/lib/actions.js +1472 -187
- package/lib/chainEdit.d.ts +187 -0
- package/lib/chainEdit.js +330 -0
- package/lib/chainUpscale.d.ts +25 -0
- package/lib/chainUpscale.js +134 -0
- package/lib/extend.d.ts +17 -0
- package/lib/extend.js +174 -0
- package/lib/filmMix.d.ts +24 -10
- package/lib/filmMix.js +30 -14
- package/lib/index.d.ts +14 -1
- package/lib/index.js +296 -186
- package/lib/mods/loras.d.ts +19 -88
- package/lib/mods/loras.js +38 -9
- package/lib/refine.d.ts +123 -0
- package/lib/refine.js +301 -0
- package/lib/repair.d.ts +15 -0
- package/lib/repair.js +164 -0
- package/lib/reshoot.d.ts +201 -0
- package/lib/reshoot.js +352 -0
- package/lib/schema.d.ts +92 -13
- package/lib/schema.js +355 -45
- package/lib/swap.d.ts +14 -0
- package/lib/swap.js +95 -0
- package/lib/timelineContract.d.ts +164 -1
- package/lib/timelineContract.js +220 -4
- package/lib/windowSpec.d.ts +23 -0
- package/lib/windowSpec.js +49 -0
- package/package.json +9 -8
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { GraphBuilder, OutputHandle } from '@melite/comfyui-card-kit/graph';
|
|
2
|
+
import type { H3Facts } from './actions.js';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export declare const loadVideo: (g: GraphBuilder, path: string, frameLoadCap?: number, skipFirstFrames?: number) => OutputHandle[];
|
|
16
|
+
export declare const RESOLUTION_SHORT_EDGE: Readonly<Record<string, number>>;
|
|
17
|
+
/** The engine's plan_clips shape math, ported (ext lines 270-273):
|
|
18
|
+
* scale the source by shortEdge/min(w,h), snap both edges to 32
|
|
19
|
+
* (round), floor 32. Cited, never re-derived — an engine-side move
|
|
20
|
+
* of this math must update this port or the admission lies. */
|
|
21
|
+
export declare const planTierShape: (width: number, height: number, shortEdge: number) => {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
/** THE CROSS-REGIME JOIN ADMISSION: given the film regime's shape
|
|
26
|
+
* (the doc's width/height — the shape this estate's film arm
|
|
27
|
+
* renders and the join appends onto) and the mod bag's tier, answer
|
|
28
|
+
* the admission text when the tier would render a DIFFERENT shape,
|
|
29
|
+
* null when the join is shape-true. The text names both regimes,
|
|
30
|
+
* the engine-derived mod shape, and the pin (the tier whose short
|
|
31
|
+
* edge matches the film's — 768p for the film regime's 768 short
|
|
32
|
+
* edge — or the plan node's short_edge knob for any other shape).
|
|
33
|
+
* @param filmWidth the film regime's width (the doc knob)
|
|
34
|
+
* @param filmHeight the film regime's height (the doc knob)
|
|
35
|
+
* @param tier the mod bag's resolution tier (e.g. '736p')
|
|
36
|
+
* @returns the admission warning text, or null when shapes agree */
|
|
37
|
+
export declare const admitCrossRegimeJoin: (filmWidth: number, filmHeight: number, tier: string) => string | null;
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export declare const h3MaskedEditPlane: (g: GraphBuilder, p: Record<string, unknown>, facts: H3Facts, clipSeconds: number) => {
|
|
57
|
+
sigmaModel: OutputHandle;
|
|
58
|
+
samplerSel: OutputHandle;
|
|
59
|
+
clip: OutputHandle;
|
|
60
|
+
vaeVideo: OutputHandle;
|
|
61
|
+
vaeAudio: OutputHandle;
|
|
62
|
+
};
|
|
63
|
+
/** What the seat's body callback receives: the ChainCurrent node
|
|
64
|
+
* (its .out(k) seats), the plane's encoders/decoders, the muted
|
|
65
|
+
* chain audio (the r2v ref_video_audios seat), and the window's own
|
|
66
|
+
* frames + muted slice audio (the H3SourceSlice seats). */
|
|
67
|
+
export interface ChainBodyHandles {
|
|
68
|
+
/** MiniMaxH3ChainCurrent — out(0) state, out(5) seed, out(6)
|
|
69
|
+
* length, out(7) steps, out(8)/out(9) width/height, out(12) the
|
|
70
|
+
* chain's carried audio. */
|
|
71
|
+
readonly cur: {
|
|
72
|
+
out(k: number): OutputHandle;
|
|
73
|
+
};
|
|
74
|
+
readonly clip: OutputHandle;
|
|
75
|
+
readonly vaeVideo: OutputHandle;
|
|
76
|
+
readonly vaeAudio: OutputHandle;
|
|
77
|
+
/** the chain's carried audio, muted −100dB (the r2v audio ref). */
|
|
78
|
+
readonly mutedChainAudio: OutputHandle;
|
|
79
|
+
/** the window's frames (the seat's loader, slot 0). */
|
|
80
|
+
readonly srcFrames: OutputHandle;
|
|
81
|
+
/** the window's source audio, muted (the slice's audio seat). */
|
|
82
|
+
readonly sliceAudio: OutputHandle;
|
|
83
|
+
}
|
|
84
|
+
/** The seat's masked-edit body: the nodes between ChainCurrent and
|
|
85
|
+
* ChainContext — the r2v anchors, the source slice, the edit latent,
|
|
86
|
+
* the masked target. Returns the two wires ChainContext consumes. */
|
|
87
|
+
export type ChainBody = (h: ChainBodyHandles) => {
|
|
88
|
+
/** the r2v's conditioning output. */
|
|
89
|
+
readonly conditioning: OutputHandle;
|
|
90
|
+
/** the ContexMaskedTarget's output. */
|
|
91
|
+
readonly targetLatent: OutputHandle;
|
|
92
|
+
};
|
|
93
|
+
/** The terminal: ChainAssemble's config, or null when the seat joins
|
|
94
|
+
* by file instead (the single-window extend posture). */
|
|
95
|
+
export interface ChainAssembleSeat {
|
|
96
|
+
/** 'source' keeps the source soundtrack; 'generated' assembles the
|
|
97
|
+
* checkpointed H3 sound. */
|
|
98
|
+
readonly audioSource: 'source' | 'generated';
|
|
99
|
+
/** the assemble basename (the `<runId>/<kind>` prefix). */
|
|
100
|
+
readonly filename: string;
|
|
101
|
+
}
|
|
102
|
+
/** ONE masked-edit chain seat — every delta the spine does not own.
|
|
103
|
+
* The seat validates its own entry, loads its own media, derives its
|
|
104
|
+
* own mask, and hands the body callback; the spine emits everything
|
|
105
|
+
* else with the seats' historical parameters verbatim. */
|
|
106
|
+
export interface MaskedChainSeat {
|
|
107
|
+
/** the walked doc params (the lora mod bag + SLA/shift knobs). */
|
|
108
|
+
readonly p: Record<string, unknown>;
|
|
109
|
+
/** the family's lane facts (unet off the DECL row). */
|
|
110
|
+
readonly facts: H3Facts;
|
|
111
|
+
/** the per-window clip budget (the plane's preview + the plan's
|
|
112
|
+
* default duration; for multi-window seats this is ONE window's
|
|
113
|
+
* seconds, never the total). */
|
|
114
|
+
readonly clipSeconds: number;
|
|
115
|
+
/** the plan node's overlap knob (the seat's entry default 39). */
|
|
116
|
+
readonly overlapFrames: number;
|
|
117
|
+
readonly resolution: string;
|
|
118
|
+
readonly seed: number;
|
|
119
|
+
readonly steps: number;
|
|
120
|
+
/** the swap's roles text ('' on repair/extend). */
|
|
121
|
+
readonly roles: string;
|
|
122
|
+
/** the staged source leaf (loader + timeline + lazy video wire). */
|
|
123
|
+
readonly sourceClip: string;
|
|
124
|
+
/** the window's start frame (repair's seat; 0 otherwise). */
|
|
125
|
+
readonly windowStart: number;
|
|
126
|
+
/** the staged picture_1 — the plan's geometry anchor. */
|
|
127
|
+
readonly picture1: OutputHandle;
|
|
128
|
+
/** the window's frames + audio (the seat's loadVideo call). */
|
|
129
|
+
readonly srcFrames: OutputHandle;
|
|
130
|
+
readonly srcAudio: OutputHandle;
|
|
131
|
+
/** the literal plan_json — REQUIRED by ChainPlanModern. When
|
|
132
|
+
* planFromSource is true it is the ignored fallback (the swap and
|
|
133
|
+
* repair ride the plan node's engine-derived shots); when false it
|
|
134
|
+
* IS the plan (the extend cure: the seat's own continuation shots
|
|
135
|
+
* rule — a raw prior is never re-sliced, §3 of the design). */
|
|
136
|
+
readonly planJson: string;
|
|
137
|
+
/** true wires plan_json_input from the plan node (source slicing —
|
|
138
|
+
* the swap/repair semantics); false leaves the literal ruling. */
|
|
139
|
+
readonly planFromSource: boolean;
|
|
140
|
+
/** the scheduler denoise: 1 fresh (swap/extend), partial refine
|
|
141
|
+
* (repair — its own law refuses >= 1 at the seat's door). */
|
|
142
|
+
readonly denoise: number;
|
|
143
|
+
/** the seat's masked-edit body. */
|
|
144
|
+
readonly body: ChainBody;
|
|
145
|
+
/** the ChainAssemble terminal, or null (file-join posture). */
|
|
146
|
+
readonly assemble: ChainAssembleSeat | null;
|
|
147
|
+
}
|
|
148
|
+
/** The spine's returned handles: the loop-trimmed window (the seat's
|
|
149
|
+
* file join consumes its streams) and, when assembled, the
|
|
150
|
+
* ChainAssemble node's video_path (the assembled film's absolute
|
|
151
|
+
* path — the compose join's append member). */
|
|
152
|
+
export interface ChainRender {
|
|
153
|
+
/** MiniMaxH3LoopTrim — out(0) frames, out(1) audio, out(2) the
|
|
154
|
+
* with-overlap images. */
|
|
155
|
+
readonly trimmed: {
|
|
156
|
+
out(k: number): OutputHandle;
|
|
157
|
+
};
|
|
158
|
+
/** ChainAssemble's video_path when the seat assembles; else null. */
|
|
159
|
+
readonly assemblePath: OutputHandle | null;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
/** @dev Judged against the boot census (served-grid-truth.spec.ts's
|
|
171
|
+
* band arm): the fixture's H3OneClickSwapPlan row is the engine's
|
|
172
|
+
* own word, and this pin must match it or the wall reds — an
|
|
173
|
+
* engine-side band move can never silently outdate the clamp. */
|
|
174
|
+
export declare const PLAN_CLIP_BAND: {
|
|
175
|
+
readonly min: 2.5;
|
|
176
|
+
readonly max: 15;
|
|
177
|
+
};
|
|
178
|
+
/** Emit the shared masked-edit chain for one seat. The node
|
|
179
|
+
* parameters are the three seats' historical spellings, verbatim;
|
|
180
|
+
* the seat's deltas arrive through the seat interface. The emission
|
|
181
|
+
* ends in LoopEnd (top_level_requeue) and, when configured,
|
|
182
|
+
* ChainAssemble.
|
|
183
|
+
* @param g the run's graph builder
|
|
184
|
+
* @param seat the seat's deltas (see MaskedChainSeat)
|
|
185
|
+
* @returns the trimmed window + optional assemble path (see ChainRender) */
|
|
186
|
+
export declare function renderMaskedEditChain(g: GraphBuilder, seat: MaskedChainSeat): ChainRender;
|
|
187
|
+
//# sourceMappingURL=chainEdit.d.ts.map
|
package/lib/chainEdit.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { LANE_FILES, h3LoraStackOf, h3ShiftVideoOf } from './actions.js';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export const loadVideo = (g, path, frameLoadCap = 0, skipFirstFrames = 0) => {
|
|
15
|
+
const n = g.node('VHS_LoadVideo', {
|
|
16
|
+
video: path, force_rate: 24, custom_width: 0, custom_height: 0,
|
|
17
|
+
frame_load_cap: frameLoadCap, skip_first_frames: skipFirstFrames,
|
|
18
|
+
select_every_nth: 1, format: 'None',
|
|
19
|
+
});
|
|
20
|
+
return [n.out(0), n.out(2)];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Two resolution regimes live in one family: the FILM path renders
|
|
24
|
+
// at the doc's own width/height (schema defaults 1344×768), the mod
|
|
25
|
+
// bags (replace/repair/extend) render at a plan TIER — a short-edge
|
|
26
|
+
// label the engine resolves against the source's own shape. Mixed
|
|
27
|
+
// film+mod chains joined mismatched shapes silently (friction F18):
|
|
28
|
+
// the film at 1344×768, the mod window at 736p = 1280×736. The cure
|
|
29
|
+
// is an ADMISSION WARNING at the compose door (operator order
|
|
30
|
+
|
|
31
|
+
// output changes, never a refusal). The tier math below is the
|
|
32
|
+
// ENGINE'S OWN LAW, ported verbatim from the live extension
|
|
33
|
+
// (comfyui-h3-oneclick-swap/__init__.py): RESOLUTIONS at line 28
|
|
34
|
+
// maps every tier to its short edge; plan_clips at lines 268-273
|
|
35
|
+
// scales the SOURCE shape by shortEdge/min(w,h) and snaps both
|
|
36
|
+
// edges to 32. The port cites the pin too: a tier whose short edge
|
|
37
|
+
// equals the film's own short edge composes the film's shape
|
|
38
|
+
// exactly (768p on 1344×768: scale 1.0 — the join stays
|
|
39
|
+
// shape-true), and any other shape reconciles through the plan
|
|
40
|
+
// node's optional short_edge knob (step 32), never by re-rendering
|
|
41
|
+
// the film.
|
|
42
|
+
export const RESOLUTION_SHORT_EDGE = {
|
|
43
|
+
'480p': 480, '576p': 576, '736p': 736, '768p': 768, '1080p': 1080,
|
|
44
|
+
};
|
|
45
|
+
/** The engine's plan_clips shape math, ported (ext lines 270-273):
|
|
46
|
+
* scale the source by shortEdge/min(w,h), snap both edges to 32
|
|
47
|
+
* (round), floor 32. Cited, never re-derived — an engine-side move
|
|
48
|
+
* of this math must update this port or the admission lies. */
|
|
49
|
+
export const planTierShape = (width, height, shortEdge) => {
|
|
50
|
+
const scale = shortEdge / Math.min(width, height);
|
|
51
|
+
return {
|
|
52
|
+
width: Math.max(32, Math.round(width * scale / 32) * 32),
|
|
53
|
+
height: Math.max(32, Math.round(height * scale / 32) * 32),
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/** THE CROSS-REGIME JOIN ADMISSION: given the film regime's shape
|
|
57
|
+
* (the doc's width/height — the shape this estate's film arm
|
|
58
|
+
* renders and the join appends onto) and the mod bag's tier, answer
|
|
59
|
+
* the admission text when the tier would render a DIFFERENT shape,
|
|
60
|
+
* null when the join is shape-true. The text names both regimes,
|
|
61
|
+
* the engine-derived mod shape, and the pin (the tier whose short
|
|
62
|
+
* edge matches the film's — 768p for the film regime's 768 short
|
|
63
|
+
* edge — or the plan node's short_edge knob for any other shape).
|
|
64
|
+
* @param filmWidth the film regime's width (the doc knob)
|
|
65
|
+
* @param filmHeight the film regime's height (the doc knob)
|
|
66
|
+
* @param tier the mod bag's resolution tier (e.g. '736p')
|
|
67
|
+
* @returns the admission warning text, or null when shapes agree */
|
|
68
|
+
export const admitCrossRegimeJoin = (filmWidth, filmHeight, tier) => {
|
|
69
|
+
const shortEdge = RESOLUTION_SHORT_EDGE[tier];
|
|
70
|
+
if (shortEdge === undefined)
|
|
71
|
+
return null;
|
|
72
|
+
const shape = planTierShape(filmWidth, filmHeight, shortEdge);
|
|
73
|
+
if (shape.width === filmWidth && shape.height === filmHeight)
|
|
74
|
+
return null;
|
|
75
|
+
const filmShort = Math.min(filmWidth, filmHeight);
|
|
76
|
+
const pin = Object.entries(RESOLUTION_SHORT_EDGE)
|
|
77
|
+
.find(([, e]) => e === filmShort)?.[0];
|
|
78
|
+
const pinText = pin !== undefined
|
|
79
|
+
? `pin the bag's resolution ${pin} (short edge ${String(filmShort)} — the plan then composes ${String(filmWidth)}×${String(filmHeight)} exactly)`
|
|
80
|
+
: `pin the plan's short_edge ${String(filmShort)} (the film's own short edge — no tier spells it)`;
|
|
81
|
+
return `h3-timeline: CROSS-REGIME JOIN — the film regime renders ${String(filmWidth)}×${String(filmHeight)} but the mod bag's tier '${tier}' renders ${String(shape.width)}×${String(shape.height)} on a film-shaped source (the engine scales the short edge to ${String(shortEdge)}, snaps to 32); the join mismatches shapes. To join shape-true, ${pinText}; to keep the mismatch, carry on — this admission warns, it never refuses.`;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export const h3MaskedEditPlane = (g, p, facts, clipSeconds) => {
|
|
102
|
+
const stabilize = p.sla_stabilize_motion ?? true;
|
|
103
|
+
const unet = g.node('UNETLoader', { unet_name: facts.unet, weight_dtype: 'default' }).out();
|
|
104
|
+
const sla = g.node('H3SLAAttention', {
|
|
105
|
+
model: unet,
|
|
106
|
+
sparsity_ratio: p.sla_sparsity,
|
|
107
|
+
block_size: p.sla_block_size,
|
|
108
|
+
min_seq_len: p.sla_min_seq_len,
|
|
109
|
+
dense_last_steps: p.sla_dense_last_steps,
|
|
110
|
+
protect_audio: p.sla_protect_audio,
|
|
111
|
+
enabled: true,
|
|
112
|
+
dense_steps: p.sla_dense_steps,
|
|
113
|
+
dense_backend: p.sla_dense_backend,
|
|
114
|
+
disable_fp16_accum: p.sla_disable_fp16_accum,
|
|
115
|
+
stabilize_motion: stabilize,
|
|
116
|
+
reference_protection: p.sla_reference_protection !== 'Off',
|
|
117
|
+
}).out();
|
|
118
|
+
const chunked = g.node('MiniMaxChunkFeedForward', {
|
|
119
|
+
model: g.node('MiniMaxLowVRAMAttention', { model: sla, head_chunks: 4 }).out(),
|
|
120
|
+
chunks: 2, seq_threshold: 4096,
|
|
121
|
+
}).out();
|
|
122
|
+
const clip = g.node('CLIPLoader', {
|
|
123
|
+
clip_name: LANE_FILES.clip, type: 'minimax',
|
|
124
|
+
}).out();
|
|
125
|
+
const vaeVideo = g.node('VAELoader', { vae_name: LANE_FILES.vae_video }).out();
|
|
126
|
+
const vaeAudio = g.node('VAELoader', { vae_name: LANE_FILES.vae_audio }).out();
|
|
127
|
+
let slaSel = p.sla_enabled === false
|
|
128
|
+
? true
|
|
129
|
+
: (p.sla_switch ?? null);
|
|
130
|
+
if (slaSel === null)
|
|
131
|
+
slaSel = g.node('PrimitiveBoolean', { value: false }).out();
|
|
132
|
+
const picked = g.node('ComfySwitchNode', { switch: slaSel, on_true: chunked, on_false: sla }).out();
|
|
133
|
+
const loraModel = g.node('LTX_lora_loader', {
|
|
134
|
+
model: picked, mode: 'minimax', stack_data: h3LoraStackOf(p),
|
|
135
|
+
}).out();
|
|
136
|
+
// The preview override's frame budget: the caller's one clip at
|
|
137
|
+
// the film clock (the film rides its own length node — the clock
|
|
138
|
+
// node is film-owned; a literal rides here, the same posture the
|
|
139
|
+
// reference's fixed preview knobs take).
|
|
140
|
+
const previewed = g.node('ModelPreviewOverrideKJ', {
|
|
141
|
+
max_resolution: 512, jpeg_quality: 80,
|
|
142
|
+
suppress_default_preview: true, preview_frames: Math.round(clipSeconds * 24),
|
|
143
|
+
preview_fps: 8, tiny_vae: 'none', model: loraModel,
|
|
144
|
+
}).out();
|
|
145
|
+
const adaln = g.node('H3AdaLNLoRAFix', { model: previewed, mode: 'port' }).out();
|
|
146
|
+
const sigmaModel = g.node('MiniMaxH3SigmaShift', {
|
|
147
|
+
model: adaln, shift_video: h3ShiftVideoOf(p), shift_audio: p.shift_audio,
|
|
148
|
+
}).out();
|
|
149
|
+
const samplerSel = g.node('KSamplerSelect', { sampler_name: 'euler' }).out();
|
|
150
|
+
return { sigmaModel, samplerSel, clip, vaeVideo, vaeAudio };
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
/** @dev Judged against the boot census (served-grid-truth.spec.ts's
|
|
162
|
+
* band arm): the fixture's H3OneClickSwapPlan row is the engine's
|
|
163
|
+
* own word, and this pin must match it or the wall reds — an
|
|
164
|
+
* engine-side band move can never silently outdate the clamp. */
|
|
165
|
+
export const PLAN_CLIP_BAND = { min: 2.5, max: 15.0 };
|
|
166
|
+
const planClipFeed = (seconds) => Math.min(PLAN_CLIP_BAND.max, Math.max(PLAN_CLIP_BAND.min, seconds));
|
|
167
|
+
/** Emit the shared masked-edit chain for one seat. The node
|
|
168
|
+
* parameters are the three seats' historical spellings, verbatim;
|
|
169
|
+
* the seat's deltas arrive through the seat interface. The emission
|
|
170
|
+
* ends in LoopEnd (top_level_requeue) and, when configured,
|
|
171
|
+
* ChainAssemble.
|
|
172
|
+
* @param g the run's graph builder
|
|
173
|
+
* @param seat the seat's deltas (see MaskedChainSeat)
|
|
174
|
+
* @returns the trimmed window + optional assemble path (see ChainRender) */
|
|
175
|
+
export function renderMaskedEditChain(g, seat) {
|
|
176
|
+
const { p, facts } = seat;
|
|
177
|
+
// ── the family's own model + lora plane (the shared masked-edit
|
|
178
|
+
// seat — the operator's lora law; a seat NEVER hand-rolls a stack) ──
|
|
179
|
+
const { sigmaModel, samplerSel, clip, vaeVideo, vaeAudio } = h3MaskedEditPlane(g, p, facts, seat.clipSeconds);
|
|
180
|
+
// ── the audio prep (the seats' shared posture: the source audio
|
|
181
|
+
// trims to the loop budget; the slice's copy is muted — the edit
|
|
182
|
+
// latent holds the source picture, never its sound) ──
|
|
183
|
+
const srcAudioTrim = g.node('TrimAudioDuration', {
|
|
184
|
+
start_index: 0, duration: 2048, audio: seat.srcAudio,
|
|
185
|
+
}).out(0);
|
|
186
|
+
const sliceAudio = g.node('AudioAdjustVolume', {
|
|
187
|
+
volume: -100, audio: srcAudioTrim,
|
|
188
|
+
}).out(0);
|
|
189
|
+
// ── the plan head (the entry's scalars, engine-derived geometry;
|
|
190
|
+
// picture_1 = the seat's anchor — the grid snap + tier scaling
|
|
191
|
+
// stay ENGINE-OWNED, never re-derived renderer-side). clip_seconds
|
|
192
|
+
// rides the WIDGET BAND clamp above (the node's own floor/ceiling
|
|
193
|
+
// would 400 the edge rungs at submit); the window's true length
|
|
194
|
+
// rides default_duration_seconds below, never this seat ──
|
|
195
|
+
const plan = g.node('H3OneClickSwapPlan', {
|
|
196
|
+
clip_seconds: planClipFeed(seat.clipSeconds),
|
|
197
|
+
overlap_frames: seat.overlapFrames,
|
|
198
|
+
resolution: seat.resolution,
|
|
199
|
+
steps: seat.steps,
|
|
200
|
+
seed: seat.seed,
|
|
201
|
+
roles: seat.roles,
|
|
202
|
+
source_frames: seat.srcFrames,
|
|
203
|
+
picture_1: seat.picture1,
|
|
204
|
+
});
|
|
205
|
+
const profile = g.node('MiniMaxH3GenerationProfile', {
|
|
206
|
+
scene_continuity: 'Hard picture + protected audio',
|
|
207
|
+
audio_profile: 'Generate audio',
|
|
208
|
+
}).out(0);
|
|
209
|
+
const chainPlan = g.node('MiniMaxH3ChainPlanModern', {
|
|
210
|
+
plan_json: seat.planJson,
|
|
211
|
+
run_name: plan.out(3),
|
|
212
|
+
generation_fingerprint: '',
|
|
213
|
+
width: plan.out(1),
|
|
214
|
+
height: plan.out(2),
|
|
215
|
+
encode_mode: 'video',
|
|
216
|
+
crop: 'center',
|
|
217
|
+
default_duration_seconds: seat.clipSeconds,
|
|
218
|
+
default_steps: seat.steps,
|
|
219
|
+
base_seed: seat.seed,
|
|
220
|
+
segment_crf: 16,
|
|
221
|
+
video_blend_frames: 0,
|
|
222
|
+
chain_policy: profile,
|
|
223
|
+
// THE PLAN-INPUT LAW (the extend cure, design §3): only a
|
|
224
|
+
// source-SLICING seat wires the plan node's derived shots — a
|
|
225
|
+
// non-empty plan_json_input OVERRIDES the literal, and the plan
|
|
226
|
+
// node slices the SOURCE by clip_seconds (the swap's semantics,
|
|
227
|
+
// the repair's window re-slice). A continuation seat (extend)
|
|
228
|
+
// leaves the literal ruling: its shots are NEW seconds, never a
|
|
229
|
+
// re-slice of the raw prior.
|
|
230
|
+
...(seat.planFromSource ? { plan_json_input: plan.out(0) } : {}),
|
|
231
|
+
}).out(0);
|
|
232
|
+
const timeline = g.node('MiniMaxH3SourceTimeline', {
|
|
233
|
+
video_path: seat.sourceClip, audio_path: '', embedded_audio: 'auto',
|
|
234
|
+
// the window rides BOTH loaders identically (the VHS seat's
|
|
235
|
+
// skip + this one): the timeline maps the chain onto the same
|
|
236
|
+
// window the frames/audio were cut from.
|
|
237
|
+
skip_first_frames: Math.round(seat.windowStart), source_audio: srcAudioTrim,
|
|
238
|
+
// THE LAZY-VIDEO WIRE (friction-report #4): the timeline's
|
|
239
|
+
// video_path is a raw CWD-relative filesystem path (upstream
|
|
240
|
+
// _resolved_media_path: abspath, never the input dir), while
|
|
241
|
+
// VHS_LoadVideo.video must be an input-dir leaf — one string
|
|
242
|
+
// cannot satisfy both. The node prefers "a native file-backed
|
|
243
|
+
// VIDEO connection" (its own tooltip): the core loader resolves
|
|
244
|
+
// the staged leaf in the input dir, and the timeline reads the
|
|
245
|
+
// file back off the wire's stream source — video_path rides
|
|
246
|
+
// along staged but unread.
|
|
247
|
+
source_video: g.node('LoadVideo', {
|
|
248
|
+
file: seat.sourceClip,
|
|
249
|
+
}).out(0),
|
|
250
|
+
}).out(0);
|
|
251
|
+
const loop = g.node('MiniMaxH3ChainLoopStart', {
|
|
252
|
+
start_clip: 1, scene_range: '', verify_resume_history: true,
|
|
253
|
+
plan: chainPlan, source_timeline: timeline,
|
|
254
|
+
});
|
|
255
|
+
const cur = g.node('MiniMaxH3ChainCurrent', {
|
|
256
|
+
align_audio_reference: false, state: loop.out(1),
|
|
257
|
+
});
|
|
258
|
+
const mutedChainAudio = g.node('AudioAdjustVolume', {
|
|
259
|
+
volume: -100, audio: cur.out(12),
|
|
260
|
+
}).out(0);
|
|
261
|
+
// ── the seat's masked-edit body (anchors + slice + edit latent +
|
|
262
|
+
// masked target — the seat's true deltas) ──
|
|
263
|
+
const { conditioning, targetLatent } = seat.body({
|
|
264
|
+
cur, clip, vaeVideo, vaeAudio, mutedChainAudio,
|
|
265
|
+
srcFrames: seat.srcFrames, sliceAudio,
|
|
266
|
+
});
|
|
267
|
+
const ctx = g.node('MiniMaxH3ChainContext', {
|
|
268
|
+
state: cur.out(0), conditioning,
|
|
269
|
+
vae: vaeVideo, latent: targetLatent, audio_vae: vaeAudio,
|
|
270
|
+
});
|
|
271
|
+
// ── the sampler tail (the denoise pole is the seat's one knob:
|
|
272
|
+
// full 1 fresh — swap/extend; partial refine — the repair's law) ──
|
|
273
|
+
const sample = g.node('SamplerCustomAdvanced', {
|
|
274
|
+
noise: g.node('RandomNoise', { noise_seed: cur.out(5) }).out(0),
|
|
275
|
+
guider: g.node('BasicGuider', { model: sigmaModel, conditioning: ctx.out(0) }).out(0),
|
|
276
|
+
sampler: samplerSel,
|
|
277
|
+
sigmas: g.node('BasicScheduler', {
|
|
278
|
+
scheduler: 'simple', steps: cur.out(7), denoise: seat.denoise, model: sigmaModel,
|
|
279
|
+
}).out(0),
|
|
280
|
+
latent_image: ctx.out(3),
|
|
281
|
+
}).out(0);
|
|
282
|
+
const decoded = g.node('VAEDecode', { samples: sample, vae: vaeVideo }).out(0);
|
|
283
|
+
const decodedAudio = g.node('VAEDecodeAudio', { samples: sample, vae: vaeAudio }).out(0);
|
|
284
|
+
const trimmed = g.node('MiniMaxH3LoopTrim', {
|
|
285
|
+
trim_frames: ctx.out(1), fps: 24, match_tail: true,
|
|
286
|
+
audio_trim_mode: 'sync_with_video',
|
|
287
|
+
images: decoded, audio: decodedAudio, state: cur.out(0),
|
|
288
|
+
});
|
|
289
|
+
const seg = g.node('MiniMaxH3ChainSegmentSave', {
|
|
290
|
+
state: cur.out(0), images: trimmed.out(0), sampled_latent: sample,
|
|
291
|
+
audio: trimmed.out(1), images_with_overlap: trimmed.out(2),
|
|
292
|
+
}).out(0);
|
|
293
|
+
const review = g.node('MiniMaxH3ChainReview', {
|
|
294
|
+
enabled: false, play_notification_sound: false,
|
|
295
|
+
auto_continue_timeout_minutes: 0, unload_models_while_waiting: false,
|
|
296
|
+
assemble_partial_on_stop: true, partial_audio_source: 'checkpointed',
|
|
297
|
+
candidate_count: 1, review_each_candidate: false,
|
|
298
|
+
state: cur.out(0), segment: seg, audio: trimmed.out(1),
|
|
299
|
+
}).out(0);
|
|
300
|
+
const loopEnd = g.node('MiniMaxH3ChainLoopEnd', {
|
|
301
|
+
|
|
302
|
+
// expansion dies past clip 2 (subgraph-qualified node ids stop
|
|
303
|
+
// resolving at depth >= 3 — the pack now refuses >2-scene
|
|
304
|
+
// recursive plans at hop 1). Requeue mode checkpoints each scene,
|
|
305
|
+
// ends its prompt terminal-success, and the estate's requeue
|
|
306
|
+
// DRIVER (comfyui-execute.ts driveH3ChainRequeue) claims the
|
|
307
|
+
// durable handoff, patches LoopStart to the owed scene, and
|
|
308
|
+
// re-submits until the chain completes — the film assembles on
|
|
309
|
+
// the final prompt.
|
|
310
|
+
between_scene_cleanup: 'off', execution_mode: 'top_level_requeue',
|
|
311
|
+
flow: loop.out(0), state: cur.out(0),
|
|
312
|
+
images: trimmed.out(0), sampled_latent: sample, segment: review,
|
|
313
|
+
});
|
|
314
|
+
// ── the terminal: ChainAssemble when the seat assembles in-chain
|
|
315
|
+
// (the latent-seam machinery — blend_schedule 'plan' rides the
|
|
316
|
+
// policy's own overlaps); null when the seat joins by file. ──
|
|
317
|
+
if (seat.assemble === null)
|
|
318
|
+
return { trimmed, assemblePath: null };
|
|
319
|
+
const assemble = g.node('MiniMaxH3ChainAssemble', {
|
|
320
|
+
audio_source: seat.assemble.audioSource,
|
|
321
|
+
filename: seat.assemble.filename,
|
|
322
|
+
audio_bitrate: 256, copy_to_output: true, output_subfolder: '',
|
|
323
|
+
blend_schedule: 'plan', boundary_tone_match: 'off',
|
|
324
|
+
color_stabilization: 'off', delete_checkpoints_after_assembly: false,
|
|
325
|
+
generated_audio_join: 'av_overlap',
|
|
326
|
+
manifest: loopEnd.out(0),
|
|
327
|
+
});
|
|
328
|
+
return { trimmed, assemblePath: assemble.out(0) };
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=chainEdit.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GraphBuilder } from '@melite/comfyui-card-kit/graph';
|
|
2
|
+
import type { H3Facts } from './actions.js';
|
|
3
|
+
/** The arm predicate: BAG PRESENCE — the same law as the
|
|
4
|
+
* replace/repair/extend/refine/reshoot arms (a commission is armed
|
|
5
|
+
* when its bag is a NON-EMPTY ARRAY). Absent or empty bag = the
|
|
6
|
+
* compose never sees the chain (byte-stable graphs).
|
|
7
|
+
* @param p the gated compose doc
|
|
8
|
+
* @returns true when the upscale bag carries at least one entry */
|
|
9
|
+
export declare function upscaleArmed(p: Record<string, unknown>): boolean;
|
|
10
|
+
/** The chain-upscale renderer: validates the bound entry, then
|
|
11
|
+
* composes the deferred 2x loop over the named prior run. The film
|
|
12
|
+
* path never reaches here (the card branches on a non-empty upscale
|
|
13
|
+
* bag, and a bag beside any other edit arm refuses loud: one door
|
|
14
|
+
* per doc). The emission ends in ChainAssemble at `<runId>/upscale`
|
|
15
|
+
* (copy_to_output — the estate's film law; the recipe's dated
|
|
16
|
+
* filename and no-copy posture is a browser-session spelling, not an
|
|
17
|
+
* estate one).
|
|
18
|
+
* @param entry the upscale mod's single bound entry
|
|
19
|
+
* @param p the walked doc params (the lora mod bag + scheduler knobs
|
|
20
|
+
* — the family plane this loop renders under)
|
|
21
|
+
* @param facts the family's lane facts (unet off the DECL row)
|
|
22
|
+
* @param g the run's graph builder
|
|
23
|
+
* @param runId the run tree's id (the assemble filename rides it) */
|
|
24
|
+
export declare function renderH3ChainUpscale(entry: Record<string, unknown>, p: Record<string, unknown>, facts: H3Facts, g: GraphBuilder, runId: string): void;
|
|
25
|
+
//# sourceMappingURL=chainUpscale.d.ts.map
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { h3MaskedEditPlane } from './chainEdit.js';
|
|
2
|
+
import { REFINE_UPSCALE_MODEL } from './refine.js';
|
|
3
|
+
/** The upscale entry's required seats (the reshoot idiom: an armed
|
|
4
|
+
* doc with an empty seat refuses loud naming the seat). */
|
|
5
|
+
const REQUIRED_SEATS = [
|
|
6
|
+
['chain_run', 'the prior chain run whose checkpointed scenes the 2x pass resumes — the engine-side run name (its h3_chains store directory), resolved to the newest per-scene lineage at the execute door'],
|
|
7
|
+
];
|
|
8
|
+
const num = (e, key, d) => typeof e[key] === 'number' ? e[key] : d;
|
|
9
|
+
const str = (e, key, d) => typeof e[key] === 'string' ? e[key] : d;
|
|
10
|
+
/** The arm predicate: BAG PRESENCE — the same law as the
|
|
11
|
+
* replace/repair/extend/refine/reshoot arms (a commission is armed
|
|
12
|
+
* when its bag is a NON-EMPTY ARRAY). Absent or empty bag = the
|
|
13
|
+
* compose never sees the chain (byte-stable graphs).
|
|
14
|
+
* @param p the gated compose doc
|
|
15
|
+
* @returns true when the upscale bag carries at least one entry */
|
|
16
|
+
export function upscaleArmed(p) {
|
|
17
|
+
const bag = p.upscale;
|
|
18
|
+
return Array.isArray(bag) && bag.length > 0;
|
|
19
|
+
}
|
|
20
|
+
/** The chain-upscale renderer: validates the bound entry, then
|
|
21
|
+
* composes the deferred 2x loop over the named prior run. The film
|
|
22
|
+
* path never reaches here (the card branches on a non-empty upscale
|
|
23
|
+
* bag, and a bag beside any other edit arm refuses loud: one door
|
|
24
|
+
* per doc). The emission ends in ChainAssemble at `<runId>/upscale`
|
|
25
|
+
* (copy_to_output — the estate's film law; the recipe's dated
|
|
26
|
+
* filename and no-copy posture is a browser-session spelling, not an
|
|
27
|
+
* estate one).
|
|
28
|
+
* @param entry the upscale mod's single bound entry
|
|
29
|
+
* @param p the walked doc params (the lora mod bag + scheduler knobs
|
|
30
|
+
* — the family plane this loop renders under)
|
|
31
|
+
* @param facts the family's lane facts (unet off the DECL row)
|
|
32
|
+
* @param g the run's graph builder
|
|
33
|
+
* @param runId the run tree's id (the assemble filename rides it) */
|
|
34
|
+
export function renderH3ChainUpscale(entry, p, facts, g, runId) {
|
|
35
|
+
for (const [seat, what] of REQUIRED_SEATS) {
|
|
36
|
+
const v = entry[seat];
|
|
37
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
38
|
+
throw new Error(`h3-timeline upscale: '${seat}' names no run — ${what}; an upscale needs the prior chain run bound`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const denoise = num(entry, 'denoise', 0.24);
|
|
42
|
+
if (denoise >= 1) {
|
|
43
|
+
throw new Error(`h3-timeline upscale: denoise ${denoise} >= 1 — a second pass is an upscale, never a re-render (the recipe's pass-2 window is 0.24; a full-noise sigma discards the learned upscaled latent — that is a reshoot, and the reshoot door exists)`);
|
|
44
|
+
}
|
|
45
|
+
const steps = num(entry, 'steps', 20);
|
|
46
|
+
const segmentCrf = num(entry, 'segment_crf', 18);
|
|
47
|
+
const prompt = str(entry, 'prompt', '');
|
|
48
|
+
// ── the family's own plane (the shared masked-edit seat — the
|
|
49
|
+
// operator's lora law; a seat NEVER hand-rolls a stack) ──
|
|
50
|
+
const { sigmaModel, clip, vaeVideo, vaeAudio } = h3MaskedEditPlane(g, p, facts, 6);
|
|
51
|
+
// ── the head (the F19 selection law: the bare run name, resolved
|
|
52
|
+
// to the newest per-scene lineage at the execute door) + the loop
|
|
53
|
+
// family's own adapter/current spine ──
|
|
54
|
+
const manager = g.node('MiniMaxH3ChainCheckpointManager', {
|
|
55
|
+
selection_json: entry['chain_run'],
|
|
56
|
+
});
|
|
57
|
+
const adapter = g.node('MiniMaxH3ChainUpscaleAdapter', {
|
|
58
|
+
source_manifest: manager.out(0),
|
|
59
|
+
profile: 'h3_2x', backend: 'h3_latent', recipe_json: '{}',
|
|
60
|
+
start_clip: 1, end_clip: 0, save_latent: false,
|
|
61
|
+
segment_crf: segmentCrf, start_mode: 'resume',
|
|
62
|
+
});
|
|
63
|
+
const cur = g.node('MiniMaxH3ChainUpscaleCurrent', {
|
|
64
|
+
state: adapter.out(1),
|
|
65
|
+
});
|
|
66
|
+
// ── the conditioning rebuild (the node's own defaults for its
|
|
67
|
+
// reference policy seats — the recipe's spellings: missing caches
|
|
68
|
+
// rebuild text-only, motion refs keep audio, refs stay strict).
|
|
69
|
+
// Blank prompt reuses the source run's own scene prompts ──
|
|
70
|
+
const conditioning = g.node('MiniMaxH3ChainUpscaleReferenceConditioning', {
|
|
71
|
+
state: cur.out(0), clip, video_vae: vaeVideo,
|
|
72
|
+
missing_cache: 'text_only', motion_ref_mode: 'exclude_video_keep_audio',
|
|
73
|
+
prompt_override: prompt,
|
|
74
|
+
override_ref_image_size: 'inherit', override_reference_policy: 'strict',
|
|
75
|
+
override_semantic_anchor_size: 'inherit',
|
|
76
|
+
override_semantic_anchor_mode: 'inherit',
|
|
77
|
+
}).out(0);
|
|
78
|
+
// ── the learned 2x upscale (ONE variant path: multiplier 2.0, the
|
|
79
|
+
// family's single weights spelling, offload after — the recipe's
|
|
80
|
+
// own posture, freeing VRAM for pass 2) + the conditioning sync ──
|
|
81
|
+
const upscaled = g.node('MinimaxH3LatentUpscaler3D', {
|
|
82
|
+
latent: cur.out(2),
|
|
83
|
+
model_name: REFINE_UPSCALE_MODEL,
|
|
84
|
+
// F23 — the combo's child rides its DOTTED path (see refine.ts)
|
|
85
|
+
mode: 'scale by multiplier', 'mode.scale': 2.0,
|
|
86
|
+
align: 32, keep_proportion: true,
|
|
87
|
+
device: 'cuda', precision: 'bf16', offload_after_upscale: true,
|
|
88
|
+
}).out(0);
|
|
89
|
+
const synced = g.node('H3ConditioningSyncFromLatents', {
|
|
90
|
+
original_latent: cur.out(2), upscaled_latent: upscaled,
|
|
91
|
+
positive: conditioning,
|
|
92
|
+
method: 'bilinear', motion_ref_mode: 'conditioning_policy',
|
|
93
|
+
}).out(0);
|
|
94
|
+
// ── pass 2 (the recipe's tail: Pass2Prepare over the upscaled
|
|
95
|
+
// latent + the source's untouched audio latent, then the sampler —
|
|
96
|
+
// DisableNoise because Pass2Prepare owns the noise member, the
|
|
97
|
+
// res_multistep select, the 'simple' schedule at the entry's
|
|
98
|
+
// denoise/steps) ──
|
|
99
|
+
const noise = g.node('RandomNoise', { noise_seed: cur.out(9) }).out(0);
|
|
100
|
+
const sigmas = g.node('BasicScheduler', {
|
|
101
|
+
model: sigmaModel, scheduler: 'simple', steps, denoise,
|
|
102
|
+
}).out(0);
|
|
103
|
+
const pass2 = g.node('MiniMaxH3ChainPass2Prepare', {
|
|
104
|
+
upscaled_video: upscaled, source_audio: cur.out(3),
|
|
105
|
+
model: sigmaModel, noise, sigmas, state: cur.out(0),
|
|
106
|
+
}).out(0);
|
|
107
|
+
const sampled = g.node('SamplerCustomAdvanced', {
|
|
108
|
+
noise: g.node('DisableNoise', {}).out(0),
|
|
109
|
+
guider: g.node('BasicGuider', { model: sigmaModel, conditioning: synced }).out(0),
|
|
110
|
+
sampler: g.node('KSamplerSelect', { sampler_name: 'res_multistep' }).out(0),
|
|
111
|
+
sigmas, latent_image: pass2,
|
|
112
|
+
}).out(0);
|
|
113
|
+
const decoded = g.node('VAEDecode', { samples: sampled, vae: vaeVideo }).out(0);
|
|
114
|
+
// ── the loop tail (top_level_requeue — the estate's requeue driver
|
|
115
|
+
// claims each owed scene and patches the ADAPTER's start_clip; the
|
|
116
|
+
// upscale family's LoopEnd rides the same durable h3_chain rows as
|
|
117
|
+
// the scene chain) + the estate's assemble law ──
|
|
118
|
+
const segment = g.node('MiniMaxH3ChainUpscaleSegmentSave', {
|
|
119
|
+
state: cur.out(0), images: decoded, upscaled_latent: sampled,
|
|
120
|
+
}).out(0);
|
|
121
|
+
const loopEnd = g.node('MiniMaxH3ChainUpscaleLoopEnd', {
|
|
122
|
+
flow: adapter.out(0), state: cur.out(0),
|
|
123
|
+
images: decoded, segment, upscaled_latent: sampled,
|
|
124
|
+
}).out(0);
|
|
125
|
+
g.node('MiniMaxH3ChainAssemble', {
|
|
126
|
+
manifest: loopEnd,
|
|
127
|
+
audio_source: 'plan', filename: `${runId}/upscale`,
|
|
128
|
+
audio_bitrate: 256, copy_to_output: true, output_subfolder: '',
|
|
129
|
+
blend_schedule: 'plan', boundary_tone_match: 'off',
|
|
130
|
+
color_stabilization: 'off', delete_checkpoints_after_assembly: false,
|
|
131
|
+
generated_audio_join: 'av_overlap',
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=chainUpscale.js.map
|