Skip to content

One-click character swap for videos: an open-source, local Higgsfield Genjutsu alternative built on ComfyUI and MiniMax H3, with FLUX.3 Klein relighting.

Make Montage Generate one click

D3voz46d98d31327b
diff --git a/README.md b/README.md
index 8f9703a..69dd00a 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,7 @@ On Windows, double-click `start_openjutsu.bat` (ComfyUI must be running, or star
A 6 s clip at 480p takes about 6–13 minutes on a 4060 Ti, most of it in H3 sampling. 736p is the default; 1080p is about 2.5× slower than 736p and needs much more memory. Custom sets an exact width × height from 256 to 2048 px a side (rounded to 32); the video is scaled and centre-cropped to that shape first. It needs the `short_edge` input of the H3 Swap Plan nodes in comfyui-h3-oneclick-swap.
-Advanced motion transfer has a **Montage** tab for edited clips where different people take turns within one shot without a hard cut (whip pans, selfie handovers, travel montages). Write roles as "who - looks" ("the dancer - white polo, jeans"): the looks help match the people, and only the part before " - " reaches H3. **Find people** (about 3 minutes for 18 s of video) tracks everyone with SAM over the whole video and matches each appearance to the roles with Qwen (a person SAM loses and finds again is matched again, so they keep their photo), then lists the appearances with a photo picker each. Find people saves the tracks, and the render masks with exactly those; nothing is tracked again. The video is made as one chain like Standard, with overlapping clips: each clip has one H3 pass per photo on screen in it (the two with the most screen time) that masks only that photo's appearances, with a prompt about that person only. It needs the pack's `H3MontagePeople`, `H3MontageTracks`, `H3MontagePlan` and `H3MontagePass` nodes. The saved tracks live in ComfyUI's temp folder, so after a ComfyUI restart, Find people again.
+Advanced motion transfer has a **Montage** tab for edited clips where different people take turns within one shot without a hard cut (whip pans, selfie handovers, travel montages). Write roles as "who - looks" ("the dancer - white polo, jeans"): the looks help match the people, and only the part before " - " reaches H3. **Generate** tracks everyone with SAM over the whole video, matches each appearance to the roles with Qwen (a person SAM loses and finds again is matched again, so they keep their photo) and makes the video as one chain like Standard, with overlapping clips: each clip has one H3 pass per photo on screen in it (the two with the most screen time) that masks only that photo's appearances, with a prompt about that person only. Appearances on screen for under 12 frames or at under 2% of the frame stay as they are, since H3 draws them as grey figures; the result page lists them. **Find people** (about 3 minutes for 18 s of video) is the optional review: it does the tracking and matching alone, lists the appearances with a photo picker each and saves the tracks, and Generate from that list masks with exactly those tracks. The saved tracks live in ComfyUI's temp folder and are checked against the video, part and size, so after a ComfyUI restart or a change, Find people again. It needs the pack's `H3MontagePeople`, `H3MontageTracks`, `H3MontagePicks`, `H3MontagePlan` and `H3MontagePass` nodes.
## Tips
diff --git a/app/api/jobs/route.ts b/app/api/jobs/route.ts
index 071813f..785f8fb 100644
--- a/app/api/jobs/route.ts
+++ b/app/api/jobs/route.ts
@@ -166,12 +166,14 @@ function parseLabels(entry: FormDataEntryValue | null, photos: number): Label[]
return labels.map(({ track, start, end, role }) => ({ track, start, end, role }));
}
+// Without tracks the montage finds the people itself and starts from the default picks; with them, the person list's picks are used.
function parseMontage(form: FormData) {
const { pictures, settings } = parseAdvanced(form);
if (pictures.length !== parsePeople(form).roles.length) throw new Error("Give each photo a role.");
- const tracks = String(form.get("tracks") ?? "");
- if (!TRACKS_FILE.test(tracks)) throw new Error("Find people again.");
- return { pictures, settings, tracks, labels: parseLabels(form.get("labels"), pictures.length) };
+ const tracks = form.get("tracks");
+ if (tracks === null) return { pictures, settings, review: null };
+ if (!TRACKS_FILE.test(String(tracks))) throw new Error("Find people again.");
+ return { pictures, settings, review: { tracks: String(tracks), labels: parseLabels(form.get("labels"), pictures.length) } };
}
export async function POST(request: Request) {
@@ -188,9 +190,9 @@ export async function POST(request: Request) {
const { roles, resolution } = parsePeople(form);
submit = () => submitPeople(video, section, roles, resolution);
} else if (mode === "montage") {
- const { pictures, settings, tracks, labels } = parseMontage(form);
+ const { pictures, settings, review } = parseMontage(form);
const model = parseModel(form, await listModels());
- submit = () => submitMontage(video, section, pictures, settings, tracks, labels, model);
+ submit = () => submitMontage(video, section, pictures, settings, review, model);
} else if (mode === "simple") {
const { picture, settings } = parseSimple(form);
const model = parseModel(form, await listModels());
diff --git a/components/openjutsu.tsx b/components/openjutsu.tsx
index 988dcad..e1951d1 100644
--- a/components/openjutsu.tsx
+++ b/components/openjutsu.tsx
@@ -10,7 +10,7 @@ import { DEFAULT_MODEL, MAX_LORAS, STEPS, STRENGTH, type Lora } from "../lib/mod
import type { EditMode } from "../lib/object.ts";
import { CHUNK_SECONDS, faceChunkCount, type FaceStyle } from "../lib/face.ts";
import { DEFAULT_PRESET, DEFAULT_TONE, DETAIL, TONE_MODES, TONE_RANGES, toneFromPreset, type ToneSettings, type ToneValue } from "../lib/color.ts";
-import { appearances, renderLabels, type Appearance, type Label, type People } from "../lib/montage.ts";
+import { appearances, renderLabels, type Appearance, type Kept, type Label, type People, type Review } from "../lib/montage.ts";
type Character = { file: File; url: string; role: string };
type Mode = "simple" | "advanced" | "object" | "post";
@@ -318,7 +318,7 @@ export function Openjutsu() {
setLook({ file: files[0], url: URL.createObjectURL(files[0]) });
}
- async function submit(kind: Kind, montagePicks?: { tracks: string; labels: Label[] }) {
+ async function submit(kind: Kind, review?: Review) {
if (!video || (kind !== "mask" && kind !== "people" && !ready)) return;
setSubmitting(true);
setFormError("");
@@ -365,8 +365,10 @@ export function Openjutsu() {
form.append("picture", c.file);
form.append("role", c.role);
}
- form.set("tracks", montagePicks?.tracks ?? "");
- form.set("labels", JSON.stringify(montagePicks?.labels ?? []));
+ if (review) {
+ form.set("tracks", review.tracks);
+ form.set("labels", JSON.stringify(review.labels));
+ }
form.set("resolution", resolutionField);
form.set("seed", String(seed));
form.set("clip_seconds", String(clipSeconds));
@@ -533,8 +535,8 @@ export function Openjutsu() {
{montage && (
<p className="hint">
For edited clips where different people take turns within one shot, with no hard cut between them: whip pans,
- selfie handovers, travel and &ldquo;vibe&rdquo; montages. Find people tracks everyone over the whole video and matches
- them to the photos; you check each appearance and pick its photo, then the video is made in one go. Give every photo a role with a look after
+ selfie handovers, travel and &ldquo;vibe&rdquo; montages. Generate tracks everyone over the whole video, matches them to the
+ photos and makes the video in one go. To check who becomes which photo first, use Find people. Give every photo a role with a look after
&ldquo; - &rdquo; (&ldquo;the dancer - white polo, jeans&rdquo;) so the people can be told apart. Use Standard for everything else.
</p>
)}
@@ -807,9 +809,10 @@ export function Openjutsu() {
<div className="go">
<div className="row">
{mode === "simple" && <button className="secondary" disabled={!video || submitting} onClick={() => submit("mask")}>Check mask</button>}
- {mode === "advanced" && montage ? (
- <button className="primary" disabled={!video || !character || submitting} onClick={() => submit("people")}>{submitting ? "Uploading…" : "Find people"}</button>
- ) : (
+ {mode === "advanced" && montage ? (<>
+ <button className="secondary" disabled={!video || !character || submitting} onClick={() => submit("people")}>Find people</button>
+ <button className="primary" disabled={!video || !character || submitting} onClick={() => submit("montage")}>{submitting ? "Uploading…" : "Generate"}</button>
+ </>) : (
<button className="primary" disabled={!video || !ready || submitting} onClick={() => submit(mode === "object" ? fromPicture ? "simple" : "object" : mode === "post" ? post : mode === "simple" ? "simple" : onePassEach ? "advanced_maxq" : "advanced")}>
{submitting ? "Uploading…" : "Generate"}
</button>
@@ -818,7 +821,7 @@ export function Openjutsu() {
<small>{colorFix
? !video ? "Add a video." : ready ? `${(part.length || video.duration).toFixed(1)} s of video` : "Turn on detail contrast, the tone mapper or both."
: clips && ready
- ? mode === "advanced" && montage ? "About 3 minutes per 18 s of video; then you check who becomes which photo and generate."
+ ? mode === "advanced" && montage ? `${clips} clip${clips > 1 ? "s" : ""} or more at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}; Find people (about 3 minutes per 18 s) lets you check the picks first.`
: faceFix ? `Up to ${clips} chunk${clips > 1 ? "s" : ""} of face` : `${clips} clip${clips > 1 ? "s" : ""} at ${canvas ? `${canvas[0]}×${canvas[1]}` : resolution}`
: `Add a video and ${mode === "object" ? "say what it becomes" : faceFix ? "the photo of the person" : mode === "simple" ? "a character photo" : "character photos"}.`}</small>
</div>
@@ -861,6 +864,7 @@ function RunView({ run, job, progress, preview, streamError, now, onCancel, onRe
return (
<section className="panel result">
<video src={job.video.url} controls autoPlay playsInline />
+ {run.kind === "montage" && job.data && <KeptNote url={job.data} />}
<div className="row">
<a className="primary" href={`${job.video.url}?download`} download={job.video.name}>Download MP4</a>
<button className="secondary" onClick={onReset}>{run.kind === "object" ? "New edit" : run.kind === "face" || run.kind === "color" ? "Fix another" : "New swap"}</button>
@@ -979,6 +983,21 @@ function MaskCheck({ url, clipSeconds, checked, margin, onMargin, onRecheck, onG
);
}
+// A montage without review keeps brief or small appearances as they are; say so instead of passing the swap off as complete.
+function KeptNote({ url }: { url: string }) {
+ const [kept, setKept] = useState<Kept[]>([]);
+ useEffect(() => {
+ fetch(url).then((response) => response.json()).then((data: { kept: Kept[] }) => setKept(data.kept), () => setKept([]));
+ }, [url]);
+ if (!kept.length) return null;
+ return (
+ <p className="hint">
+ Left as they are, too {kept.every((k) => k.small) ? "small" : "brief or small"} for H3 to draw:{" "}
+ {kept.map((k) => `photo ${k.photo}'s person at ${timecode(k.start / 24)}–${timecode(k.end / 24)}`).join(", ")}. Use Find people to pick them anyway.
+ </p>
+ );
+}
+
function PersonList({ url, photos, onBack, onGenerate }: {
url: string; photos: string[]; onBack: () => void; onGenerate: ((tracks: string, labels: Label[]) => void) | null;
}) {
diff --git a/lib/comfy.ts b/lib/comfy.ts
index 877e97e..de05631 100644
--- a/lib/comfy.ts
+++ b/lib/comfy.ts
@@ -8,7 +8,7 @@ import { applyModel, type ModelSettings } from "./model.ts";
import { OBJECT_PICTURE, OBJECT_VIDEO, pruneObject, type ObjectSettings } from "./object.ts";
import { FACE_PICTURE, FACE_VIDEO, pruneFace, type FaceSettings } from "./face.ts";
import { COLOR_VIDEO, pruneColor, type ColorSettings } from "./color.ts";
-import { PEOPLE_NODES, peopleRoles, pruneMontage, type Label } from "./montage.ts";
+import { PEOPLE_NODES, peopleRoles, pruneMontage, type Review } from "./montage.ts";
export type PublicJob = {
id: string;
@@ -16,7 +16,7 @@ export type PublicJob = {
queuePosition: number | null;
error: string | null;
video: { id: string; name: string; url: string } | null;
- data: string | null; // what Find people found, as JSON
+ data: string | null; // JSON: what Find people found, or who a montage kept as they are
};
export const TERMINAL = new Set(["succeeded", "failed", "canceled", "expired"]);
@@ -138,9 +138,9 @@ export async function submitMask(video: File, section: Section, hatFix: boolean,
return publicJob(await comfy.submit(workflow));
}
-export async function submitMontage(video: File, section: Section, pictures: File[], settings: AdvancedSettings, tracks: string, labels: Label[], model: ModelSettings) {
+export async function submitMontage(video: File, section: Section, pictures: File[], settings: AdvancedSettings, review: Review | null, model: ModelSettings) {
const comfy = client();
- const graph = pruneMontage(await loadGraph("montage"), pictures.length, settings, tracks, labels);
+ const graph = pruneMontage(await loadGraph("montage"), pictures.length, settings, review);
applyModel(graph, model);
setSection(graph, nodeByTitle(graph, VIDEO), section);
const workflow = comfy.workflows.fromJson(graph);
diff --git a/lib/montage.ts b/lib/montage.ts
index 72c29ea..53354d9 100644
--- a/lib/montage.ts
+++ b/lib/montage.ts
@@ -1,27 +1,35 @@
-// Montage: for edited clips where people take turns within one shot. Find people (workflows/people.api.json) tracks every
-// person over the whole video, labels each appearance with a photo and saves the tracks; H3MontagePeople in
-// comfyui-h3-oneclick-swap writes the result. The render (workflows/montage.api.json) loads those same tracks and makes the
-// video as one chain, with one H3 pass per photo on screen in each clip.
+// Montage: for edited clips where people take turns within one shot. workflows/montage.api.json tracks every person over the
+// whole video, labels each appearance with a photo and makes the video as one chain, with one H3 pass per photo on screen in
+// each clip. To review the picks first, Find people (workflows/people.api.json) does the tracking and labelling alone and saves
+// the tracks (H3MontagePeople in comfyui-h3-oneclick-swap); the render then loads those tracks instead of tracking again.
import { PLAN, nodeByTitle, pruneAdvanced, type AdvancedSettings } from "./advanced.ts";
-import type { ApiGraph } from "./simple.ts";
+import { isLink, type ApiGraph } from "./simple.ts";
// One SAM track's appearance within one shot. It spans start..end (to the middle of the gaps around it), is on screen during
-// `on`, takes at most `area` of the frame and looks like photo `role` (0 = none). Frames count from the start of the part used, at 24 fps.
-export type Track = { track: number; start: number; end: number; role: number; on: [number, number][]; area: number; image: string };
+// `on`, takes at most `area` of the frame and looks like photo `role` (0 = none). pick: the photo it starts as, 0 to keep it
+// (brief or small appearances, which H3 draws as grey figures). Frames count from the start of the part used, at 24 fps.
+export type Track = { track: number; start: number; end: number; role: number; on: [number, number][]; area: number; pick: number; image: string };
// tracks: the file Find people saved them to, in ComfyUI's temp folder
export type People = { frames: number; tracks: string | null; people: Track[] };
-// pick: the photo this appearance becomes, 0 to keep it. small: never big enough for H3 to draw them.
-export type Appearance = Track & { frames: number; small: boolean; pick: number };
+// small: never big enough for H3 to draw them.
+export type Appearance = Track & { frames: number; small: boolean };
export type Label = { track: number; start: number; end: number; role: number };
+// The picks from the person list, and the tracks file Find people saved.
+export type Review = { tracks: string; labels: Label[] };
+// What a montage without review left as it is: a labelled appearance of `photo` too brief or small to swap.
+export type Kept = { photo: number; start: number; end: number; small: boolean };
// Node ids in workflows/people.api.json.
export const PEOPLE_NODES = { video: "1", crops: "6" };
export const TRACKS = "Tracks from Find people";
+// The montage graph's own tracking and labelling, for a run without review.
+const SAM = "SAM 3.1 track every person (whole video)";
+const CROPS = "Show each track per shot";
+const ANALYSIS = [SAM, CROPS, "Who is each track (Qwen3-VL)", "Read the track labels", "Picks without review"];
export const TRACKS_FILE = /^h3_montage_people_\d+_\.npz$/;
-// Appearances start as kept unless they are on screen this long and this big: H3 draws a brief or small,
-// far-off person as the grey figure of the motion reference instead of the photo.
+// Listed even when unlabelled once on screen this long or this big.
const BRIEF = 12;
const MIN_SHARE = 0.02;
@@ -33,8 +41,7 @@ export function appearances({ people }: People): Appearance[] {
return people
.map((t) => {
const frames = t.on.reduce((sum, [a, b]) => sum + b - a, 0);
- const small = t.area < MIN_SHARE;
- return { ...t, frames, small, pick: t.role && !small && frames >= BRIEF ? t.role : 0 };
+ return { ...t, frames, small: t.area < MIN_SHARE };
})
// unlabelled small flickers stay as they are either way; a big one may be part of someone (an arm, a knee)
.filter((a) => a.role || a.frames >= BRIEF || !a.small)
@@ -45,9 +52,20 @@ export function renderLabels(list: Appearance[]): Label[] {
return list.filter((a) => a.pick).map(({ track, start, end, pick }) => ({ track, start, end, role: pick }));
}
-export function pruneMontage(source: ApiGraph, pictures: number, settings: AdvancedSettings, tracks: string, labels: Label[]): ApiGraph {
+export function pruneMontage(source: ApiGraph, pictures: number, settings: AdvancedSettings, review: Review | null): ApiGraph {
const graph = pruneAdvanced(source, pictures, settings);
- graph[nodeByTitle(graph, PLAN)].inputs.labels = JSON.stringify(labels);
- graph[nodeByTitle(graph, TRACKS)].inputs.file = tracks;
+ const tracks = nodeByTitle(graph, TRACKS);
+ if (!review) {
+ delete graph[tracks];
+ graph[nodeByTitle(graph, CROPS)].inputs.people = peopleRoles(settings.roles.slice(0, pictures));
+ return graph;
+ }
+ const sam = nodeByTitle(graph, SAM);
+ for (const title of ANALYSIS) delete graph[nodeByTitle(graph, title)];
+ for (const node of Object.values(graph)) {
+ for (const [name, value] of Object.entries(node.inputs)) if (isLink(value) && value[0] === sam) node.inputs[name] = [tracks, 0];
+ }
+ graph[nodeByTitle(graph, PLAN)].inputs.labels = JSON.stringify(review.labels);
+ graph[tracks].inputs.file = review.tracks;
return graph;
}
diff --git a/test/montage.test.ts b/test/montage.test.ts
index e5dc79b..b15900c 100644
--- a/test/montage.test.ts
+++ b/test/montage.test.ts
@@ -2,13 +2,17 @@ import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
import { PEOPLE_NODES, TRACKS, TRACKS_FILE, appearances, peopleRoles, pruneMontage, renderLabels, type Track } from "../lib/montage.ts";
-import { PLAN, nodeByTitle, type AdvancedSettings } from "../lib/advanced.ts";
+import { PLAN, VIDEO, nodeByTitle, type AdvancedSettings } from "../lib/advanced.ts";
import { isLink, type ApiGraph } from "../lib/simple.ts";
import { DEFAULT_MODEL, applyModel } from "../lib/model.ts";
-const track = (id: number, role: number, start: number, end: number, on: [number, number][], area = 0.1): Track => ({ track: id, start, end, role, on, area, image: `img${id}` });
+// the pack's default pick: the photo when on screen 12+ frames at 2%+ of the frame
+const track = (id: number, role: number, start: number, end: number, on: [number, number][], area = 0.1): Track => {
+ const frames = on.reduce((sum, [a, b]) => sum + b - a, 0);
+ return { track: id, start, end, role, on, area, pick: role && area >= 0.02 && frames >= 12 ? role : 0, image: `img${id}` };
+};
-test("appearances are listed in order and start as their photo unless brief or small", () => {
+test("appearances are listed in order with the pack's picks, unlabelled ones only when long or big", () => {
const list = appearances({
frames: 300, tracks: "h3_montage_people_00001_.npz", people: [
track(1, 2, 0, 160, [[104, 160]]),
@@ -36,33 +40,58 @@ test("the render gets the picks, keeping each appearance's frames, and leaves ou
assert.deepEqual(renderLabels(list), [{ track: 1, start: 0, end: 100, role: 1 }]);
});
-test("the montage export loads the tracks Find people saved and takes the picks", () => {
- const source: ApiGraph = JSON.parse(readFileSync(new URL("../workflows/montage.api.json", import.meta.url), "utf8"));
- const settings: AdvancedSettings = { roles: ["the dancer - white polo", "the filmer - bucket hat"], resolution: "480p", motion: 512, hatFix: false, noLipSync: false, margin: "normal", seed: 3, clipSeconds: 6 };
- const labels = [{ track: 0, start: 0, end: 107, role: 2 }];
- const graph = pruneMontage(source, 2, settings, "h3_montage_people_00003_.npz", labels);
- const dangling = Object.entries(graph).flatMap(([id, node]) => Object.entries(node.inputs).filter(([, v]) => isLink(v) && !graph[v[0]]).map(([name]) => `${id}.${name}`));
- assert.deepEqual(dangling, []);
+const source: ApiGraph = JSON.parse(readFileSync(new URL("../workflows/montage.api.json", import.meta.url), "utf8"));
+const settings: AdvancedSettings = { roles: ["the dancer - white polo", "the filmer - bucket hat"], resolution: "480p", motion: 512, hatFix: false, noLipSync: false, margin: "normal", seed: 3, clipSeconds: 6 };
+const dangling = (graph: ApiGraph) => Object.entries(graph).flatMap(([id, node]) => Object.entries(node.inputs).filter(([, v]) => isLink(v) && !graph[v[0]]).map(([name]) => `${id}.${name}`));
+const classes = (graph: ApiGraph) => Object.values(graph).map((node) => node.class_type);
+
+test("without review the montage tracks, labels and picks by itself, matching the roles to the photos", () => {
+ const graph = pruneMontage(source, 2, settings, null);
+ assert.deepEqual(dangling(graph), []);
+ assert.ok(!classes(graph).includes("H3MontageTracks"));
const plan = graph[nodeByTitle(graph, PLAN)];
assert.equal(plan.class_type, "H3MontagePlan");
+ const picks = graph[(plan.inputs.labels as [string, number])[0]];
+ assert.equal(picks.class_type, "H3MontagePicks");
+ const sam = graph[(plan.inputs.track_data as [string, number])[0]];
+ assert.equal(sam.class_type, "SAM3_VideoTrack");
+ assert.equal(graph[(picks.inputs.track_data as [string, number])[0]], sam);
+ const crops = Object.values(graph).find((node) => node.class_type === "H3TrackCrops")!;
+ assert.equal(crops.inputs.people, "<Subject 1>: the dancer - white polo\n<Subject 2>: the filmer - bucket hat");
+ // the same tracking as Find people, at the same 1008 px frames as the per-clip hat and face tracking
+ const people: ApiGraph = JSON.parse(readFileSync(new URL("../workflows/people.api.json", import.meta.url), "utf8"));
+ const find = Object.values(people).find((node) => node.class_type === "SAM3_VideoTrack")!;
+ for (const name of ["detection_threshold", "max_objects", "detect_interval"]) assert.equal(sam.inputs[name], find.inputs[name]);
+ const size = (g: ApiGraph, node: typeof sam) => g[(node.inputs.images as [string, number])[0]].inputs.largest_size;
+ assert.equal(size(graph, sam), size(people, find));
+ assert.equal(crops.inputs.max_crops, people[PEOPLE_NODES.crops].inputs.max_crops);
+});
+
+test("with review the montage loads the tracks Find people saved and takes the picks", () => {
+ const labels = [{ track: 0, start: 0, end: 107, role: 2 }];
+ const graph = pruneMontage(source, 2, settings, { tracks: "h3_montage_people_00003_.npz", labels });
+ assert.deepEqual(dangling(graph), []);
+ for (const gone of ["SAM3_VideoTrack" , "H3TrackCrops", "H3TrackRoles", "H3MontagePicks"]) {
+ assert.ok(!Object.values(graph).some((node) => node.class_type === gone && !/hats|faces/.test(node._meta?.title ?? "")), gone);
+ }
+ const plan = graph[nodeByTitle(graph, PLAN)];
assert.deepEqual(JSON.parse(String(plan.inputs.labels)), labels);
assert.equal(plan.inputs.roles, "the dancer - white polo\nthe filmer - bucket hat");
assert.ok(!("picture_3" in plan.inputs) && isLink(plan.inputs.picture_2));
const tracks = graph[nodeByTitle(graph, TRACKS)];
assert.equal(tracks.inputs.file, "h3_montage_people_00003_.npz");
assert.deepEqual(plan.inputs.track_data, [nodeByTitle(graph, TRACKS), 0]);
- applyModel(graph, { ...DEFAULT_MODEL, steps: 4 });
- assert.equal(plan.inputs.steps, 4);
const passes = Object.values(graph).filter((node) => node.class_type === "H3MontagePass");
assert.deepEqual(passes.map((node) => node.inputs.pass_number), [1, 2]);
+ assert.ok(passes.every((node) => isLink(node.inputs.track_data) && node.inputs.track_data[0] === nodeByTitle(graph, TRACKS)));
assert.ok(passes.every((node) => isLink(node.inputs.picture_2) && !("picture_3" in node.inputs)));
- // no person tracking at render time: the masks are the saved ones
- assert.ok(!Object.values(graph).some((node) => node.class_type === "SAM3_VideoTrack" && /every person/.test(node._meta?.title ?? "")));
- // the hats and faces SAM finds per clip line up with the saved tracks: both at the same 1008 px frames
+ // the loader checks it gets the frames Find people tracked: the source video's, as H3 Montage People saw them
+ assert.deepEqual(tracks.inputs.source_frames, [nodeByTitle(graph, VIDEO), 0]);
const people: ApiGraph = JSON.parse(readFileSync(new URL("../workflows/people.api.json", import.meta.url), "utf8"));
- const find = Object.values(people).find((node) => node.class_type === "SAM3_VideoTrack")!;
- const size = (g: ApiGraph, title: RegExp) => Object.values(g).find((node) => node.class_type === "ImageScaleToMaxDimension" && title.test(node._meta?.title ?? ""))!.inputs.largest_size;
- assert.equal(size(graph, /^SAM video/), people[(find.inputs.images as [string, number])[0]].inputs.largest_size);
+ const saved = Object.values(people).find((node) => node.class_type === "H3MontagePeople")!;
+ assert.deepEqual(saved.inputs.source_frames, [PEOPLE_NODES.video, 0]);
+ applyModel(graph, { ...DEFAULT_MODEL, steps: 4 });
+ assert.equal(plan.inputs.steps, 4);
});
test("only files Find people saves pass as tracks", () => {
diff --git a/workflows/montage.api.json b/workflows/montage.api.json
index 477e66e..941a356 100644
--- a/workflows/montage.api.json
+++ b/workflows/montage.api.json
@@ -7,7 +7,7 @@
"7": {"inputs": {"prompt": "Describe the person in this picture for a casting sheet, in one sentence of about 40 words: apparent age and gender, hair, facial hair, skin tone, build, and their complete outfit including footwear. No preamble, no background.", "max_length": 120, "sampling_mode": "off", "thinking": false, "use_default_template": true, "mtp": "auto", "clip": ["16", 0], "image": ["6", 0]}, "class_type": "TextGenerate", "_meta": {"title": "Describe picture 2"}},
"8": {"inputs": {"video": "apt_rose_16s.mkv", "force_rate": 24, "custom_width": 0, "custom_height": 0, "frame_load_cap": 0, "skip_first_frames": 0, "select_every_nth": 1, "format": "None"}, "class_type": "VHS_LoadVideo", "_meta": {"title": "Source video (people get replaced)"}},
"9": {"inputs": {"start_index": 0, "duration": 2048, "audio": ["8", 2]}, "class_type": "TrimAudioDuration", "_meta": {"title": "Soundtrack (whole video)"}},
- "14": {"class_type": "H3MontagePlan", "_meta": {"title": "Swap Plan (roles, seed, size)"}, "inputs": {"clip_seconds": 6, "overlap_frames": 39, "resolution": "736p", "steps": 6, "seed": 0, "roles": "", "no_lip_sync": ["97", 0], "source_frames": ["8", 0], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0], "picture_1_text": ["4", 0], "picture_2_text": ["7", 0], "picture_3_text": ["105", 0], "picture_4_text": ["108", 0], "track_data": ["109", 0], "labels": "[]"}},
+ "14": {"class_type": "H3MontagePlan", "_meta": {"title": "Swap Plan (roles, seed, size)"}, "inputs": {"clip_seconds": 6, "overlap_frames": 39, "resolution": "736p", "steps": 6, "seed": 0, "roles": "", "no_lip_sync": ["97", 0], "source_frames": ["8", 0], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0], "picture_1_text": ["4", 0], "picture_2_text": ["7", 0], "picture_3_text": ["105", 0], "picture_4_text": ["108", 0], "track_data": ["121", 0], "labels": ["125", 0]}},
"16": {"inputs": {"clip_name": "qwen3vl_8b_int8_convrot.safetensors", "type": "stable_diffusion", "device": "default"}, "class_type": "CLIPLoader", "_meta": {"title": "Describer: Qwen3-VL 8B"}},
"18": {"inputs": {"unet_name": "minimax_h3_ref2va_pruned_int8_convrot.safetensors", "weight_dtype": "default"}, "class_type": "UNETLoader", "_meta": {"title": "H3 Diffusion Model"}},
"19": {"inputs": {"lora_name": "minimax_h3_DMAD_4step_full_lora_avg_rank_39_bf16.safetensors", "strength_model": 1, "model": ["18", 0]}, "class_type": "LoraLoaderModelOnly", "_meta": {"title": "DMAD LoRA"}},
@@ -86,8 +86,13 @@
"106": {"inputs": {"image": "example.png"}, "class_type": "LoadImage", "_meta": {"title": "Picture 4"}},
"107": {"inputs": {"upscale_method": "area", "largest_size": 768, "image": ["106", 0]}, "class_type": "ImageScaleToMaxDimension", "_meta": {"title": "Shrink for the describer"}},
"108": {"inputs": {"prompt": "Describe the person in this picture for a casting sheet, in one sentence of about 40 words: apparent age and gender, hair, facial hair, skin tone, build, and their complete outfit including footwear. No preamble, no background.", "max_length": 120, "sampling_mode": "off", "thinking": false, "use_default_template": true, "mtp": "auto", "clip": ["16", 0], "image": ["107", 0]}, "class_type": "TextGenerate", "_meta": {"title": "Describe picture 4"}},
- "109": {"inputs": {"file": ""}, "class_type": "H3MontageTracks", "_meta": {"title": "Tracks from Find people"}},
- "111": {"class_type": "H3MontagePass", "_meta": {"title": "Pass 1: this clip's person"}, "inputs": {"pass_number": 1, "montage": ["14", 4], "track_data": ["109", 0], "clip_index": ["32", 1], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0]}},
- "112": {"class_type": "H3MontagePass", "_meta": {"title": "Pass 2: this clip's second person"}, "inputs": {"pass_number": 2, "montage": ["14", 4], "track_data": ["109", 0], "clip_index": ["32", 1], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0]}},
- "113": {"class_type": "ComfySwitchNode", "_meta": {"title": "Pass 2 only where the piece has a second person"}, "inputs": {"switch": ["111", 4], "on_false": ["68", 0], "on_true": ["87", 0]}}
+ "109": {"inputs": {"file": "", "source_frames": ["8", 0]}, "class_type": "H3MontageTracks", "_meta": {"title": "Tracks from Find people"}},
+ "111": {"class_type": "H3MontagePass", "_meta": {"title": "Pass 1: this clip's person"}, "inputs": {"pass_number": 1, "montage": ["14", 4], "track_data": ["121", 0], "clip_index": ["32", 1], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0]}},
+ "112": {"class_type": "H3MontagePass", "_meta": {"title": "Pass 2: this clip's second person"}, "inputs": {"pass_number": 2, "montage": ["14", 4], "track_data": ["121", 0], "clip_index": ["32", 1], "picture_1": ["2", 0], "picture_2": ["5", 0], "picture_3": ["103", 0], "picture_4": ["106", 0]}},
+ "113": {"class_type": "ComfySwitchNode", "_meta": {"title": "Pass 2 only where the piece has a second person"}, "inputs": {"switch": ["111", 4], "on_false": ["68", 0], "on_true": ["87", 0]}},
+ "121": {"inputs": {"detection_threshold": 0.35, "max_objects": 0, "detect_interval": 1, "images": ["36", 0], "model": ["26", 0], "conditioning": ["27", 0]}, "class_type": "SAM3_VideoTrack", "_meta": {"title": "SAM 3.1 track every person (whole video)"}},
+ "122": {"inputs": {"cut_threshold": 40, "max_crops": 32, "people": "<Subject 1>: the main person", "track_data": ["121", 0], "images": ["36", 0]}, "class_type": "H3TrackCrops", "_meta": {"title": "Show each track per shot"}},
+ "123": {"inputs": {"prompt": ["122", 1], "max_length": 1200, "sampling_mode": "off", "thinking": false, "use_default_template": true, "mtp": "auto", "clip": ["16", 0], "image": ["122", 0]}, "class_type": "TextGenerate", "_meta": {"title": "Who is each track (Qwen3-VL)"}},
+ "124": {"inputs": {"segments": ["122", 2], "answer": ["123", 0]}, "class_type": "H3TrackRoles", "_meta": {"title": "Read the track labels"}},
+ "125": {"inputs": {"track_data": ["121", 0], "labels": ["124", 0]}, "class_type": "H3MontagePicks", "_meta": {"title": "Picks without review"}}
}
diff --git a/workflows/people.api.json b/workflows/people.api.json
index 273aedc..8febe02 100644
--- a/workflows/people.api.json
+++ b/workflows/people.api.json
@@ -8,5 +8,5 @@
"7": {"class_type": "CLIPLoader", "_meta": {"title": "Describer: Qwen3-VL 8B"}, "inputs": {"clip_name": "qwen3vl_8b_int8_convrot.safetensors", "type": "stable_diffusion", "device": "default"}},
"8": {"class_type": "TextGenerate", "_meta": {"title": "Who is each track (Qwen3-VL)"}, "inputs": {"prompt": ["6", 1], "max_length": 1200, "sampling_mode": "off", "thinking": false, "use_default_template": true, "mtp": "auto", "clip": ["7", 0], "image": ["6", 0]}},
"9": {"class_type": "H3TrackRoles", "_meta": {"title": "Read the track labels"}, "inputs": {"segments": ["6", 2], "answer": ["8", 0]}},
- "10": {"class_type": "H3MontagePeople", "_meta": {"title": "People per shot (for the piece list)"}, "inputs": {"track_data": ["5", 0], "crops": ["6", 0], "labels": ["9", 0]}}
+ "10": {"class_type": "H3MontagePeople", "_meta": {"title": "People (for the person list)"}, "inputs": {"track_data": ["5", 0], "crops": ["6", 0], "labels": ["9", 0], "source_frames": ["1", 0]}}
}