@melite/models-h3 0.2.0-alpha → 0.2.3-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -16
- package/lib/actions.d.ts +10 -1
- package/lib/actions.js +455 -294
- package/lib/chainEdit.d.ts +106 -3
- package/lib/chainEdit.js +191 -16
- package/lib/chainUpscale.js +4 -1
- package/lib/edit.d.ts +103 -0
- package/lib/edit.js +645 -0
- package/lib/extend.d.ts +1 -0
- package/lib/extend.js +162 -36
- package/lib/filmMix.d.ts +29 -2
- package/lib/filmMix.js +93 -23
- package/lib/finalize.js +6 -1
- package/lib/index.d.ts +3 -2
- package/lib/index.js +78 -34
- package/lib/mods/loras.js +15 -1
- package/lib/refine.d.ts +151 -13
- package/lib/refine.js +626 -131
- package/lib/refmodBake.d.ts +29 -0
- package/lib/refmodBake.js +176 -0
- package/lib/repair.js +84 -77
- package/lib/reshoot.js +68 -16
- package/lib/schema.d.ts +44 -0
- package/lib/schema.js +155 -43
- package/lib/secondPass.d.ts +31 -0
- package/lib/secondPass.js +59 -0
- package/lib/swap.js +63 -34
- package/lib/timelineContract.d.ts +281 -5
- package/lib/timelineContract.js +394 -10
- package/package.json +24 -9
package/lib/refine.js
CHANGED
|
@@ -1,23 +1,62 @@
|
|
|
1
1
|
import { chainSaveBoundaries, concatSavedFilms, filmJoinAudio } from './actions.js';
|
|
2
|
-
import { h3MaskedEditPlane, loadVideo } from './chainEdit.js';
|
|
3
|
-
import {
|
|
2
|
+
import { contexMaskedTarget, h3MaskedEditPlane, loadVideo } from './chainEdit.js';
|
|
3
|
+
import { FULL_NOISE_REASON, fullNoiseClause } from './secondPass.js';
|
|
4
|
+
import { DOC_FPS_DEFAULT, MAX_COMPOSED_WINDOWS, SEAM_OVERLAP_FRAMES } from './timelineContract.js';
|
|
4
5
|
/** The learned 3D-conv upscale weights (the schema's upscale_model
|
|
5
6
|
* seat carries this same single option — one file, one spelling, no
|
|
6
7
|
* hand-spelled alternatives). */
|
|
7
8
|
export const REFINE_UPSCALE_MODEL = 'minimax_h3_latent_upscaler_3d_bf16.safetensors';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
15
19
|
export const REFINE_2X_OOM_FRAMES = 141;
|
|
16
20
|
|
|
17
21
|
|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export const REFINE_DEFAULT_CLIP_SECONDS = 2.33;
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
export const REGION_REPAIR_GREEN_FRAMES = 362;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export const REFINE_WORKAROUND_WIDE_FRAMES = 90;
|
|
51
|
+
/** The refine auto-tile's default carried overlap, in frames at the
|
|
52
|
+
* film clock — the film's own seam (SEAM_OVERLAP_FRAMES), which is
|
|
53
|
+
* also token-exact (5, 22, 39 …), so the default auto-tile takes the
|
|
54
|
+
* carry face: the windows chain through the film's own latent
|
|
55
|
+
* continuation across every join. Imported, never hand-typed
|
|
56
|
+
* (refine-window audit D1: the card must never carry a hand-typed
|
|
57
|
+
* copy of a measured constant — and the overlap that matches the
|
|
58
|
+
* generation seam grid is the family contract's own number). */
|
|
59
|
+
export const REFINE_DEFAULT_OVERLAP_FRAMES = SEAM_OVERLAP_FRAMES;
|
|
21
60
|
/** The refine entry's required seats (the reshoot idiom: an armed
|
|
22
61
|
* doc with an empty seat refuses loud naming the seat). */
|
|
23
62
|
const REQUIRED_SEATS = [
|
|
@@ -35,6 +74,37 @@ export function refineArmed(p) {
|
|
|
35
74
|
const bag = p.refine;
|
|
36
75
|
return Array.isArray(bag) && bag.length > 0;
|
|
37
76
|
}
|
|
77
|
+
/** One entry's dials, read with the arm's own defaults — ONE owner
|
|
78
|
+
* for the single-window arm, the bag walk and the carry face.
|
|
79
|
+
* @param entry the refine entry
|
|
80
|
+
* @returns the dial set its window renders under (denoise refuses at
|
|
81
|
+
* or above 1: a second pass is a refine, never a re-render) */
|
|
82
|
+
const refineDials = (entry) => {
|
|
83
|
+
const denoise = num(entry, 'denoise', 0.32);
|
|
84
|
+
// THE SHARED FULL-NOISE LAW (secondPass.ts): the clause and the
|
|
85
|
+
// reason are the seat's own — this door names its window.
|
|
86
|
+
if (denoise >= 1) {
|
|
87
|
+
throw new Error(`h3-timeline refine: denoise ${denoise} >= 1 — ${fullNoiseClause('refine')} (the partial-denoise window is 0.05–0.50; ${FULL_NOISE_REASON} and the vendored node throws — that is a reshoot, and the reshoot door exists)`);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
denoise,
|
|
91
|
+
seed: num(entry, 'seed', 0),
|
|
92
|
+
steps: num(entry, 'steps', 6),
|
|
93
|
+
upMode: entry['mode'] ?? 'scale by multiplier',
|
|
94
|
+
upScale: entry['scale'] ?? 2.0,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
/** An entry's two media seats, bound or the door refuses loud naming
|
|
98
|
+
* the seat (the reshoot idiom: an armed doc never rides an empty seat).
|
|
99
|
+
* @param entry the refine entry */
|
|
100
|
+
const requireRefineEntry = (entry) => {
|
|
101
|
+
for (const [seat, what] of REQUIRED_SEATS) {
|
|
102
|
+
const v = entry[seat];
|
|
103
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
104
|
+
throw new Error(`h3-timeline refine: '${seat}' names no media — ${what}; a refine needs both seats bound (source_clip, refine_prompt)`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
38
108
|
|
|
39
109
|
|
|
40
110
|
|
|
@@ -44,122 +114,116 @@ export function refineArmed(p) {
|
|
|
44
114
|
|
|
45
115
|
|
|
46
116
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export function renderH3RefineWindow(entry, p, facts, g, seat) {
|
|
54
|
-
for (const [seat, what] of REQUIRED_SEATS) {
|
|
55
|
-
const v = entry[seat];
|
|
56
|
-
if (typeof v !== 'string' || v.trim() === '') {
|
|
57
|
-
throw new Error(`h3-timeline refine: '${seat}' names no media — ${what}; a refine needs both seats bound (source_clip, refine_prompt)`);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const denoise = num(entry, 'denoise', 0.32);
|
|
61
|
-
if (denoise >= 1) {
|
|
62
|
-
throw new Error(`h3-timeline refine: denoise ${denoise} >= 1 — a second pass is a refine, never a re-render (the partial-denoise window is 0.05–0.50; a full-noise sigma discards the learned upscaled latent and the vendored node throws — that is a reshoot, and the reshoot door exists)`);
|
|
117
|
+
const judgeRefineWindow = (cap, dials) => {
|
|
118
|
+
const sameSize = dials.upMode === 'scale by multiplier' && dials.upScale < 2;
|
|
119
|
+
if (!sameSize && cap > REFINE_2X_OOM_FRAMES) {
|
|
120
|
+
const named = dials.upMode === 'scale by multiplier' ? `${dials.upScale}x` : dials.upMode;
|
|
121
|
+
throw new Error(`h3-timeline refine: a ${cap} f window at ${named} is TOO LONG — the 2x pass was measured OOM at ${REFINE_2X_OOM_FRAMES} f (2688×1536, 48 kHz; H3 memory grows with the window, and that is the whole story: there is no OOM mystery and no ceiling to press, whichever sizing mode upsizes, a window that dies is just a window too long). The design is the ~2 s window (${REFINE_DEFAULT_CLIP_SECONDS} s = ${Math.round(REFINE_DEFAULT_CLIP_SECONDS * 24)} f, the 2 s class's rung of the 22+17k token grid) tiled window by window and joined by the context carry — the carry is what makes a short window seamless (the carry is served, ROADMAP F3-14 cured), so no film ever needs a wider window. Cut clip_seconds to ${REFINE_DEFAULT_CLIP_SECONDS} s or less and let the carry tile the rest, or lower scale to 1 for a same-size pass`);
|
|
63
122
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
};
|
|
124
|
+
/** THE JOINT AV TARGET — the estate's one source→nested-AV
|
|
125
|
+
* constructor rider: the SolidMask (all-white, sized from the
|
|
126
|
+
* loader's frames via GetImageSizeAndCount — never a hand-typed
|
|
127
|
+
* resolution) feeds the shared `contexMaskedTarget` seat every
|
|
128
|
+
* masked-edit chain rides (chainEdit.ts, the timeline rework's
|
|
129
|
+
* stage-1 seam). White means "every frame is editable" (nothing
|
|
130
|
+
* is held; a refine re-renders the window at its own denoise) and
|
|
131
|
+
* `keep_audio` carries the window's soundtrack into the joint
|
|
132
|
+
* latent, so the audio stream every downstream node reads is the
|
|
133
|
+
* source's own.
|
|
134
|
+
* @param g the run's graph builder
|
|
135
|
+
* @param plane the plane's two VAE seats
|
|
136
|
+
* @param frames the window's loaded frames
|
|
137
|
+
* @param audio the window's loaded soundtrack
|
|
138
|
+
* @returns the nested video+audio target latent the handoff refines */
|
|
139
|
+
const refineJointTarget = (g, plane, frames, audio) => {
|
|
140
|
+
const size = g.node('GetImageSizeAndCount', { image: frames });
|
|
141
|
+
const whiteMask = g.node('SolidMask', {
|
|
142
|
+
value: 1, width: size.out(1), height: size.out(2),
|
|
143
|
+
}).out(0);
|
|
144
|
+
return contexMaskedTarget(g, plane, {
|
|
145
|
+
frames, audio, mask: whiteMask, keepAudio: true,
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
/** THE WINDOW BODY — one refine window, whichever door composed it:
|
|
149
|
+
* joint AV target → (carry) → the 2x handoff → decode → (head-trim).
|
|
150
|
+
* THE CARRY IS THE FILM'S OWN NODE, with the film's own seats
|
|
151
|
+
* (iteration, overlap_frames, continue_audio_latent true, the
|
|
152
|
+
* model + sigmas the sampler will ride, previous_latent = the
|
|
153
|
+
* previous window's joint latent): the carried tail is copied into
|
|
154
|
+
* this window's head, the zero-prefix mask pins it (gradient false),
|
|
155
|
+
* the audio prefix takes the same Soft AV half-cosine release, and
|
|
156
|
+
* the returned model is the drift-controlled one the handoff samples
|
|
157
|
+
* with — one mechanism for normal gens and refine gens.
|
|
158
|
+
*
|
|
159
|
+
* WHAT rides as `previous_latent` (settled round 27): the previous
|
|
160
|
+
* window's JOINT TARGET — the latent its handoff refined. A refine
|
|
161
|
+
* has no base-rate sample (its only sample IS the 2x handoff's), and
|
|
162
|
+
* the joint-AV upscaler the handoff wraps takes a base-rate latent,
|
|
163
|
+
* so the film's own 2x-arm law applies: carry the base grid and let
|
|
164
|
+
* each window's upscale re-derive the high grid (actions.ts's F44
|
|
165
|
+
* seam currency — `seamLatent = upscaleOn ? sampled.out(0)` — is the
|
|
166
|
+
* symmetry owner). The head-trim then drops the carried duplicate,
|
|
167
|
+
* exactly as the film's windows do, and the tail is the plain file
|
|
168
|
+
* concat — no alpha blend anywhere on either path.
|
|
169
|
+
* @param g the run's graph builder
|
|
170
|
+
* @param entry the window's entry (prompt + dials)
|
|
171
|
+
* @param p the walked doc params (the scheduler name)
|
|
172
|
+
* @param plane the family plane (shared by a carry film)
|
|
173
|
+
* @param seat the window's loader seats + carried head + save prefix
|
|
174
|
+
* @param iteration the window's index in its emission (the
|
|
175
|
+
* continuation's own `iteration` seat; only read when carrying)
|
|
176
|
+
* @param previousLatent the previous window's joint target — present
|
|
177
|
+
* exactly when this window carries
|
|
178
|
+
* @returns the window's SaveVideo passthrough plus the joint target
|
|
179
|
+
* the NEXT window carries */
|
|
180
|
+
const composeRefineWindow = (g, entry, p, plane, seat, iteration, previousLatent) => {
|
|
181
|
+
const dials = refineDials(entry);
|
|
182
|
+
requireRefineEntry(entry);
|
|
183
|
+
judgeRefineWindow(seat.cap, dials);
|
|
184
|
+
const [srcFrames, srcAudio] = loadVideo(g, entry['source_clip'], seat.cap, seat.skip);
|
|
185
|
+
const target = refineJointTarget(g, plane, srcFrames, srcAudio);
|
|
121
186
|
const positive = g.node('CLIPTextEncode', {
|
|
122
|
-
text: entry['refine_prompt'], clip,
|
|
187
|
+
text: entry['refine_prompt'], clip: plane.clip,
|
|
123
188
|
}).out(0);
|
|
124
|
-
const noise = g.node('RandomNoise', { noise_seed: seed }).out(0);
|
|
189
|
+
const noise = g.node('RandomNoise', { noise_seed: dials.seed }).out(0);
|
|
125
190
|
const sched = g.node('BasicScheduler', {
|
|
126
|
-
model: sigmaModel, scheduler: p.sched_name,
|
|
127
|
-
steps, denoise,
|
|
191
|
+
model: plane.sigmaModel, scheduler: p.sched_name,
|
|
192
|
+
steps: dials.steps, denoise: dials.denoise,
|
|
128
193
|
}).out(0);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
194
|
+
let cond = positive;
|
|
195
|
+
let mdl = plane.sigmaModel;
|
|
196
|
+
let lat = target;
|
|
197
|
+
if (previousLatent !== undefined) {
|
|
198
|
+
/* v8 ignore next 5 -- unreachable by construction: every caller passes previousLatent exactly for k ≥ 1, where overlapFrames = carries[k−1], and the tokenExactCarry door (≥ 5) has already refused every smaller carry; the guard stays as the window body's own contract against a future wiring slip */
|
|
199
|
+
if (seat.overlapFrames <= 0) {
|
|
200
|
+
throw new Error(`h3-timeline refine: window ${iteration} arrived with a previous latent but no carried head — a carry without frames to carry is a wiring bug, not a doc to fix`);
|
|
201
|
+
}
|
|
202
|
+
const cont = g.node('MiniMaxH3FiniteLatentContinuation', {
|
|
203
|
+
positive: cond, target_latent: lat, iteration,
|
|
204
|
+
overlap_frames: seat.overlapFrames, continue_audio_latent: true,
|
|
205
|
+
model: mdl, sigmas: sched, previous_latent: previousLatent,
|
|
206
|
+
});
|
|
207
|
+
cond = cont.out(0);
|
|
208
|
+
lat = cont.out(1);
|
|
209
|
+
mdl = cont.out(3);
|
|
210
|
+
}
|
|
134
211
|
const upscaled = g.node('MinimaxH3LatentUpscaler3DRefineHandoff', {
|
|
135
|
-
latent:
|
|
136
|
-
|
|
137
|
-
model: sigmaModel, positive,
|
|
212
|
+
latent: lat, noise, sampler: plane.samplerSel, sigmas: sched,
|
|
213
|
+
model: mdl, positive: cond,
|
|
138
214
|
model_name: REFINE_UPSCALE_MODEL,
|
|
139
|
-
|
|
140
|
-
// declares `mode` as a plain combo and `scale` as its OWN required
|
|
141
|
-
// top-level FLOAT (production /object_info + the vendored
|
|
142
|
-
// minimax_h3_refine.py:349-353) — there is no `mode.scale` seat on
|
|
143
|
-
// it. The dotted spelling belongs to MinimaxH3LatentUpscaler3D
|
|
144
|
-
// (COMFY_DYNAMICCOMBO_V3, chainUpscale.ts), a DIFFERENT node; the
|
|
145
|
-
// round-5 cure crossed the two and reintroduced
|
|
146
|
-
// required_input_missing on this member.
|
|
147
|
-
mode: upMode, scale: upScale,
|
|
148
|
-
// Multiplier mode ignores these (the film's own note at its
|
|
149
|
-
// handoff mount) — they ride the upscaler's own defaults.
|
|
215
|
+
mode: dials.upMode, scale: dials.upScale,
|
|
150
216
|
width: 1280, height: 704, megapixels: 1,
|
|
151
217
|
keep_proportion: true, align: 32,
|
|
152
218
|
lock_audio: true, cfg: 1.0, device: 'cuda', precision: 'bf16',
|
|
153
219
|
offload_after_upscale: false,
|
|
154
220
|
}).out(0);
|
|
155
|
-
|
|
156
|
-
let
|
|
157
|
-
let adec = g.node('VAEDecodeAudio', { samples: upscaled, vae: vaeAudio }).out(0);
|
|
221
|
+
let vdec = g.node('VAEDecode', { samples: upscaled, vae: plane.vaeVideo }).out(0);
|
|
222
|
+
let adec = g.node('VAEDecodeAudio', { samples: upscaled, vae: plane.vaeAudio }).out(0);
|
|
158
223
|
if (seat.overlapFrames > 0) {
|
|
159
|
-
// THE CARRIED HEAD
|
|
160
|
-
//
|
|
161
|
-
//
|
|
162
|
-
// hard audio trim (the carried seam leaves picture AND sound).
|
|
224
|
+
// THE CARRIED HEAD: the film's own finalize node, the film's own
|
|
225
|
+
// seats (iteration 1, the carried span, audio trimmed with the
|
|
226
|
+
// picture) — the seam is never replayed and never blended.
|
|
163
227
|
const fin = g.node('MiniMaxH3FiniteSegmentFinalize', {
|
|
164
228
|
sampled_latent: upscaled, images: vdec, audio: adec,
|
|
165
229
|
iteration: 1, overlap_frames: seat.overlapFrames, trim_audio_head: true,
|
|
@@ -170,10 +234,52 @@ export function renderH3RefineWindow(entry, p, facts, g, seat) {
|
|
|
170
234
|
const created = g.node('CreateVideo', {
|
|
171
235
|
images: vdec, audio: filmJoinAudio(g, adec), fps: 24, bit_depth: 8,
|
|
172
236
|
});
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
237
|
+
return {
|
|
238
|
+
save: g.node('SaveVideo', {
|
|
239
|
+
video: created.out(), filename_prefix: seat.prefix,
|
|
240
|
+
format: 'mp4', codec: 'h264',
|
|
241
|
+
}).out(0),
|
|
242
|
+
target,
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
export function renderH3RefineWindow(entry, p, facts, g, seat) {
|
|
258
|
+
if (!Number.isInteger(seat.cap) || seat.cap < 1) {
|
|
259
|
+
throw new Error(`h3-timeline refine: a ${seat.cap} f window — a refine window needs frames (the loop's cap is the loader's frame_load_cap at 24 fps; the design window is ${REFINE_DEFAULT_CLIP_SECONDS} s = ${Math.round(REFINE_DEFAULT_CLIP_SECONDS * 24)} f, the 2 s class's rung — the carry-joined window, not the widest-green workaround)`);
|
|
260
|
+
}
|
|
261
|
+
if (!Number.isInteger(seat.skip) || seat.skip < 0) {
|
|
262
|
+
throw new Error(`h3-timeline refine: a window starting at frame ${seat.skip} — a window starts at or after the clip's first frame (the loop's skip is the loader's skip_first_frames)`);
|
|
263
|
+
}
|
|
264
|
+
const plane = h3MaskedEditPlane(g, p, facts, seat.cap / 24);
|
|
265
|
+
return composeRefineWindow(g, entry, p, plane, seat, 0).save;
|
|
266
|
+
}
|
|
267
|
+
/** ONE entry's window ORIGIN seats (the loader's coordinates, derived
|
|
268
|
+
* from the seconds the entry states — the film clock, 24 fps). One
|
|
269
|
+
* owner for the single-window arm and the bag carrier, so both doors
|
|
270
|
+
* judge a stated length/start identically.
|
|
271
|
+
* @param entry the refine entry (clip_seconds, start_seconds)
|
|
272
|
+
* @returns the window's frame cap and first frame */
|
|
273
|
+
function refineWindowOrigin(entry) {
|
|
274
|
+
const clipSeconds = num(entry, 'clip_seconds', REFINE_DEFAULT_CLIP_SECONDS);
|
|
275
|
+
const startSeconds = num(entry, 'start_seconds', 0);
|
|
276
|
+
if (!(clipSeconds > 0)) {
|
|
277
|
+
throw new Error(`h3-timeline refine: clip_seconds ${clipSeconds} — a refine window needs frames (the seat is the loader's frame_load_cap: seconds × 24 at the film clock; the design window is ${REFINE_DEFAULT_CLIP_SECONDS} s = ${Math.round(REFINE_DEFAULT_CLIP_SECONDS * 24)} f, the 2 s class's rung — the carry-joined window, not the widest-green workaround)`);
|
|
278
|
+
}
|
|
279
|
+
if (!(startSeconds >= 0)) {
|
|
280
|
+
throw new Error(`h3-timeline refine: start_seconds ${startSeconds} — a window starts at or after the clip's first frame (the seat is the loader's skip_first_frames); advance it window by window to cover a long film`);
|
|
281
|
+
}
|
|
282
|
+
return { cap: Math.max(1, Math.round(clipSeconds * 24)), skip: Math.round(startSeconds * 24) };
|
|
177
283
|
}
|
|
178
284
|
/** The refine renderer: validates the bound entry, then composes
|
|
179
285
|
* the standalone single-window second pass. Like the swap, the film
|
|
@@ -187,19 +293,14 @@ export function renderH3RefineWindow(entry, p, facts, g, seat) {
|
|
|
187
293
|
* — the family plane this refine renders under)
|
|
188
294
|
* @param facts the family's lane facts (unet off the DECL row)
|
|
189
295
|
* @param g the run's graph builder
|
|
190
|
-
* @param runId the run tree's id (the refine filename rides it)
|
|
296
|
+
* @param runId the run tree's id (the refine filename rides it)
|
|
297
|
+
* @returns the window's SaveVideo passthrough (the bag carrier's
|
|
298
|
+
* N=1 delegate returns the same handle; statement callers ignore it) */
|
|
191
299
|
export function renderH3Refine(entry, p, facts, g, runId) {
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
if (!(startSeconds >= 0)) {
|
|
198
|
-
throw new Error(`h3-timeline refine: start_seconds ${startSeconds} — a window starts at or after the clip's first frame (the seat is the loader's skip_first_frames); advance it window by window to cover a long film`);
|
|
199
|
-
}
|
|
200
|
-
renderH3RefineWindow(entry, p, facts, g, {
|
|
201
|
-
cap: Math.max(1, Math.round(clipSeconds * 24)),
|
|
202
|
-
skip: Math.round(startSeconds * 24),
|
|
300
|
+
const { cap, skip } = refineWindowOrigin(entry);
|
|
301
|
+
return renderH3RefineWindow(entry, p, facts, g, {
|
|
302
|
+
cap,
|
|
303
|
+
skip,
|
|
203
304
|
overlapFrames: 0,
|
|
204
305
|
prefix: `${runId}/refine`,
|
|
205
306
|
});
|
|
@@ -232,6 +333,369 @@ export function renderH3Refine(entry, p, facts, g, runId) {
|
|
|
232
333
|
|
|
233
334
|
|
|
234
335
|
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
|
|
384
|
+
export const tokenExactCarry = (frames) => Number.isInteger(frames) && frames >= 5 && (frames - 5) % 17 === 0;
|
|
385
|
+
/** The next token-exact carry at or above a measured span — the rung
|
|
386
|
+
* a refusal names so the fix is a stated number, not a search.
|
|
387
|
+
* @param frames the measured carry in frames
|
|
388
|
+
* @returns the smallest token-exact carry ≥ `frames` */
|
|
389
|
+
export const nextTokenExact = (frames) => frames <= 5 ? 5 : 5 + 17 * Math.ceil((frames - 5) / 17);
|
|
390
|
+
/** The most truthful start for the next window: the film's own 22 f
|
|
391
|
+
* seam when the previous window can hold it, else the largest
|
|
392
|
+
* token-exact carry the window can still advance from. The refusal
|
|
393
|
+
* names this frame, so the fix is one edited Start seconds.
|
|
394
|
+
* @param prev the previous window's origin (cap + skip at the film clock)
|
|
395
|
+
* @returns the next window's start frame, or null when the window is
|
|
396
|
+
* too short for any carried join */
|
|
397
|
+
export const lawfulCarryStart = (prev) => {
|
|
398
|
+
for (const carry of [22, 5, 39, 56, 73, 90, 107, 124, 141]) {
|
|
399
|
+
if (carry < prev.cap)
|
|
400
|
+
return prev.skip + prev.cap - carry;
|
|
401
|
+
}
|
|
402
|
+
return null;
|
|
403
|
+
};
|
|
404
|
+
/** THE TILING SEATS — the two seats that set a member's geometry
|
|
405
|
+
* (mode + scale). Prompts and dials stay per-window (the film's own
|
|
406
|
+
* freedom: every window composes its own conditioning), but one
|
|
407
|
+
* film joins one shape, so a bag that states different tiling seats
|
|
408
|
+
* refuses.
|
|
409
|
+
* @param a the entry the face reads (bag[0])
|
|
410
|
+
* @param b the entry compared against it
|
|
411
|
+
* @returns one entry per differing tiling seat, empty when they agree */
|
|
412
|
+
const refineTilingDiff = (a, b) => {
|
|
413
|
+
const out = [];
|
|
414
|
+
const modeA = a['mode'] ?? 'scale by multiplier';
|
|
415
|
+
const modeB = b['mode'] ?? 'scale by multiplier';
|
|
416
|
+
if (modeA !== modeB)
|
|
417
|
+
out.push(`mode ('${modeA}' vs '${modeB}')`);
|
|
418
|
+
const scaleA = num(a, 'scale', 2.0);
|
|
419
|
+
const scaleB = num(b, 'scale', 2.0);
|
|
420
|
+
if (scaleA !== scaleB)
|
|
421
|
+
out.push(`scale (${String(scaleA)} vs ${String(scaleB)})`);
|
|
422
|
+
return out;
|
|
423
|
+
};
|
|
424
|
+
/** THE CARRY FACE — N windows of ONE film, each join riding the
|
|
425
|
+
* FILM'S OWN SEAM NODE (round 27; operator order: "ZERO DIFFERENCE
|
|
426
|
+
* BETWEEN THE CONTEXT CARRY FROM THE NORMAL GENS AND THE REFINE
|
|
427
|
+
* GENS"). Every window composes the single-press body (joint AV
|
|
428
|
+
* target → [MiniMaxH3FiniteLatentContinuation] → the 2x handoff →
|
|
429
|
+
* decode → head-trim → SaveVideo); window k's continuation receives
|
|
430
|
+
* window k−1's joint target as `previous_latent` with the film's
|
|
431
|
+
* seats (iteration, the carried overlap, continue_audio_latent true,
|
|
432
|
+
* the model + sigmas the handoff samples with), and the film tail is
|
|
433
|
+
* the film's own join — the finalize head-trim per window, then the
|
|
434
|
+
* plain file concat ordered by the unload boundary chain. No
|
|
435
|
+
* crossfade, no list-seat copy, no refine-only carry: the same node,
|
|
436
|
+
* the same overlap, the same audio release, the same trim.
|
|
437
|
+
*
|
|
438
|
+
* PER-ENTRY CONDITIONING IS LAWFUL: each window composes its own
|
|
439
|
+
* CLIPTextEncode/RandomNoise/BasicScheduler from ITS entry, so a bag
|
|
440
|
+
* of different prompts refines window by window (the film's own
|
|
441
|
+
* freedom). Only the tiling seats must agree — they set the member
|
|
442
|
+
* geometry and one film joins one shape.
|
|
443
|
+
* @param entries the bag's entries, film order (one per window)
|
|
444
|
+
* @param p the walked doc params
|
|
445
|
+
* @param facts the family's lane facts
|
|
446
|
+
* @param g the run's graph builder
|
|
447
|
+
* @param windows each window's cap + skip, film order (≥ 2)
|
|
448
|
+
* @param carries each join's carried overlap in frames (one per join)
|
|
449
|
+
* @param runId the run tree's id (member + film prefixes ride it)
|
|
450
|
+
* @returns the assembled film's SaveVideo passthrough */
|
|
451
|
+
/** THE CARRY LAW, judged without emitting (the stand-down and the
|
|
452
|
+
* carrier share one judge): the entries tile the stated windows one
|
|
453
|
+
* per window, every join is token-exact, each window passes its own
|
|
454
|
+
* seat/ceiling door, and the tiling seats (mode + scale) agree across
|
|
455
|
+
* the film. Called by `renderH3RefineCarry` before its walk and by
|
|
456
|
+
* the bag/loop before the F3-14 stand-down, so a malformed shape
|
|
457
|
+
* keeps its own better voice and the stand-down owns only lawful
|
|
458
|
+
* carries.
|
|
459
|
+
* @param entries the film's entries, film order (one per window)
|
|
460
|
+
* @param windows each window's cap + skip, film order (≥ 2)
|
|
461
|
+
* @param carries each join's carried overlap in frames (one per join) */
|
|
462
|
+
function assertRefineCarryLawful(entries, windows, carries) {
|
|
463
|
+
if (entries.length !== windows.length) {
|
|
464
|
+
throw new Error(`h3-timeline refine: the carry face names ${entries.length} entries over ${windows.length} windows — one entry per window, film order`);
|
|
465
|
+
}
|
|
466
|
+
if (windows.length < 2 || carries.length !== windows.length - 1) {
|
|
467
|
+
throw new Error(`h3-timeline refine: the carry face tiles ${windows.length} windows over ${carries.length} joins — at least two windows and one carried join each, in film order`);
|
|
468
|
+
}
|
|
469
|
+
if (!carries.every(tokenExactCarry)) {
|
|
470
|
+
throw new Error(`h3-timeline refine: the carry face carries ${carries.join(', ')} f — every join must be token-exact (frames >= 5 and (frames - 5) % 17 === 0: 5, 22, 39 …; the H3 VAE maps 5 frames to 2 latent tokens, then 17 frames to every 5 further tokens); a non-exact overlap refuses — the crossfade of two independent renders is the ghost, never a silent snap`);
|
|
471
|
+
}
|
|
472
|
+
for (let k = 0; k < windows.length; k += 1) {
|
|
473
|
+
const w = windows[k];
|
|
474
|
+
if (!Number.isInteger(w.cap) || w.cap < 1) {
|
|
475
|
+
throw new Error(`h3-timeline refine: the carry face's window ${k} carries cap ${w.cap} f — a whole frame count at or above one`);
|
|
476
|
+
}
|
|
477
|
+
if (!Number.isInteger(w.skip) || w.skip < 0) {
|
|
478
|
+
throw new Error(`h3-timeline refine: the carry face's window ${k} starts at skip ${w.skip} — a whole frame offset at or above zero`);
|
|
479
|
+
}
|
|
480
|
+
const dials = refineDials(entries[k]);
|
|
481
|
+
requireRefineEntry(entries[k]);
|
|
482
|
+
judgeRefineWindow(w.cap, dials);
|
|
483
|
+
if (k === 0)
|
|
484
|
+
continue;
|
|
485
|
+
const carry = carries[k - 1];
|
|
486
|
+
if (carry >= w.cap) {
|
|
487
|
+
throw new Error(`h3-timeline refine: window ${k} carries ${carry} f of its ${w.cap} f — the carried head must leave frames of its own to refine (a window at or below the carried span re-renders nothing)`);
|
|
488
|
+
}
|
|
489
|
+
if (carry >= windows[k - 1].cap) {
|
|
490
|
+
throw new Error(`h3-timeline refine: the join into window ${k} carries ${carry} f but window ${k - 1} holds only ${windows[k - 1].cap} f — a carry cannot exceed the window it comes from`);
|
|
491
|
+
}
|
|
492
|
+
const diffs = refineTilingDiff(entries[0], entries[k]);
|
|
493
|
+
if (diffs.length > 0) {
|
|
494
|
+
throw new Error(`h3-timeline refine: window ${k} states ${diffs.join('; ')} against window 0's — the members would save at different shapes and one film joins one shape (the tiling seats are mode + scale; prompts and dials stay per-window)`);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
export function renderH3RefineCarry(entries, p, facts, g, windows, carries, runId) {
|
|
499
|
+
assertRefineCarryLawful(entries, windows, carries);
|
|
500
|
+
// ── ONE shared plane for the whole film (the film's own posture:
|
|
501
|
+
// one unet stack, one clip, the two VAEs; the boundary chain below
|
|
502
|
+
// orders the saves, never a second unet) ──
|
|
503
|
+
const plane = h3MaskedEditPlane(g, p, facts, windows[0].cap / 24);
|
|
504
|
+
// ── the film's own walk: window k≥2 carries window k−1's joint
|
|
505
|
+
// target through the film's seam node, saves its trimmed member
|
|
506
|
+
// under its own prefix, and the boundary chain orders every save
|
|
507
|
+
// before the concat reads the files back ──
|
|
508
|
+
const saves = [];
|
|
509
|
+
const prefixes = [];
|
|
510
|
+
let previous;
|
|
511
|
+
for (let k = 0; k < windows.length; k += 1) {
|
|
512
|
+
const prefix = `${runId}/refine_w${k}`;
|
|
513
|
+
const body = composeRefineWindow(g, entries[k], p, plane, {
|
|
514
|
+
cap: windows[k].cap,
|
|
515
|
+
skip: windows[k].skip,
|
|
516
|
+
overlapFrames: k === 0 ? 0 : carries[k - 1],
|
|
517
|
+
prefix,
|
|
518
|
+
}, k, previous);
|
|
519
|
+
saves.push(body.save);
|
|
520
|
+
prefixes.push(prefix);
|
|
521
|
+
previous = body.target;
|
|
522
|
+
}
|
|
523
|
+
const boundary = chainSaveBoundaries(g, saves);
|
|
524
|
+
return concatSavedFilms(g, prefixes, boundary, `${runId}/refine`);
|
|
525
|
+
}
|
|
526
|
+
export function renderH3RefineBag(bag, p, facts, g, runId) {
|
|
527
|
+
// The card door arms on bag presence (refineArmed) — an empty bag
|
|
528
|
+
// here is a wiring bug, never user input. Refuse loud at the seam.
|
|
529
|
+
if (!Array.isArray(bag) || bag.length === 0) {
|
|
530
|
+
throw new Error('h3-timeline refine: the bag arrived empty at the family carrier — the card door arms on a non-empty refine bag, so this is a compose-wiring bug, not a doc to fix');
|
|
531
|
+
}
|
|
532
|
+
// THE SEQUENTIAL-PRESS LAW (F36): one entry IS the arm's own
|
|
533
|
+
// single-window emission — byte-identical, no boundary, no concat.
|
|
534
|
+
// The walk posture (press, judge, press) stays lawful through this
|
|
535
|
+
// delegate, and a doc that needs no tiling pays nothing for it.
|
|
536
|
+
|
|
537
|
+
// can make windows, but the human operator can't"): a LONE entry
|
|
538
|
+
// stating windows > 1 tiles ITSELF through the F24 loop renderer —
|
|
539
|
+
// the compose derives every window's start (start_seconds + k ×
|
|
540
|
+
// (cap − overlap)), so the human states a window SIZE and a COUNT
|
|
541
|
+
// instead of hand-tiling N entries with frame-exact starts the
|
|
542
|
+
// 0.25-step dials cannot reach. windows = 1 keeps the delegate
|
|
543
|
+
// above byte-identically (a lone window has no join, so a stated
|
|
544
|
+
// overlap_frames rides along unused — the seat's own tooltip says
|
|
545
|
+
// so, never a silent second meaning). A windows > 1 seat on ANY
|
|
546
|
+
// entry of a MULTI-entry bag refuses below — two tilings stated,
|
|
547
|
+
// and the bag already IS one.
|
|
548
|
+
if (bag.length === 1) {
|
|
549
|
+
const entry = bag[0];
|
|
550
|
+
const stated = entry['windows'];
|
|
551
|
+
const windows = typeof stated === 'number' ? stated : 1;
|
|
552
|
+
if (windows !== 1) {
|
|
553
|
+
if (!Number.isInteger(windows) || windows < 2 || windows > MAX_COMPOSED_WINDOWS) {
|
|
554
|
+
throw new Error(`h3-timeline refine: windows ${String(stated)} — one entry auto-tiles a whole number of windows from 2 to ${MAX_COMPOSED_WINDOWS} (1 is the single-window walk posture: judge each window before pressing the next); hand-tiled entries are the bag's own shape for mixed-seat films`);
|
|
555
|
+
}
|
|
556
|
+
const rawOverlap = entry['overlap_frames'];
|
|
557
|
+
const overlap = rawOverlap === undefined ? REFINE_DEFAULT_OVERLAP_FRAMES : rawOverlap;
|
|
558
|
+
if (!Number.isInteger(overlap) || overlap < 0) {
|
|
559
|
+
throw new Error(`h3-timeline refine: overlap_frames ${String(rawOverlap)} — the carried overlap is whole frames at or above zero (22 is the film's own seam and token-exact: 5, 22, 39 … the film's own continuation carries each join; any other overlap of 1 or more refuses — a crossfade of two independent renders is not served; 0 abuts with the hard cut)`);
|
|
560
|
+
}
|
|
561
|
+
return renderH3RefineWindows(entry, p, facts, g, runId, { windows, overlapFrames: overlap });
|
|
562
|
+
}
|
|
563
|
+
return renderH3Refine(entry, p, facts, g, runId);
|
|
564
|
+
}
|
|
565
|
+
if (bag.some((e) => typeof e['windows'] === 'number' && e['windows'] > 1)) {
|
|
566
|
+
throw new Error('h3-timeline refine: a multi-entry bag states windows above 1 — the bag already IS the tiling (each entry is one window, placed by its own start_seconds); state windows on ONE lone entry to auto-tile, or tile the entries by hand');
|
|
567
|
+
}
|
|
568
|
+
if (bag.length > MAX_COMPOSED_WINDOWS) {
|
|
569
|
+
throw new Error(`h3-timeline refine: the bag carries ${bag.length} entries — the film's composed-window ceiling is ${MAX_COMPOSED_WINDOWS} (${(MAX_COMPOSED_WINDOWS * (REFINE_DEFAULT_CLIP_SECONDS - 22 / 24)).toFixed(2)} s at the default window); refine a shorter film or raise clip_seconds inside the measured ${REFINE_2X_OOM_FRAMES} f ceiling`);
|
|
570
|
+
}
|
|
571
|
+
// LAW 1 — ONE FILM PER BAG: the staged leaf is per-entry text, so
|
|
572
|
+
// compare the named leaves. An entry naming NO leaf skips this
|
|
573
|
+
// comparison on purpose: the window renderer's own REQUIRED_SEATS
|
|
574
|
+
// refusal owns that voice (missing seat, not mixed sources).
|
|
575
|
+
const leaves = new Set();
|
|
576
|
+
for (const entry of bag) {
|
|
577
|
+
const leaf = entry['source_clip'];
|
|
578
|
+
if (typeof leaf === 'string' && leaf.trim() !== '')
|
|
579
|
+
leaves.add(leaf.trim());
|
|
580
|
+
}
|
|
581
|
+
if (leaves.size > 1) {
|
|
582
|
+
const named = [...leaves].map((l) => `'${l}'`).join(', ');
|
|
583
|
+
throw new Error(`h3-timeline refine: the bag's entries name ${leaves.size} different source clips (${named}) — ONE FILM PER BAG: a multi-entry refine tiles windows of ONE staged leaf into one film (the boundary chain + file join join windows of one timeline); two sources are two films, and a second card is the honest door for a second source`);
|
|
584
|
+
}
|
|
585
|
+
// LAW 2 — NO GAPS, NO FULL OVERLAP (the no-drop law): derive every
|
|
586
|
+
// window's origin first (the same validation the single-window arm
|
|
587
|
+
// runs, per entry), then judge consecutive entries in STATED order.
|
|
588
|
+
const origins = bag.map((entry) => refineWindowOrigin(entry));
|
|
589
|
+
for (let k = 1; k < origins.length; k += 1) {
|
|
590
|
+
const prev = origins[k - 1];
|
|
591
|
+
const cur = origins[k];
|
|
592
|
+
const overlap = prev.skip + prev.cap - cur.skip;
|
|
593
|
+
if (overlap < 0) {
|
|
594
|
+
throw new Error(`h3-timeline refine: window ${k} starts at frame ${cur.skip} but window ${k - 1} ends at frame ${prev.skip + prev.cap} — a ${-(overlap)} f gap silently drops source seconds (the no-drop law: consecutive windows overlap, never a hole; state window ${k} at or before frame ${prev.skip + prev.cap})`);
|
|
595
|
+
}
|
|
596
|
+
if (cur.skip <= prev.skip) {
|
|
597
|
+
throw new Error(`h3-timeline refine: window ${k} starts at frame ${cur.skip}, at or before window ${k - 1}'s start (frame ${prev.skip}) — out of order and fully covering the previous window (the compose never silently sorts; in film order every entry starts strictly after the one before it, carrying its tail as overlap)`);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
// Every entry binds BOTH seats before any join judgment: a bag whose
|
|
601
|
+
// second window names no prompt is malformed whichever join it would
|
|
602
|
+
// have taken, and the seat's own door says so (the carry refusal
|
|
603
|
+
// below owns stated-but-different seats, never an absent one).
|
|
604
|
+
for (const entry of bag) {
|
|
605
|
+
for (const [seat, what] of REQUIRED_SEATS) {
|
|
606
|
+
const v = entry[seat];
|
|
607
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
608
|
+
throw new Error(`h3-timeline refine: '${seat}' names no media — ${what}; a refine needs both seats bound (source_clip, refine_prompt)`);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
// THE TILING: one window body per entry, prefix k 0-based (the F24
|
|
613
|
+
// loop's walled spelling). THE JOIN FACE is decided by the carries:
|
|
614
|
+
// a bag whose every join CARRIES (≥ 1 f) rides the carry face — the
|
|
615
|
+
// film's own continuation per join, head-trim + plain concat — and
|
|
616
|
+
// a bag with ANY zero-carry join keeps the independent walk
|
|
617
|
+
// (head-trim for the overlaps it states, then the concat: a hard
|
|
618
|
+
// cut where nothing is carried). N=1 never reaches here (the
|
|
619
|
+
// sequential-press delegate above).
|
|
620
|
+
const originsCarries = [];
|
|
621
|
+
for (let k = 1; k < origins.length; k += 1) {
|
|
622
|
+
originsCarries.push(origins[k - 1].skip + origins[k - 1].cap - origins[k].skip);
|
|
623
|
+
}
|
|
624
|
+
const blendJoins = originsCarries.length > 0 && originsCarries.every((o) => o >= 1);
|
|
625
|
+
// THE GHOST IS NOT A FALLBACK (FRICTION F26, operator burn
|
|
626
|
+
|
|
627
|
+
// join is off the token grid cannot continue the stream — and the
|
|
628
|
+
|
|
629
|
+
// the blend fallback, was a linear crossfade of two INDEPENDENT
|
|
630
|
+
// renders: a double exposure at the seam. The measured burn: a
|
|
631
|
+
// hand-placed 20 f carry silently switched the mechanism and
|
|
632
|
+
// shipped the ghost. It refuses instead, naming the measured carry
|
|
633
|
+
// and the start that lands the film's own 22 f seam.
|
|
634
|
+
if (blendJoins) {
|
|
635
|
+
const offGrid = originsCarries.findIndex((c) => !tokenExactCarry(c));
|
|
636
|
+
if (offGrid !== -1) {
|
|
637
|
+
const carry = originsCarries[offGrid];
|
|
638
|
+
const prev = origins[offGrid];
|
|
639
|
+
const next = origins[offGrid + 1];
|
|
640
|
+
const lawful = lawfulCarryStart(prev);
|
|
641
|
+
const clockFps = num(p, 'fps', DOC_FPS_DEFAULT);
|
|
642
|
+
const rung = nextTokenExact(carry);
|
|
643
|
+
throw new Error(`h3-timeline refine: the join between windows ${offGrid} and ${offGrid + 1} carries ${carry} f (derived: ${prev.skip} + ${prev.cap} − ${next.skip}) — not token-exact, so the model cannot continue the stream across it (5 frames = 2 latent tokens, then 17 frames = every 5 further tokens: 5, 22, 39, 56 …). A crossfade of the two independent renders would hide the mismatch behind a double exposure (the ghost) and is not served. ${lawful === null
|
|
644
|
+
? `This window is too short for any carried join — state zero carry (abut the windows) or one entry with windows above 1.`
|
|
645
|
+
: `State window ${offGrid + 1} at frame ${lawful} (${(lawful / clockFps).toFixed(3)} s) for a 22 f carry — the film's own seam — (the nearest rung above the measured span is ${rung} f), or make the join zero-carry (start window ${offGrid + 1} at frame ${prev.skip + prev.cap}, the hard cut).`}`);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// operator order "the app cannot ever go all green while this is
|
|
649
|
+
// still broken"): the refinement pass now strips the foreign
|
|
650
|
+
// dynamic denoise-mask patch at the handoff that burned (the
|
|
651
|
+
// vendored MinimaxH3LatentUpscaler3DRefineHandoff clone-strips
|
|
652
|
+
// the Drift-Control AV function before its guider samples — the
|
|
653
|
+
// estate python wall tests/test_h3_refine_handoff_strip.py judges
|
|
654
|
+
// the cure live and pins the burn's verbatim ValueError). The
|
|
655
|
+
// shape judges above stay law; the carried bag rides the round-27
|
|
656
|
+
// carry walk (the "ZERO DIFFERENCE" seat).
|
|
657
|
+
assertRefineCarryLawful(bag, origins, originsCarries);
|
|
658
|
+
return renderH3RefineCarry(bag, p, facts, g, origins, originsCarries, runId);
|
|
659
|
+
}
|
|
660
|
+
const prefixes = [];
|
|
661
|
+
const saves = [];
|
|
662
|
+
for (let k = 0; k < bag.length; k += 1) {
|
|
663
|
+
const prefix = `${runId}/refine_w${k}`;
|
|
664
|
+
saves.push(renderH3RefineWindow(bag[k], p, facts, g, {
|
|
665
|
+
cap: origins[k].cap,
|
|
666
|
+
skip: origins[k].skip,
|
|
667
|
+
overlapFrames: k === 0 ? 0 : originsCarries[k - 1],
|
|
668
|
+
prefix,
|
|
669
|
+
}));
|
|
670
|
+
prefixes.push(prefix);
|
|
671
|
+
}
|
|
672
|
+
// THE FILM TAIL (one boundary chain, one join face here): one unload
|
|
673
|
+
// boundary per window save, the final token transitively depending
|
|
674
|
+
// on EVERY save (the §20 memory law — N windows must never
|
|
675
|
+
// co-reside), then the abutting concat into the one terminal film.
|
|
676
|
+
const boundary = chainSaveBoundaries(g, saves);
|
|
677
|
+
return concatSavedFilms(g, prefixes, boundary, `${runId}/refine`);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
|
|
235
699
|
|
|
236
700
|
|
|
237
701
|
|
|
@@ -247,7 +711,7 @@ export function renderH3RefineWindows(entry, p, facts, g, runId, loop) {
|
|
|
247
711
|
}
|
|
248
712
|
const clipSeconds = num(entry, 'clip_seconds', REFINE_DEFAULT_CLIP_SECONDS);
|
|
249
713
|
if (!(clipSeconds > 0)) {
|
|
250
|
-
throw new Error(`h3-timeline refine: clip_seconds ${clipSeconds} — a refine window needs frames (the seat is the loader's frame_load_cap: seconds × 24 at the film clock; the
|
|
714
|
+
throw new Error(`h3-timeline refine: clip_seconds ${clipSeconds} — a refine window needs frames (the seat is the loader's frame_load_cap: seconds × 24 at the film clock; the design window is ${REFINE_DEFAULT_CLIP_SECONDS} s = ${Math.round(REFINE_DEFAULT_CLIP_SECONDS * 24)} f, the 2 s class's rung — the carry-joined window, not the widest-green workaround)`);
|
|
251
715
|
}
|
|
252
716
|
const startFrames = Math.round(num(entry, 'start_seconds', 0) * 24);
|
|
253
717
|
const cap = Math.max(1, Math.round(clipSeconds * 24));
|
|
@@ -257,11 +721,42 @@ export function renderH3RefineWindows(entry, p, facts, g, runId, loop) {
|
|
|
257
721
|
}
|
|
258
722
|
const prefixes = [];
|
|
259
723
|
const saves = [];
|
|
724
|
+
// THE JOIN FACE has exactly TWO faces: a carried loop (windows ≥ 2,
|
|
725
|
+
// overlap ≥ 1) walks the film's own continuation per join (the
|
|
726
|
+
// carry face: MiniMaxH3FiniteLatentContinuation with the film's
|
|
727
|
+
// seats, head-trim + plain concat); a one-window loop or a
|
|
728
|
+
// zero-overlap loop keeps the independent walk (head-trim + concat,
|
|
729
|
+
// a hard cut where nothing is carried).
|
|
730
|
+
const blend = loop.windows >= 2 && loop.overlapFrames >= 1;
|
|
731
|
+
// THE GHOST IS NOT A FALLBACK (FRICTION F26, operator burn
|
|
732
|
+
|
|
733
|
+
// the film's own seam —, 39 …) cannot continue the stream, and the
|
|
734
|
+
|
|
735
|
+
// crossfade of two INDEPENDENT renders — a double exposure at the
|
|
736
|
+
// seam. It refuses, naming the grid and the next rung.
|
|
737
|
+
if (blend && !tokenExactCarry(loop.overlapFrames)) {
|
|
738
|
+
const rung = nextTokenExact(loop.overlapFrames);
|
|
739
|
+
throw new Error(`h3-timeline refine: the loop carries a ${loop.overlapFrames} f overlap — not token-exact, so the model cannot continue the stream across it (5 frames = 2 latent tokens, then 17 frames = every 5 further tokens: 5, 22, 39, 56 …). A crossfade of the two independent renders would hide the mismatch behind a double exposure (the ghost) and is not served. State overlap_frames 22 — the film's own seam — (the nearest rung above ${loop.overlapFrames} f is ${rung} f), another rung of the grid, or 0 for the abutting hard cut.`);
|
|
740
|
+
}
|
|
741
|
+
if (blend) {
|
|
742
|
+
const windows = Array.from({ length: loop.windows }, (_, k) => ({
|
|
743
|
+
cap, skip: startFrames + k * step,
|
|
744
|
+
}));
|
|
745
|
+
const carries = new Array(loop.windows - 1).fill(loop.overlapFrames);
|
|
746
|
+
const entries = new Array(loop.windows).fill(entry);
|
|
747
|
+
|
|
748
|
+
// the handoff strips the foreign Drift-Control patch before its
|
|
749
|
+
// second pass (tests/test_h3_refine_handoff_strip.py judges the
|
|
750
|
+
// cure live); the loop's carried joins ride the same round-27
|
|
751
|
+
// carry walk as the bag's.
|
|
752
|
+
assertRefineCarryLawful(entries, windows, carries);
|
|
753
|
+
return renderH3RefineCarry(entries, p, facts, g, windows, carries, runId);
|
|
754
|
+
}
|
|
260
755
|
for (let k = 0; k < loop.windows; k += 1) {
|
|
261
756
|
const prefix = `${runId}/refine_w${k}`;
|
|
262
757
|
saves.push(renderH3RefineWindow(entry, p, facts, g, {
|
|
263
758
|
cap, skip: startFrames + k * step,
|
|
264
|
-
overlapFrames:
|
|
759
|
+
overlapFrames: 0,
|
|
265
760
|
prefix,
|
|
266
761
|
}));
|
|
267
762
|
prefixes.push(prefix);
|