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.

Add From picture with image preview before rendering

D3voz3c78d5468d8b
diff --git a/README.md b/README.md
index 2d97cee..6c6e131 100644
--- a/README.md
+++ b/README.md
@@ -9,6 +9,7 @@ The app is a small Next.js front end over a ComfyUI workflow. It uses [`@comfyor
- **Simple motion transfer**: available. One character replaces the main person (the one who fills the most of the frame). Runs `workflows/simple.api.json`, exported from `H3 One-Click Single Swap (DMAD 6 step).json`.
- **Advanced motion transfer**: available. 1–4 characters, each with an optional role; every tracked person is matched to a role per shot, and people without a character stay untouched. Runs `workflows/advanced.api.json`, exported from `H3 One-Click Advanced Swap (DMAD 6 step).json`; **One pass per person** (two characters) runs `workflows/advanced_maxq.api.json`.
- **Object swap**: available. **Change** what SAM tracks (hair, a jacket, a car) into what you describe or show in a picture; **Remove** it; or change the **Background** around it (`person` stays). Only that area is regenerated. Runs `workflows/object.api.json`, exported from `H3 One-Click Object Swap (DMAD 6 step).json`.
+- **From picture** (under Object swap): FLUX prepares the character in the raw video frame's pose and body cut while keeping the character picture's background. Review or regenerate the image before choosing **Use this image · render video**. The video step uses the exact saved preview with Metric3D normal-map motion guidance, for one 5.875-second clip at a 480 px short edge with the source soundtrack. See [the workflow requirements](workflows/picture/README.md).
- **Post-processing**: available, for a finished video. **Fix faces**: H3 draws faces poorly when the person is small in the frame, so this redraws the face of the person in a photo at close-up size and pastes it back. Runs `workflows/face.api.json`, written by `workflows/build/openjutsu_face_build.py`. **Fix colours** softens H3's harsh look without an H3 run: Image Detail Contrast takes some fine detail contrast out, then Orion4D's DCTL Tone Mapper grades every frame. Runs `workflows/color.api.json`.
## Requirements
diff --git a/app/api/picture/route.ts b/app/api/picture/route.ts
new file mode 100644
index 0000000..398cce4
--- /dev/null
+++ b/app/api/picture/route.ts
@@ -0,0 +1,155 @@
+import { randomUUID } from "node:crypto";
+import { openAsBlob } from "node:fs";
+import { readFile } from "node:fs/promises";
+import { join } from "node:path";
+import { apiAccess, HttpError, IMAGE_SIGNATURE, readFormData, StoredFile, validateJobId, VIDEO_SIGNATURE } from "../../../lib/http.ts";
+import { canvasSize, isLink, MAX_SEED, type ApiGraph } from "../../../lib/simple.ts";
+
+export const runtime = "nodejs";
+const PREPARED = "OpenJutsu · prepared picture";
+const RENDERED = "OpenJutsu · picture motion";
+const FILE_CHECKS = {
+ video: { signature: VIDEO_SIGNATURE, error: "Choose an MP4, MOV, MKV, WebM or AVI video." },
+ picture: { signature: IMAGE_SIGNATURE, error: "Choose a PNG, JPEG or WebP character picture." },
+};
+type OutputFile = { filename: string; subfolder?: string; type?: string };
+type History = { prompt?: [number, string, ApiGraph]; status?: { status_str?: string; completed?: boolean }; outputs?: Record<string, { images?: OutputFile[]; gifs?: OutputFile[] }> };
+
+async function comfy(path: string, init?: RequestInit) {
+ const base = (process.env.COMFYUI_URL?.trim() || "http://127.0.0.1:8188").replace(/\/+$/, "");
+ const response = await fetch(`${base}${path}`, { ...init, cache: "no-store", redirect: "error", signal: AbortSignal.timeout(30_000) });
+ if (!response.ok) {
+ const data = await response.json().catch(() => null);
+ const details = Object.values(data?.node_errors ?? {}).flatMap((node) => (node as { errors?: { message: string; details?: string }[] }).errors ?? [])
+ .map((error) => `${error.message}${error.details ? `: ${error.details}` : ""}`).join("; ");
+ throw new HttpError(502, details || data?.error?.message || `ComfyUI answered with HTTP ${response.status}. Check its console.`);
+ }
+ return response;
+}
+
+async function template(stage: "prepare" | "motion"): Promise<ApiGraph> {
+ return JSON.parse(await readFile(join(process.cwd(), "workflows", "picture", `from_picture_${stage}_flux3.api.json`), "utf8"));
+}
+
+function view(file: OutputFile) {
+ return `/view?${new URLSearchParams({ filename: file.filename, subfolder: file.subfolder ?? "", type: file.type ?? "output" })}`;
+}
+
+async function uploadFile(blob: Blob, extension: string) {
+ const form = new FormData();
+ form.set("image", blob, `openjutsu_picture_${randomUUID()}${extension}`);
+ form.set("type", "input");
+ const asset = await (await comfy("/upload/image", { method: "POST", body: form })).json();
+ return asset.subfolder ? `${asset.subfolder}/${asset.name}` : asset.name;
+}
+
+async function history(id: string) {
+ validateJobId(id);
+ const data = await (await comfy(`/history/${encodeURIComponent(id)}`)).json();
+ const item: History | undefined = data[id];
+ if (item) {
+ const graph = item.prompt?.[2];
+ const prepared = graph?.["21"]?.class_type === "SaveImage" && graph["21"]._meta?.title === PREPARED;
+ const rendered = graph?.["63"]?.class_type === "VHS_VideoCombine" && graph["63"]._meta?.title === RENDERED;
+ if (!prepared && !rendered) throw new HttpError(404, "This is not an OpenJutsu picture job.");
+ if (item.status?.status_str === "error") throw new HttpError(422, "Generation failed. Check the ComfyUI console for missing models or memory errors.");
+ }
+ return item;
+}
+
+function failure(error: unknown) {
+ return Response.json({ error: error instanceof HttpError ? error.message : "Could not reach ComfyUI. Start it locally and try again." }, { status: error instanceof HttpError ? error.status : 502 });
+}
+
+let uploading = false;
+
+export async function POST(request: Request) {
+ const denied = apiAccess(request);
+ if (denied) return denied;
+ if (uploading) return Response.json({ error: "Another picture request is in progress. Try again shortly." }, { status: 429 });
+ uploading = true;
+ let upload: Awaited<ReturnType<typeof readFormData>> | undefined;
+ try {
+ let graph: ApiGraph;
+ if (request.headers.get("Content-Type")?.startsWith("application/json")) {
+ const body = await request.json();
+ if (typeof body.prepared !== "string") throw new HttpError(400, "Prepare a picture first.");
+ const item = await history(body.prepared);
+ const file = item?.outputs?.["21"]?.images?.[0];
+ const source = item?.prompt?.[2];
+ if (!file || !source || source["21"]?._meta?.title !== PREPARED || source["1"]?.class_type !== "VHS_LoadVideo") throw new HttpError(409, "The prepared picture is not ready. Generate it first.");
+ const picture = await (await comfy(view(file))).blob();
+ graph = await template("motion");
+ graph["20"] = { class_type: "LoadImage", inputs: { image: await uploadFile(picture, ".png") } };
+ graph["1"].inputs.video = source["1"].inputs.video;
+ graph["1"].inputs.skip_first_frames = source["1"].inputs.skip_first_frames;
+ const [width, height] = canvasSize(Number(source["3"].inputs.width), Number(source["3"].inputs.height), "480p");
+ for (const id of ["33", "56"]) Object.assign(graph[id].inputs, { width, height });
+ graph["58"].inputs.noise_seed = source["19"].inputs.seed;
+ graph["63"]._meta = { title: RENDERED };
+ const keep = new Set<string>();
+ function visit(id: string) {
+ if (keep.has(id)) return;
+ keep.add(id);
+ for (const value of Object.values(graph[id].inputs)) if (isLink(value)) visit(value[0]);
+ }
+ visit("63");
+ graph = Object.fromEntries(Object.entries(graph).filter(([id]) => keep.has(id)));
+ } else {
+ upload = await readFormData(request, FILE_CHECKS);
+ const form = upload.form, video = form.get("video"), picture = form.get("picture");
+ if (!(video instanceof StoredFile) || !video.size || !(picture instanceof StoredFile) || !picture.size) throw new HttpError(400, "Choose a video and a character picture.");
+ const start = Number(form.get("start") ?? 0), seed = Number(form.get("seed") ?? 0);
+ const width = Number(form.get("width")), height = Number(form.get("height"));
+ if (!Number.isFinite(start) || start < 0 || !Number.isInteger(seed) || seed < 0 || seed > MAX_SEED) throw new HttpError(400, "Use a start time of 0 or later and a valid whole-number seed.");
+ if (![width, height].every((side) => Number.isFinite(side) && side > 0)) throw new HttpError(400, "Wait for the video's dimensions to load.");
+ const extension = video.name.match(/\.(mp4|mov|mkv|webm|avi)$/i)?.[0];
+ const pictureExtension = picture.name.match(/\.(png|jpe?g|webp)$/i)?.[0];
+ if (!extension || !pictureExtension) throw new HttpError(400, "Choose a supported video and PNG, JPEG or WebP picture.");
+ graph = await template("prepare");
+ const prompt = form.get("prompt");
+ if (typeof prompt === "string" && prompt.trim()) graph["6"].inputs.value = prompt;
+ const [editWidth, editHeight] = canvasSize(width, height, "768p");
+ for (const id of ["3", "5"]) Object.assign(graph[id].inputs, { width: editWidth, height: editHeight });
+ graph["1"].inputs.video = await uploadFile(await openAsBlob(video.path), extension.toLowerCase());
+ graph["1"].inputs.skip_first_frames = Math.round(start * 24);
+ graph["4"].inputs.image = await uploadFile(await openAsBlob(picture.path), pictureExtension.toLowerCase());
+ graph["19"].inputs.seed = seed;
+ graph["21"]._meta = { title: PREPARED };
+ }
+ const result = await (await comfy("/prompt", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prompt: graph }) })).json();
+ return Response.json({ id: result.prompt_id }, { status: 202 });
+ } catch (error) {
+ return failure(error);
+ } finally {
+ await upload?.dispose();
+ uploading = false;
+ }
+}
+
+export async function GET(request: Request) {
+ const denied = apiAccess(request);
+ if (denied) return denied;
+ try {
+ const url = new URL(request.url), id = url.searchParams.get("id") ?? "";
+ const item = await history(id);
+ if (!item) {
+ const queue = await (await comfy("/queue")).json();
+ const waiting = [...queue.queue_running, ...queue.queue_pending].some((entry: unknown[]) => entry[1] === id);
+ if (!waiting) throw new HttpError(404, "This job was removed or ComfyUI restarted. Generate the picture again.");
+ return Response.json({ status: "processing" });
+ }
+ const isVideo = item.prompt?.[2]?.["63"]?._meta?.title === RENDERED;
+ const media = url.searchParams.get("media");
+ const output = item.outputs?.[isVideo ? "63" : media === "frame" ? "22" : "21"];
+ const file = isVideo ? output?.gifs?.[0] : output?.images?.[0];
+ if (!file) throw new HttpError(422, "ComfyUI returned no result. Check its console.");
+ const base = `/api/picture?id=${encodeURIComponent(id)}`;
+ if (!media) return Response.json({ status: "ready", url: `${base}&media=result`, ...(!isVideo ? { frame: `${base}&media=frame` } : {}) });
+ const response = await comfy(view(file), { headers: request.headers.has("Range") ? { Range: request.headers.get("Range")! } : {} });
+ return new Response(response.body, { status: response.status, headers: {
+ "Content-Type": isVideo ? "video/mp4" : "image/png", "X-Content-Type-Options": "nosniff", "Cache-Control": "private, no-store",
+ ...Object.fromEntries(["Content-Length", "Content-Range", "Accept-Ranges"].flatMap((key) => response.headers.has(key) ? [[key, response.headers.get(key)!]] : [])),
+ } });
+ } catch (error) { return failure(error); }
+}
diff --git a/app/globals.css b/app/globals.css
index 1d864ca..4c27101 100644
--- a/app/globals.css
+++ b/app/globals.css
@@ -50,6 +50,11 @@ h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
}
.inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
+.picture-pipeline { display: grid; gap: 20px; }
+.picture-pipeline label { display: grid; gap: 8px; }
+.picture-reference { width: 100%; max-height: 280px; object-fit: contain; border-radius: 12px; }
+.picture-comparison figure { margin: 0; display: grid; gap: 8px; }
+.picture-comparison img { width: 100%; max-height: 480px; object-fit: contain; background: var(--bg); border-radius: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 14px; align-content: start; }
.panel h2 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 10px; }
.panel h2 > span {
diff --git a/components/from-picture.tsx b/components/from-picture.tsx
new file mode 100644
index 0000000..e630794
--- /dev/null
+++ b/components/from-picture.tsx
@@ -0,0 +1,150 @@
+"use client";
+
+import { useEffect, useState } from "react";
+import { MAX_SEED } from "../lib/simple.ts";
+
+const PROMPT = "change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>.";
+const STORAGE = "openjutsu.picture-preview";
+type Job = { id: string; stage: "prepare" | "render" };
+
+export function FromPicture({ initialVideo, initialPicture, start: initialStart = 0 }: { initialVideo?: File; initialPicture?: File; start?: number }) {
+ const [video, setVideo] = useState<File | null>(initialVideo ?? null);
+ const [picture, setPicture] = useState<File | null>(initialPicture ?? null);
+ const [videoUrl, setVideoUrl] = useState("");
+ const [pictureUrl, setPictureUrl] = useState("");
+ const [size, setSize] = useState<[number, number] | null>(null);
+ const [start, setStart] = useState(initialStart);
+ const [seed, setSeed] = useState(0);
+ const [prompt, setPrompt] = useState(PROMPT);
+ const [job, setJob] = useState<Job | null>(null);
+ const [prepared, setPrepared] = useState("");
+ const [preview, setPreview] = useState<{ url: string; frame: string } | null>(null);
+ const [result, setResult] = useState("");
+ const [submitting, setSubmitting] = useState(false);
+ const [error, setError] = useState("");
+ const busy = submitting || !!job;
+
+ useEffect(() => {
+ try {
+ const saved = JSON.parse(localStorage.getItem(STORAGE) ?? "null");
+ if (typeof saved?.prepared === "string") setPrepared(saved.prepared);
+ if (typeof saved?.job?.id === "string" && ["prepare", "render"].includes(saved.job.stage)) {
+ setJob(saved.job);
+ if (saved.job.stage === "render" && saved.prepared) {
+ const base = `/api/picture?id=${encodeURIComponent(saved.prepared)}`;
+ setPreview({ url: `${base}&media=result`, frame: `${base}&media=frame` });
+ }
+ }
+ else if (typeof saved?.prepared === "string" && saved.prepared) setJob({ id: saved.prepared, stage: "prepare" });
+ } catch {}
+ }, []);
+ useEffect(() => {
+ if (!video) return;
+ const url = URL.createObjectURL(video); setVideoUrl(url); setSize(null);
+ return () => URL.revokeObjectURL(url);
+ }, [video]);
+ useEffect(() => {
+ if (!picture) return;
+ const url = URL.createObjectURL(picture); setPictureUrl(url);
+ return () => URL.revokeObjectURL(url);
+ }, [picture]);
+
+ function remember(next: Job | null, image: string) {
+ try { localStorage.setItem(STORAGE, JSON.stringify({ job: next, prepared: image })); } catch {}
+ }
+ useEffect(() => {
+ if (!job) return;
+ const controller = new AbortController();
+ let timer: ReturnType<typeof setTimeout>;
+ async function poll() {
+ try {
+ const response = await fetch(`/api/picture?id=${encodeURIComponent(job!.id)}`, { signal: controller.signal });
+ const data = await response.json();
+ if (!response.ok) {
+ setError(data.error ?? "Could not read the job.");
+ if ([400, 404, 422].includes(response.status)) { setJob(null); remember(null, prepared); }
+ else timer = setTimeout(poll, 5000);
+ return;
+ }
+ setError("");
+ if (data.status !== "ready") { timer = setTimeout(poll, 2000); return; }
+ if (job!.stage === "prepare") {
+ setPrepared(job!.id); setPreview({ url: data.url, frame: data.frame }); remember(null, job!.id);
+ } else { setResult(data.url); remember(job, prepared); }
+ setJob(null);
+ } catch {
+ if (!controller.signal.aborted) { setError("Connection interrupted. Retrying…"); timer = setTimeout(poll, 5000); }
+ }
+ }
+ void poll();
+ return () => { controller.abort(); clearTimeout(timer); };
+ }, [job, prepared]);
+
+ function invalidate() {
+ setPrepared(""); setPreview(null); setResult(""); setError(""); remember(null, "");
+ }
+ async function prepare(nextSeed: number) {
+ if (!video || !picture || !size) return;
+ setSubmitting(true); invalidate(); setSeed(nextSeed);
+ try {
+ const form = new FormData();
+ form.set("video", video); form.set("picture", picture); form.set("start", String(start)); form.set("seed", String(nextSeed));
+ form.set("width", String(size[0])); form.set("height", String(size[1])); form.set("prompt", prompt);
+ const response = await fetch("/api/picture", { method: "POST", body: form });
+ const data = await response.json();
+ if (!response.ok) throw new Error(data.error);
+ const next: Job = { id: data.id, stage: "prepare" }; remember(next, ""); setJob(next);
+ } catch (error) { setError((error as Error).message); }
+ finally { setSubmitting(false); }
+ }
+ async function render() {
+ if (!prepared || !preview) return;
+ setSubmitting(true); setError(""); setResult("");
+ try {
+ const response = await fetch("/api/picture", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prepared }) });
+ const data = await response.json();
+ if (!response.ok) throw new Error(data.error);
+ const next: Job = { id: data.id, stage: "render" }; remember(next, prepared); setJob(next);
+ } catch (error) { setError((error as Error).message); }
+ finally { setSubmitting(false); }
+ }
+
+ return <div className="picture-pipeline">
+ <p className="hint">Prepare the character in the video's starting pose with FLUX. Review the image first, then render its motion while keeping the picture's background.</p>
+ <div className="inputs">
+ <section className="panel">
+ <h2><span>1</span> Character and source video</h2>
+ <label>Source video<input type="file" accept="video/*,.mkv" disabled={busy} onChange={(event) => { const file = event.target.files?.[0]; if (file) { invalidate(); setVideo(file); setStart(0); } }} /></label>
+ {videoUrl && <video src={videoUrl} controls preload="metadata" onLoadedMetadata={(event) => setSize([event.currentTarget.videoWidth, event.currentTarget.videoHeight])} />}
+ <label>Character picture · image 1<input type="file" accept="image/png,image/jpeg,image/webp" disabled={busy} onChange={(event) => { const file = event.target.files?.[0]; if (file) { invalidate(); setPicture(file); } }} /></label>
+ {pictureUrl && <img className="picture-reference" src={pictureUrl} alt="Character and background reference" />}
+ <label>Start at (seconds)<input className="target-input" type="number" min={0} step={0.1} value={start} disabled={busy} onChange={(event) => { invalidate(); setStart(Number(event.target.value)); }} /></label>
+ <small>The raw frame at this time is image 2. Video test: one 5.875-second clip from here, at a 480 px short edge.</small>
+ </section>
+ <section className="panel">
+ <h2><span>2</span> Prepare the first frame</h2>
+ <p className="hint">Image 1 supplies the character and background. Image 2 supplies the pose and body cut.</p>
+ <label>FLUX edit prompt<textarea className="report" rows={6} value={prompt} disabled={busy} onChange={(event) => { invalidate(); setPrompt(event.target.value); }} /></label>
+ <label>Seed<input className="target-input" type="number" min={0} max={MAX_SEED} step={1} value={seed} disabled={busy} onChange={(event) => { invalidate(); setSeed(Number(event.target.value)); }} /></label>
+ <button className="primary" disabled={busy || !video || !picture || !size} onClick={() => prepare(seed)}>Generate preview image</button>
+ <p className="hint">This step only generates an image. Video rendering starts when you choose to use the preview.</p>
+ </section>
+ </div>
+ {busy && <p role="status">{submitting ? "Submitting…" : job?.stage === "prepare" ? "FLUX is preparing the image…" : "Generating normals and rendering the video…"}</p>}
+ {error && <p className="error" role="alert">{error}</p>}
+ {preview && <section className="panel">
+ <h2><span>3</span> Review before rendering</h2>
+ <div className="inputs picture-comparison">
+ <figure><figcaption>Source frame · image 2</figcaption><img src={preview.frame} alt="Raw source video frame used for pose and body cut" /></figure>
+ <figure><figcaption>FLUX prepared image</figcaption><img src={preview.url} alt="FLUX generated character in the source pose" /></figure>
+ </div>
+ <p className="hint">Check the pose, framing, character and background. The video will use this exact prepared image.</p>
+ <div className="row">
+ <a href={preview.url} download="prepared-frame.png">Download image</a>
+ <button className="secondary" disabled={busy || !video || !picture || !size} onClick={() => prepare((seed + 1) % (MAX_SEED + 1))}>Generate another image</button>
+ <button className="primary" disabled={busy} onClick={render}>Use this image · render video</button>
+ </div>
+ </section>}
+ {result && <section className="panel"><h2>Video result</h2><video src={result} controls /><a href={result} download="picture-motion.mp4">Download video</a></section>}
+ </div>;
+}
diff --git a/components/openjutsu.tsx b/components/openjutsu.tsx
index 0146542..3d90f1a 100644
--- a/components/openjutsu.tsx
+++ b/components/openjutsu.tsx
@@ -10,6 +10,7 @@ import { MAX_CHARACTERS } from "../lib/advanced.ts";
import { DEFAULT_MODEL, MAX_LORAS, STEPS, STRENGTH, type Lora } from "../lib/model.ts";
import type { EditMode, FitSummary, PaintKeyframe, PlacementKeyframe } from "../lib/object.ts";
import { ObjectPlacement } from "./object-placement.tsx";
+import { FromPicture } from "./from-picture.tsx";
import { CHUNK_SECONDS, FACE_STYLES, 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 Kept, type Label, type People, type Review } from "../lib/montage.ts";
@@ -51,11 +52,13 @@ const FACE_STYLE_TEXT: Record<FaceStyle, { label: string; hint: string }> = {
mouth: { label: "Follow the mouth", hint: "The face follows the video's expressions and mouth movements; a little less like the photo." },
};
-const EDITS: { id: EditMode; label: string; target: string; what: string; to: string; toHint: string }[] = [
+type EditTab = EditMode | "picture";
+const EDITS: { id: EditTab; label: string; target: string; what: string; to: string; toHint: string }[] = [
{ id: "change", label: "Change", target: "hair, top", what: "What to change", to: "short bright pink hair and a black leather jacket", toHint: "What it becomes" },
{ id: "add", label: "Add", target: "on the table", what: "Where it goes", to: "a chocolate cake on a plate", toHint: "Object to add" },
{ id: "remove", label: "Remove", target: "poster", what: "What to remove", to: "a plain wall", toHint: "What shows instead (optional)" },
{ id: "background", label: "Background", target: "person", what: "What stays", to: "a snowy mountain pass at dusk", toHint: "The new place" },
+ { id: "picture", label: "From picture", target: "person", what: "Who is replaced", to: "", toHint: "" },
];
const isRun = (run: Run | null) => typeof run?.id === "string" && Object.hasOwn(KIND_LABELS, run.kind);
@@ -87,7 +90,7 @@ function readHistory(): PastRun[] {
type Settings = {
mode: Mode; maxQuality: boolean; montage: boolean; resolution: Resolution; customSize: Size; hatFix: boolean; noLipSync: boolean;
- margin: Margin; target: string; editMode: EditMode; editTarget: string; biggestOnly: boolean; keepOutline: boolean; post: Post;
+ margin: Margin; target: string; editMode: EditTab; editTarget: string; biggestOnly: boolean; keepOutline: boolean; post: Post;
detailOn: boolean; detail: number; toneOn: boolean; tone: ToneSettings; tonePreset: string; faceStyle: FaceStyle;
chunkSeconds: number; seed: number; clipSeconds: number; motion: MotionSize; steps: number; model: string; loras: Lora[];
};
@@ -243,7 +246,7 @@ export function Openjutsu() {
const [noLipSync, setNoLipSync] = useState(false);
const [margin, setMargin] = useState<Margin>("normal");
const [target, setTarget] = useState(DEFAULT_TARGET);
- const [editMode, setEditMode] = useState<EditMode>("change");
+ const [editMode, setEditMode] = useState<EditTab>("change");
const [editTarget, setEditTarget] = useState(EDITS[0].target);
const [changeTo, setChangeTo] = useState("");
const [action, setAction] = useState("");
@@ -682,6 +685,13 @@ export function Openjutsu() {
))}
</nav>
+ {mode === "object" && !run && <nav className="segmented" aria-label="Object swap tools">
+ {EDITS.map((e) => <button key={e.id} className={e.id === editMode ? "on" : ""} aria-pressed={e.id === editMode} onClick={() => {
+ if (e.id !== editMode) { setEditTarget(e.target); setChangeTo(""); setAction(""); }
+ setEditMode(e.id);
+ }}>{e.label}</button>)}
+ </nav>}
+
{formError && <div className="row">
<p className="error" role="alert">{formError}</p>
<CopyDetails lines={[tab, run ? jobLine(run, job) : "", `Error: ${formError}`]} />
@@ -720,7 +730,7 @@ export function Openjutsu() {
onMontage={video && character && !submitting ? (tracks, labels) => submit("montage", { tracks, labels }) : null} frames={frames}
onRetry={video && same && ready && !submitting && run.kind === generateKind && generateKind !== "montage" ? () => { reset(); submit(generateKind); } : null}
/>
- ) : (
+ ) : mode === "object" && editMode === "picture" ? <FromPicture initialVideo={video?.file} initialPicture={look?.file} start={whole ? 0 : part.start} /> : (
<>
<section className="inputs">
<div className="panel">
@@ -812,16 +822,6 @@ export function Openjutsu() {
<p className="hint">No H3 run: the video is only filtered, so it keeps its frames and soundtrack. The detail contrast runs first, then the tone mapper.</p>
</>) : mode === "object" ? (
<div className="edit">
- <div className="segmented">
- {EDITS.map((e) => (
- <button key={e.id} className={e.id === editMode ? "on" : ""} onClick={() => {
- // Each tab's fields mean something else: "top, pants" left over from Change made From picture swap only the top.
- // The default goes in as a value, not a placeholder, so an untouched box shows what SAM tracks.
- if (e.id !== editMode) { setEditTarget(e.target); setChangeTo(""); setAction(""); }
- setEditMode(e.id);
- }}>{e.label}</button>
- ))}
- </div>
<label>
<span>{edit.what} <small>{editMode === "add" ? "Describe the placement, for example on the table in front of the person." : "What SAM tracks, in English."}{(editMode === "change" || editMode === "remove") && " Separate several with commas."}</small></span>
<input value={editTarget} maxLength={100} placeholder={edit.target} onChange={(event) => setEditTarget(event.target.value)} />
diff --git a/test/picture-pipeline.test.ts b/test/picture-pipeline.test.ts
new file mode 100644
index 0000000..b79c91f
--- /dev/null
+++ b/test/picture-pipeline.test.ts
@@ -0,0 +1,59 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import { isLink, type ApiGraph } from "../lib/simple.ts";
+
+const load = (stage: string): ApiGraph => JSON.parse(readFileSync(new URL(`../workflows/picture/from_picture_${stage}_flux3.api.json`, import.meta.url), "utf8"));
+const prompt = "change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>.";
+
+test("the first-frame editor receives the character first and the raw video frame second, without pose preprocessors", () => {
+ const graph = load("prepare");
+ assert.equal(graph["1"].inputs.frame_load_cap, 1);
+ assert.deepEqual(graph["2"].inputs, { image: ["1", 0], batch_index: 0, length: 1 });
+ assert.deepEqual(graph["5"].inputs.image, ["4", 0]);
+ assert.deepEqual(graph["3"].inputs.image, ["2", 0]);
+ const references = graph["15"];
+ const keys = ["images.image0", "images.image1"];
+ assert.deepEqual(references.inputs[keys[0]], ["5", 0]);
+ assert.deepEqual(references.inputs[keys[1]], ["3", 0]);
+ assert.equal(graph["6"].inputs.value, prompt);
+ assert.deepEqual(graph["23"].inputs.prompt, ["6", 0]);
+ assert.deepEqual(graph["13"].inputs.text, ["23", 0]);
+ assert.deepEqual(graph["7"].inputs, { image1: ["5", 0], image2: ["3", 0] });
+ assert.deepEqual(graph["21"].inputs.images, ["20", 0]);
+ assert.ok(!Object.values(graph).some((node) => /DW|Pose|Metric3D|MiniMax/.test(node.class_type)));
+});
+
+test("the motion workflow consumes the prepared picture directly and resizes normals to the H3 canvas", () => {
+ const graph = load("motion");
+ assert.equal(graph["1"].inputs.frame_load_cap, 141);
+ assert.deepEqual(graph["56"].inputs["ref_images.ref_image_0"], ["20", 0]);
+ assert.deepEqual(graph["56"].inputs["ref_videos.ref_video_0"], ["33", 0]);
+ assert.equal(graph["32"].class_type, "Metric3D-NormalMapPreprocessor");
+ assert.equal(graph["33"].inputs.width, graph["56"].inputs.width);
+ assert.equal(graph["33"].inputs.height, graph["56"].inputs.height);
+ assert.equal(graph["56"].inputs.length, graph["1"].inputs.frame_load_cap);
+ assert.deepEqual(graph["30"].inputs.any_input, ["20", 0]);
+ assert.deepEqual(graph["30"].inputs.image_pass, ["1", 0]);
+ assert.equal(graph["30"].inputs.unload_all_models, true);
+ assert.deepEqual(graph["31"].inputs.image, ["30", 1]);
+ assert.deepEqual(graph["63"].inputs.audio, ["36", 0]);
+ assert.ok(!Object.values(graph).some((node) => /ControlNet|DWPreprocessor|ChainLoop/.test(node.class_type)));
+});
+
+test("picture pipelines have valid links and no disconnected processing nodes", () => {
+ for (const stage of ["prepare", "motion"]) {
+ const graph = load(stage);
+ const reached = new Set<string>();
+ function visit(id: string) {
+ if (reached.has(id)) return;
+ reached.add(id);
+ for (const value of Object.values(graph[id].inputs)) if (isLink(value)) {
+ assert.ok(graph[value[0]], `${stage}: missing ${value[0]}`);
+ visit(value[0]);
+ }
+ }
+ for (const [id, node] of Object.entries(graph)) if (["SaveImage", "PreviewImage", "PreviewAny", "VHS_VideoCombine"].includes(node.class_type)) visit(id);
+ assert.deepEqual([...reached].sort(), Object.keys(graph).sort(), `${stage}: disconnected node`);
+ }
+});
diff --git a/test/picture-route.test.ts b/test/picture-route.test.ts
new file mode 100644
index 0000000..256d4b1
--- /dev/null
+++ b/test/picture-route.test.ts
@@ -0,0 +1,133 @@
+import assert from "node:assert/strict";
+import { createServer } from "node:http";
+import { once } from "node:events";
+import type { AddressInfo } from "node:net";
+import test from "node:test";
+import { GET, POST } from "../app/api/picture/route.ts";
+import type { ApiGraph } from "../lib/simple.ts";
+
+let calls = 0, uploads = 0;
+const prompts: ApiGraph[] = [];
+let history: Record<string, unknown> = {};
+let queued = false, rejectPrompt = false;
+let range: string | undefined;
+let viewed = "";
+const server = createServer(async (request, response) => {
+ calls++;
+ if (request.url?.startsWith("/view?")) {
+ range = request.headers.range; viewed = request.url;
+ response.writeHead(range ? 206 : 200, { "Content-Type": "image/png", ...(range ? { "Content-Range": "bytes 0-3/4" } : {}) });
+ response.end("test"); return;
+ }
+ let data: unknown;
+ if (request.url === "/upload/image") {
+ for await (const _ of request) {}
+ data = { name: `uploaded-${++uploads}.png`, subfolder: "picture" };
+ } else if (request.url === "/prompt") {
+ const chunks = []; for await (const chunk of request) chunks.push(chunk);
+ prompts.push(JSON.parse(Buffer.concat(chunks).toString()).prompt);
+ if (rejectPrompt) {
+ response.writeHead(400, { "Content-Type": "application/json" });
+ response.end(JSON.stringify({ node_errors: { "10": { errors: [{ message: "Value not in list", details: "Missing FLUX model" }] } } })); return;
+ }
+ data = { prompt_id: `picture-${prompts.length}` };
+ } else if (request.url === "/queue") data = { queue_running: [], queue_pending: queued ? [[1, "picture-1"]] : [] };
+ else data = history;
+ response.writeHead(200, { "Content-Type": "application/json" }); response.end(JSON.stringify(data));
+});
+server.listen(0, "127.0.0.1"); await once(server, "listening");
+process.env.COMFYUI_URL = `http://127.0.0.1:${(server.address() as AddressInfo).port}/`;
+delete process.env.OPENJUTSU_PASSWORD;
+test.after(() => { server.closeAllConnections(); server.close(); });
+const url = "http://127.0.0.1:3000/api/picture";
+function inputs() {
+ const form = new FormData();
+ form.set("video", new File([new Uint8Array([0, 0, 0, 0x18]), "ftypisom"], "clip.mp4", { type: "video/mp4" }));
+ form.set("picture", new File([new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])], "character.png", { type: "image/png" }));
+ form.set("width", "1280"); form.set("height", "720"); form.set("start", "2.5"); form.set("seed", "42");
+ return form;
+}
+function render(prepared: string) {
+ return POST(new Request(url, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ prepared, filename: "untrusted.png", prompt: { untrusted: true } }) }));
+}
+function completed() {
+ return { prompt: [0, "picture-1", prompts[0]], status: { status_str: "success", completed: true }, outputs: {
+ "21": { images: [{ filename: "prepared.png", subfolder: "openjutsu_picture/flux3", type: "output" }] },
+ "22": { images: [{ filename: "frame.png", type: "temp" }] },
+ } };
+}
+
+test("picture routes reject foreign origins, invalid IDs and invalid uploads before contacting ComfyUI", async () => {
+ assert.equal((await POST(new Request(url, { method: "POST", headers: { Origin: "https://other.test" } }))).status, 403);
+ assert.equal((await GET(new Request(`${url}?id=https://other.test`))).status, 400);
+ assert.equal((await render("../not-a-job")).status, 400);
+ const form = inputs(); form.set("picture", new File(["bad"], "fake.png"));
+ assert.equal((await POST(new Request(url, { method: "POST", body: form }))).status, 400);
+ assert.equal(calls, 0);
+});
+
+test("preparation submits only FLUX, preserves image order and selected frame, and uses the source aspect ratio", async () => {
+ const form = inputs(); form.set("prompt", "Keep the character and background of image 1; use image 2's pose.");
+ const response = await POST(new Request(url, { method: "POST", body: form }));
+ assert.equal(response.status, 202); assert.equal((await response.json()).id, "picture-1");
+ const graph = prompts[0];
+ assert.equal(graph["1"].inputs.video, "picture/uploaded-1.png");
+ assert.equal(graph["4"].inputs.image, "picture/uploaded-2.png");
+ assert.equal(graph["1"].inputs.frame_load_cap, 1); assert.equal(graph["1"].inputs.skip_first_frames, 60);
+ assert.equal(graph["19"].inputs.seed, 42);
+ assert.equal(graph["3"].inputs.width, 1376); assert.equal(graph["3"].inputs.height, 768);
+ assert.deepEqual(graph["15"].inputs["images.image0"], ["5", 0]);
+ assert.deepEqual(graph["15"].inputs["images.image1"], ["3", 0]);
+ assert.equal(graph["6"].inputs.value, form.get("prompt"));
+ assert.ok(!Object.values(graph).some((node) => /MiniMax|Metric3D|VideoCombine/.test(node.class_type)));
+ assert.equal(prompts.length, 1);
+});
+
+test("preview polling returns the image and source frame without automatically submitting a video", async () => {
+ queued = true;
+ assert.equal((await (await GET(new Request(`${url}?id=picture-1`))).json()).status, "processing");
+ queued = false;
+ assert.equal((await GET(new Request(`${url}?id=picture-1`))).status, 404);
+ history = { "picture-1": completed() };
+ const ready = await (await GET(new Request(`${url}?id=picture-1`))).json();
+ assert.equal(ready.status, "ready"); assert.ok(ready.frame.endsWith("media=frame"));
+ const response = await GET(new Request(`${url}?id=picture-1&media=result`));
+ assert.equal(await response.text(), "test"); assert.ok(viewed.includes("filename=prepared.png"));
+ await GET(new Request(`${url}?id=picture-1&media=frame`));
+ assert.ok(viewed.includes("filename=frame.png")); assert.equal(prompts.length, 1);
+});
+
+test("explicit render uses the exact saved preview, retains the source offset and runs H3 without rerunning FLUX", async () => {
+ const response = await render("picture-1");
+ assert.equal(response.status, 202); assert.equal((await response.json()).id, "picture-2");
+ const graph = prompts[1];
+ assert.equal(graph["20"].class_type, "LoadImage"); assert.equal(graph["20"].inputs.image, "picture/uploaded-3.png");
+ assert.deepEqual(graph["56"].inputs["ref_images.ref_image_0"], ["20", 0]);
+ assert.equal(graph["1"].inputs.video, prompts[0]["1"].inputs.video);
+ assert.equal(graph["1"].inputs.skip_first_frames, 60); assert.equal(graph["1"].inputs.frame_load_cap, 141);
+ assert.equal(graph["33"].inputs.width, 864); assert.equal(graph["56"].inputs.width, 864);
+ assert.equal(graph["33"].inputs.height, 480); assert.equal(graph["56"].inputs.height, 480);
+ assert.equal(graph["58"].inputs.noise_seed, 42);
+ assert.ok(!Object.values(graph).some((node) => /ReferenceMultiLatent|TextGenerate|SaveImage/.test(node.class_type)));
+ assert.deepEqual(graph["63"].inputs.audio, ["36", 0]);
+});
+
+test("render rejects unfinished, unrelated and failed histories instead of accepting a client filename", async () => {
+ const count = prompts.length;
+ history = {}; assert.equal((await render("picture-1")).status, 409);
+ history = { "picture-1": { prompt: [0, "picture-1", { "21": { class_type: "SaveImage" } }] } };
+ assert.equal((await render("picture-1")).status, 404);
+ history = { "picture-1": { ...completed(), status: { status_str: "error" } } };
+ assert.equal((await render("picture-1")).status, 422); assert.equal(prompts.length, count);
+});
+
+test("video media supports seeking and submission errors identify missing models", async () => {
+ history = { "picture-2": { prompt: [0, "picture-2", prompts[1]], outputs: { "63": { gifs: [{ filename: "motion.mp4", type: "output" }] } } } };
+ const response = await GET(new Request(`${url}?id=picture-2&media=result`, { headers: { Range: "bytes=0-3" } }));
+ assert.equal(response.status, 206); assert.equal(range, "bytes=0-3");
+ assert.equal(response.headers.get("Content-Type"), "video/mp4"); assert.equal(response.headers.get("X-Content-Type-Options"), "nosniff");
+ assert.equal(response.headers.get("Content-Range"), "bytes 0-3/4"); await response.text();
+ rejectPrompt = true;
+ const rejected = await POST(new Request(url, { method: "POST", body: inputs() }));
+ assert.equal(rejected.status, 502); assert.match((await rejected.json()).error, /Missing FLUX model/);
+});
diff --git a/workflows/build/openjutsu_picture_pipeline.py b/workflows/build/openjutsu_picture_pipeline.py
new file mode 100644
index 0000000..1a1fd3d
--- /dev/null
+++ b/workflows/build/openjutsu_picture_pipeline.py
@@ -0,0 +1,113 @@
+"""Build raw-frame image editing and normal-guided H3 workflows."""
+import argparse
+import copy
+import json
+from pathlib import Path
+
+
+EDIT_PROMPT = "change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>."
+EDIT_SYSTEM = """You are an image-editing prompt upsampler. The attached images are ordered: image 1 is the character image and image 2 is the raw first frame from a video. Expand the user's request into one precise editing instruction. Keep every requested constraint. Use gender-neutral wording such as 'the character'; do not add a fixed gender.
+
+Image 1 supplies the identity, hairstyle, complete outfit, background and lighting. Image 2 supplies only the starting body pose, head orientation, arm positions, hand positions, leg positions, camera perspective, relative character size, position within the frame and body cut. Describe those pose and framing changes concretely from image 2. Replace the original pose of image 1 instead of retaining it. Keep the character and the background of image 1; do not copy the identity, hairstyle, clothes, props, setting or colors of image 2, and do not add extra objects. Describe the intended still image, not later video movements. Output only one English editing instruction, without Markdown or explanation."""
+VIDEO_PROMPT = """subject_definitions:
+<Picture 1> defines the character, outfit, background, colors, materials and lighting throughout the output.
+<Video 1> is a false-color surface-normal motion guide at 24 fps. Its colors describe surface orientation, not the appearance of the final video. Use the moving character's geometry, body pose, arm and leg movements, head direction, framing and timing as the motion reference.
+<Audio 1> is the original synchronized soundtrack.
+
+summary:
+[video editing + reference generation + audio reuse] Animate the character from <Picture 1> with the performance and framing of the character in <Video 1>. Keep the identity, outfit, background and lighting of <Picture 1>. The picture is the appearance reference; the normal-map video is the motion reference.
+
+detailed_description:
+Follow the motion guide's poses and gestures at the corresponding moments, through the last frame. Match its relative character size, camera perspective and any camera movement. Keep the picture's environment coherent throughout the performance. Do not copy the normal-map colors or replace the picture's setting with the source video's setting. Do not hold the reference picture's starting pose as the guide moves. Keep lighting and contact shadows consistent with the picture. Match visible speech to <Audio 1> when present.
+
+overall_soundscape:
+Reuse <Audio 1> unchanged. Add no new voices, music or sound effects."""
+
+
+def node(kind, title, **inputs):
+ return {"class_type": kind, "inputs": inputs, "_meta": {"title": title}}
+
+
+def prepare(video, picture, edit_width=768, edit_height=1376):
+ graph = {
+ "1": node("VHS_LoadVideo", "1 · Source video — first selected frame", video=video, force_rate=24.0,
+ custom_width=0, custom_height=0, frame_load_cap=1, skip_first_frames=0, select_every_nth=1, format="None"),
+ "2": node("ImageFromBatch", "Raw first frame", image=["1", 0], batch_index=0, length=1),
+ "3": node("ImageScale", "Image 2 · First frame / pose and body cut", image=["2", 0], upscale_method="lanczos",
+ width=edit_width, height=edit_height, crop="center"),
+ "4": node("LoadImage", "2 · Image 1 / character and background", image=picture),
+ "5": node("ImageScale", "Image 1 · Character / editor canvas", image=["4", 0], upscale_method="lanczos",
+ width=edit_width, height=edit_height, crop="center"),
+ "20": node("VAEDecode", "Prepared first frame", samples=["19", 0], vae=["12", 0]),
+ "21": node("SaveImage", "3 · Save prepared first frame", images=["20", 0], filename_prefix="openjutsu_picture/flux3/prepared_frame"),
+ "22": node("PreviewImage", "Raw first frame — compare composition", images=["3", 0]),
+ "6": node("PrimitiveStringMultiline", "Edit request · image 1 character / image 2 raw frame", value=EDIT_PROMPT),
+ "7": node("ImageBatch", "Character first, raw frame second", image1=["5", 0], image2=["3", 0]),
+ "8": node("ImageScaleToMaxDimension", "Images for the prompt upsampler", image=["7", 0], largest_size=768, upscale_method="area"),
+ "9": node("CLIPLoader", "FLUX 3 image-edit prompt upsampler", clip_name="qwen3.5_9b_flux3_prompt_upsampler_int8_convrot.safetensors", type="flux3", device="default"),
+ "23": node("TextGenerate", "Describe the raw frame's pose for the edit", clip=["9", 0], image=["8", 0], prompt=["6", 0],
+ system_prompt=["25", 0], max_length=700, sampling_mode="off", thinking=False, use_default_template=True, mtp="off"),
+ "24": node("PreviewAny", "Expanded editing instruction", source=["23", 0]),
+ "25": node("PrimitiveStringMultiline", "Image-edit prompt expansion rules", value=EDIT_SYSTEM),
+ }
+ graph.update({
+ "10": node("UNETLoader", "FLUX 3 Image Klein SD", unet_name="flux3_image_klein_sd_int8_convrot.safetensors", weight_dtype="default"),
+ "11": node("CLIPLoader", "FLUX 3 text encoder", clip_name="qwen3vl_4b_fp8_scaled.safetensors", type="flux3", device="default"),
+ "12": node("VAELoader", "FLUX VAE", vae_name="flux2-vae.safetensors"),
+ "13": node("CLIPTextEncode", "Expanded FLUX editing instruction", clip=["11", 0], text=["23", 0]),
+ "14": node("ConditioningZeroOut", "Empty negative", conditioning=["13", 0]),
+ "15": node("ReferenceMultiLatent", "Both raw image references reach FLUX", positive=["13", 0], negative=["14", 0], vae=["12", 0],
+ resolution="keep resolution", **{"images.image0": ["5", 0], "images.image1": ["3", 0]}),
+ "19": node("KSampler", "Prepare pose · FLUX 3", model=["10", 0], seed=0, steps=16, cfg=1.0,
+ sampler_name="euler", scheduler="simple", denoise=1.0, positive=["15", 0], negative=["15", 1], latent_image=["15", 2]),
+ })
+ return graph
+
+
+def motion(prepared, width=480, height=864, frames=141):
+ graph = copy.deepcopy(prepared)
+ graph["1"]["inputs"]["frame_load_cap"] = frames
+ graph["1"]["_meta"]["title"] = "1 · Source video — selected motion clip"
+ graph.update({
+ "30": node("VRAM_Debug", "Release editor VRAM before Metric3D", empty_cache=True, gc_collect=True, unload_all_models=True,
+ any_input=["20", 0], image_pass=["1", 0]),
+ "31": node("ImageScaleToMaxDimension", "Metric3D input video", image=["30", 1], largest_size=768, upscale_method="area"),
+ "32": node("Metric3D-NormalMapPreprocessor", "4 · Source motion normals", image=["31", 0], backbone="vit-small", fx=1000, fy=1000, resolution=512),
+ "33": node("ImageScale", "Normals match the output canvas", image=["32", 0], width=width, height=height, upscale_method="lanczos", crop="disabled"),
+ "34": node("ImageFromBatch", "First normal-map frame", image=["33", 0], batch_index=0, length=1),
+ "35": node("PreviewImage", "Normal-map preview", images=["34", 0]),
+ "36": node("H3SoundtrackOrSilence", "Original soundtrack / silence when absent", audio=["1", 2], video_info=["1", 3]),
+ "50": node("UNETLoader", "H3 Diffusion Model", unet_name="minimax_h3_ref2va_pruned_int8_convrot.safetensors", weight_dtype="default"),
+ "51": node("LoraLoaderModelOnly", "DMAD LoRA", model=["50", 0], lora_name="minimax_h3_DMAD_4step_full_lora_avg_rank_39_bf16.safetensors", strength_model=1.0),
+ "52": node("MiniMaxH3SigmaShift", "H3 Sigma Shift", model=["51", 0], shift_video=12.0, shift_audio=2.0),
+ "53": node("CLIPLoader", "H3 Text Encoder", clip_name="qwen3vl_32b_minimax_h3_int4_convrot.safetensors", type="minimax", device="default"),
+ "54": node("VAELoader", "H3 Video VAE", vae_name="minimax_h3_video_vae_int8_convrot.safetensors"),
+ "55": node("VAELoader", "H3 Audio VAE", vae_name="minimax_h3_audio_vae_fp32.safetensors"),
+ "56": node("MiniMaxH3ReferenceToVideo", "5 · Prepared picture + normal motion reference", clip=["53", 0], vae=["54", 0], audio_vae=["55", 0],
+ prompt=VIDEO_PROMPT, width=width, height=height, length=frames, ref_image_size="match",
+ **{"ref_images.ref_image_0": ["20", 0], "ref_videos.ref_video_0": ["33", 0], "ref_video_audios.ref_video_audio_0": ["36", 0]}),
+ "57": node("BasicGuider", "H3 Guider", model=["52", 0], conditioning=["56", 0]),
+ "58": node("RandomNoise", "Video seed", noise_seed=2577489884),
+ "59": node("KSamplerSelect", "Video sampler", sampler_name="euler"),
+ "60": node("BasicScheduler", "H3 · 6 steps", model=["52", 0], scheduler="simple", steps=6, denoise=1.0),
+ "61": node("SamplerCustomAdvanced", "Generate motion", noise=["58", 0], guider=["57", 0], sampler=["59", 0], sigmas=["60", 0], latent_image=["56", 1]),
+ "62": node("VAEDecode", "Decode video", samples=["61", 0], vae=["54", 0]),
+ "63": node("VHS_VideoCombine", "6 · Result with original soundtrack", images=["62", 0], audio=["36", 0], frame_rate=24.0, loop_count=0,
+ filename_prefix="openjutsu_picture/flux3/normal_motion", format="video/h264-mp4", pix_fmt="yuv420p", crf=16,
+ save_metadata=False, trim_to_audio=False, pingpong=False, save_output=True),
+ })
+ return graph
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--video", default="instagram1_normal_source_20261027.mp4", help="Filename in ComfyUI input/")
+ parser.add_argument("--picture", default="Stylish%20Blonde%20in%20a%20Warm%20Cafe.png", help="Original character image in ComfyUI input/")
+ parser.add_argument("--output-dir", type=Path, default=Path(__file__).resolve().parents[1]/"picture")
+ args = parser.parse_args()
+ args.output_dir.mkdir(parents=True, exist_ok=True)
+ first = prepare(args.video, args.picture)
+ for name, graph in [("prepare", first), ("motion", motion(first))]:
+ path = args.output_dir/f"from_picture_{name}_flux3.api.json"
+ path.write_text(json.dumps(dict(sorted(graph.items(), key=lambda item: int(item[0]))), indent=2, ensure_ascii=False)+"\n", encoding="utf-8")
+ print(path)
diff --git a/workflows/picture/README.md b/workflows/picture/README.md
new file mode 100644
index 0000000..65208ac
--- /dev/null
+++ b/workflows/picture/README.md
@@ -0,0 +1,42 @@
+# From picture pipelines
+
+These are ComfyUI API-format workflows. Drop a JSON file onto ComfyUI, or use **File → Open**.
+
+The app uses them under **Object swap → From picture**. Choose the video and character picture, then **Generate preview image**. Compare the FLUX image with the raw frame, adjust the prompt or generate another image if needed, and click **Use this image · render video** when ready. Previewing never starts H3 automatically. The video stage loads the saved preview image and does not rerun FLUX. Both stages use `COMFYUI_URL` directly; comfy-api-proxy is not required for this tab. Pending jobs and the selected preview resume when returning to the tab or refreshing the page.
+
+| Workflow | Result |
+| --- | --- |
+| `from_picture_prepare_flux3.api.json` | FLUX 3 prepares and saves the first-frame picture. |
+| `from_picture_motion_flux3.api.json` | FLUX preparation → Metric3D normals → H3 video. |
+
+Start with a **prepare** workflow. In **Source video**, choose the uploaded video and its `skip_first_frames`; in **Image 1 / character and background**, choose the original character picture. The first selected raw frame becomes image 2. There is no DWPose or skeleton input.
+
+The edit request is editable and defaults to:
+
+```text
+change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>.
+```
+
+The image-aware prompt upsampler sees both references and expands that request into an editing instruction. Both references also reach FLUX directly, in the same order. The expansion rules use gender-neutral wording. This first version uses FLUX; the Qwen Image trial copied the source setting into the result.
+
+Preparation defaults to a 768×1376 canvas and saves under `ComfyUI/output/openjutsu_picture/flux3/prepared_frame_*.png`. Compare the prepared picture against the raw first-frame preview before using it for video; a successful execution does not guarantee that the requested pose was followed.
+
+The **motion** variants wire the decoded prepared picture directly into H3. No manual re-upload is needed. They default to **141 frames / 5.875 seconds at 24 fps**, 480×864, six DMAD steps, and the original soundtrack (or silence if absent). They are single-clip workflows; they do not process a whole longer video or add context-loop continuation. Change `frame_load_cap` and H3's `length` together to select another valid H3 clip length.
+
+Normals are resized directly to the H3 output canvas. If changing that canvas, change both **Normals match the output canvas** and **Prepared picture + normal motion reference**. Normals are soft reference-video conditioning, not a trained normal ControlNet. The VRAM cleanup node runs after the image edit and before Metric3D to make room for its model.
+
+Required installed models are selected in the loader nodes. Defaults match this installation:
+
+- FLUX: `flux3_image_klein_sd_int8_convrot.safetensors`, `qwen3vl_4b_fp8_scaled.safetensors`, `flux2-vae.safetensors`, plus `qwen3.5_9b_flux3_prompt_upsampler_int8_convrot.safetensors`.
+- Video: the H3 pruned INT8 ref2va model, DMAD LoRA, H3 text encoder and VAEs used by the existing workflows.
+- Custom nodes: VideoHelperSuite; KJNodes for VRAM cleanup; `comfyui_controlnet_aux` for Metric3D; the one-click swap pack for soundless-video handling. Metric3D-small's checkpoint is needed for the motion variants.
+
+Regenerate the files from the repository root:
+
+```powershell
+python workflows/build/openjutsu_picture_pipeline.py --video "video.mp4" --picture "character.png"
+```
+
+Names refer to files in ComfyUI's `input` directory. The generated defaults use the current Instagram test clip and original café character picture; choose your own files after importing.
+
+Validated locally: image preparation → review → explicit video render completed in the app. The saved preview and H3's picture input were byte-identical. The result contains 141 frames at 480×864 and 24 fps, with audio, and the app supports video seeking. Temporary server outages and page refreshes preserve pending jobs. Automated tests, TypeScript checking and the production build pass. The café stayed consistent; precise pose and framing remain approximate.
diff --git a/workflows/picture/from_picture_motion_flux3.api.json b/workflows/picture/from_picture_motion_flux3.api.json
new file mode 100644
index 0000000..9e94adc
--- /dev/null
+++ b/workflows/picture/from_picture_motion_flux3.api.json
@@ -0,0 +1,661 @@
+{
+ "1": {
+ "class_type": "VHS_LoadVideo",
+ "inputs": {
+ "video": "instagram1_normal_source_20261027.mp4",
+ "force_rate": 24.0,
+ "custom_width": 0,
+ "custom_height": 0,
+ "frame_load_cap": 141,
+ "skip_first_frames": 0,
+ "select_every_nth": 1,
+ "format": "None"
+ },
+ "_meta": {
+ "title": "1 · Source video — selected motion clip"
+ }
+ },
+ "2": {
+ "class_type": "ImageFromBatch",
+ "inputs": {
+ "image": [
+ "1",
+ 0
+ ],
+ "batch_index": 0,
+ "length": 1
+ },
+ "_meta": {
+ "title": "Raw first frame"
+ }
+ },
+ "3": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "2",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 768,
+ "height": 1376,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "Image 2 · First frame / pose and body cut"
+ }
+ },
+ "4": {
+ "class_type": "LoadImage",
+ "inputs": {
+ "image": "Stylish%20Blonde%20in%20a%20Warm%20Cafe.png"
+ },
+ "_meta": {
+ "title": "2 · Image 1 / character and background"
+ }
+ },
+ "5": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "4",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 768,
+ "height": 1376,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "Image 1 · Character / editor canvas"
+ }
+ },
+ "6": {
+ "class_type": "PrimitiveStringMultiline",
+ "inputs": {
+ "value": "change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>."
+ },
+ "_meta": {
+ "title": "Edit request · image 1 character / image 2 raw frame"
+ }
+ },
+ "7": {
+ "class_type": "ImageBatch",
+ "inputs": {
+ "image1": [
+ "5",
+ 0
+ ],
+ "image2": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Character first, raw frame second"
+ }
+ },
+ "8": {
+ "class_type": "ImageScaleToMaxDimension",
+ "inputs": {
+ "image": [
+ "7",
+ 0
+ ],
+ "largest_size": 768,
+ "upscale_method": "area"
+ },
+ "_meta": {
+ "title": "Images for the prompt upsampler"
+ }
+ },
+ "9": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "qwen3.5_9b_flux3_prompt_upsampler_int8_convrot.safetensors",
+ "type": "flux3",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 image-edit prompt upsampler"
+ }
+ },
+ "10": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "flux3_image_klein_sd_int8_convrot.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 Image Klein SD"
+ }
+ },
+ "11": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "qwen3vl_4b_fp8_scaled.safetensors",
+ "type": "flux3",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 text encoder"
+ }
+ },
+ "12": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "flux2-vae.safetensors"
+ },
+ "_meta": {
+ "title": "FLUX VAE"
+ }
+ },
+ "13": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": [
+ "23",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Expanded FLUX editing instruction"
+ }
+ },
+ "14": {
+ "class_type": "ConditioningZeroOut",
+ "inputs": {
+ "conditioning": [
+ "13",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Empty negative"
+ }
+ },
+ "15": {
+ "class_type": "ReferenceMultiLatent",
+ "inputs": {
+ "positive": [
+ "13",
+ 0
+ ],
+ "negative": [
+ "14",
+ 0
+ ],
+ "vae": [
+ "12",
+ 0
+ ],
+ "resolution": "keep resolution",
+ "images.image0": [
+ "5",
+ 0
+ ],
+ "images.image1": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Both raw image references reach FLUX"
+ }
+ },
+ "19": {
+ "class_type": "KSampler",
+ "inputs": {
+ "model": [
+ "10",
+ 0
+ ],
+ "seed": 0,
+ "steps": 16,
+ "cfg": 1.0,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "denoise": 1.0,
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "15",
+ 2
+ ]
+ },
+ "_meta": {
+ "title": "Prepare pose · FLUX 3"
+ }
+ },
+ "20": {
+ "class_type": "VAEDecode",
+ "inputs": {
+ "samples": [
+ "19",
+ 0
+ ],
+ "vae": [
+ "12",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Prepared first frame"
+ }
+ },
+ "21": {
+ "class_type": "SaveImage",
+ "inputs": {
+ "images": [
+ "20",
+ 0
+ ],
+ "filename_prefix": "openjutsu_picture/flux3/prepared_frame"
+ },
+ "_meta": {
+ "title": "3 · Save prepared first frame"
+ }
+ },
+ "22": {
+ "class_type": "PreviewImage",
+ "inputs": {
+ "images": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Raw first frame — compare composition"
+ }
+ },
+ "23": {
+ "class_type": "TextGenerate",
+ "inputs": {
+ "clip": [
+ "9",
+ 0
+ ],
+ "image": [
+ "8",
+ 0
+ ],
+ "prompt": [
+ "6",
+ 0
+ ],
+ "system_prompt": [
+ "25",
+ 0
+ ],
+ "max_length": 700,
+ "sampling_mode": "off",
+ "thinking": false,
+ "use_default_template": true,
+ "mtp": "off"
+ },
+ "_meta": {
+ "title": "Describe the raw frame's pose for the edit"
+ }
+ },
+ "24": {
+ "class_type": "PreviewAny",
+ "inputs": {
+ "source": [
+ "23",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Expanded editing instruction"
+ }
+ },
+ "25": {
+ "class_type": "PrimitiveStringMultiline",
+ "inputs": {
+ "value": "You are an image-editing prompt upsampler. The attached images are ordered: image 1 is the character image and image 2 is the raw first frame from a video. Expand the user's request into one precise editing instruction. Keep every requested constraint. Use gender-neutral wording such as 'the character'; do not add a fixed gender.\n\nImage 1 supplies the identity, hairstyle, complete outfit, background and lighting. Image 2 supplies only the starting body pose, head orientation, arm positions, hand positions, leg positions, camera perspective, relative character size, position within the frame and body cut. Describe those pose and framing changes concretely from image 2. Replace the original pose of image 1 instead of retaining it. Keep the character and the background of image 1; do not copy the identity, hairstyle, clothes, props, setting or colors of image 2, and do not add extra objects. Describe the intended still image, not later video movements. Output only one English editing instruction, without Markdown or explanation."
+ },
+ "_meta": {
+ "title": "Image-edit prompt expansion rules"
+ }
+ },
+ "30": {
+ "class_type": "VRAM_Debug",
+ "inputs": {
+ "empty_cache": true,
+ "gc_collect": true,
+ "unload_all_models": true,
+ "any_input": [
+ "20",
+ 0
+ ],
+ "image_pass": [
+ "1",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Release editor VRAM before Metric3D"
+ }
+ },
+ "31": {
+ "class_type": "ImageScaleToMaxDimension",
+ "inputs": {
+ "image": [
+ "30",
+ 1
+ ],
+ "largest_size": 768,
+ "upscale_method": "area"
+ },
+ "_meta": {
+ "title": "Metric3D input video"
+ }
+ },
+ "32": {
+ "class_type": "Metric3D-NormalMapPreprocessor",
+ "inputs": {
+ "image": [
+ "31",
+ 0
+ ],
+ "backbone": "vit-small",
+ "fx": 1000,
+ "fy": 1000,
+ "resolution": 512
+ },
+ "_meta": {
+ "title": "4 · Source motion normals"
+ }
+ },
+ "33": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "32",
+ 0
+ ],
+ "width": 480,
+ "height": 864,
+ "upscale_method": "lanczos",
+ "crop": "disabled"
+ },
+ "_meta": {
+ "title": "Normals match the output canvas"
+ }
+ },
+ "34": {
+ "class_type": "ImageFromBatch",
+ "inputs": {
+ "image": [
+ "33",
+ 0
+ ],
+ "batch_index": 0,
+ "length": 1
+ },
+ "_meta": {
+ "title": "First normal-map frame"
+ }
+ },
+ "35": {
+ "class_type": "PreviewImage",
+ "inputs": {
+ "images": [
+ "34",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Normal-map preview"
+ }
+ },
+ "36": {
+ "class_type": "H3SoundtrackOrSilence",
+ "inputs": {
+ "audio": [
+ "1",
+ 2
+ ],
+ "video_info": [
+ "1",
+ 3
+ ]
+ },
+ "_meta": {
+ "title": "Original soundtrack / silence when absent"
+ }
+ },
+ "50": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "minimax_h3_ref2va_pruned_int8_convrot.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "H3 Diffusion Model"
+ }
+ },
+ "51": {
+ "class_type": "LoraLoaderModelOnly",
+ "inputs": {
+ "model": [
+ "50",
+ 0
+ ],
+ "lora_name": "minimax_h3_DMAD_4step_full_lora_avg_rank_39_bf16.safetensors",
+ "strength_model": 1.0
+ },
+ "_meta": {
+ "title": "DMAD LoRA"
+ }
+ },
+ "52": {
+ "class_type": "MiniMaxH3SigmaShift",
+ "inputs": {
+ "model": [
+ "51",
+ 0
+ ],
+ "shift_video": 12.0,
+ "shift_audio": 2.0
+ },
+ "_meta": {
+ "title": "H3 Sigma Shift"
+ }
+ },
+ "53": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "qwen3vl_32b_minimax_h3_int4_convrot.safetensors",
+ "type": "minimax",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "H3 Text Encoder"
+ }
+ },
+ "54": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "minimax_h3_video_vae_int8_convrot.safetensors"
+ },
+ "_meta": {
+ "title": "H3 Video VAE"
+ }
+ },
+ "55": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "minimax_h3_audio_vae_fp32.safetensors"
+ },
+ "_meta": {
+ "title": "H3 Audio VAE"
+ }
+ },
+ "56": {
+ "class_type": "MiniMaxH3ReferenceToVideo",
+ "inputs": {
+ "clip": [
+ "53",
+ 0
+ ],
+ "vae": [
+ "54",
+ 0
+ ],
+ "audio_vae": [
+ "55",
+ 0
+ ],
+ "prompt": "subject_definitions:\n<Picture 1> defines the character, outfit, background, colors, materials and lighting throughout the output.\n<Video 1> is a false-color surface-normal motion guide at 24 fps. Its colors describe surface orientation, not the appearance of the final video. Use the moving character's geometry, body pose, arm and leg movements, head direction, framing and timing as the motion reference.\n<Audio 1> is the original synchronized soundtrack.\n\nsummary:\n[video editing + reference generation + audio reuse] Animate the character from <Picture 1> with the performance and framing of the character in <Video 1>. Keep the identity, outfit, background and lighting of <Picture 1>. The picture is the appearance reference; the normal-map video is the motion reference.\n\ndetailed_description:\nFollow the motion guide's poses and gestures at the corresponding moments, through the last frame. Match its relative character size, camera perspective and any camera movement. Keep the picture's environment coherent throughout the performance. Do not copy the normal-map colors or replace the picture's setting with the source video's setting. Do not hold the reference picture's starting pose as the guide moves. Keep lighting and contact shadows consistent with the picture. Match visible speech to <Audio 1> when present.\n\noverall_soundscape:\nReuse <Audio 1> unchanged. Add no new voices, music or sound effects.",
+ "width": 480,
+ "height": 864,
+ "length": 141,
+ "ref_image_size": "match",
+ "ref_images.ref_image_0": [
+ "20",
+ 0
+ ],
+ "ref_videos.ref_video_0": [
+ "33",
+ 0
+ ],
+ "ref_video_audios.ref_video_audio_0": [
+ "36",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "5 · Prepared picture + normal motion reference"
+ }
+ },
+ "57": {
+ "class_type": "BasicGuider",
+ "inputs": {
+ "model": [
+ "52",
+ 0
+ ],
+ "conditioning": [
+ "56",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "H3 Guider"
+ }
+ },
+ "58": {
+ "class_type": "RandomNoise",
+ "inputs": {
+ "noise_seed": 2577489884
+ },
+ "_meta": {
+ "title": "Video seed"
+ }
+ },
+ "59": {
+ "class_type": "KSamplerSelect",
+ "inputs": {
+ "sampler_name": "euler"
+ },
+ "_meta": {
+ "title": "Video sampler"
+ }
+ },
+ "60": {
+ "class_type": "BasicScheduler",
+ "inputs": {
+ "model": [
+ "52",
+ 0
+ ],
+ "scheduler": "simple",
+ "steps": 6,
+ "denoise": 1.0
+ },
+ "_meta": {
+ "title": "H3 · 6 steps"
+ }
+ },
+ "61": {
+ "class_type": "SamplerCustomAdvanced",
+ "inputs": {
+ "noise": [
+ "58",
+ 0
+ ],
+ "guider": [
+ "57",
+ 0
+ ],
+ "sampler": [
+ "59",
+ 0
+ ],
+ "sigmas": [
+ "60",
+ 0
+ ],
+ "latent_image": [
+ "56",
+ 1
+ ]
+ },
+ "_meta": {
+ "title": "Generate motion"
+ }
+ },
+ "62": {
+ "class_type": "VAEDecode",
+ "inputs": {
+ "samples": [
+ "61",
+ 0
+ ],
+ "vae": [
+ "54",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Decode video"
+ }
+ },
+ "63": {
+ "class_type": "VHS_VideoCombine",
+ "inputs": {
+ "images": [
+ "62",
+ 0
+ ],
+ "audio": [
+ "36",
+ 0
+ ],
+ "frame_rate": 24.0,
+ "loop_count": 0,
+ "filename_prefix": "openjutsu_picture/flux3/normal_motion",
+ "format": "video/h264-mp4",
+ "pix_fmt": "yuv420p",
+ "crf": 16,
+ "save_metadata": false,
+ "trim_to_audio": false,
+ "pingpong": false,
+ "save_output": true
+ },
+ "_meta": {
+ "title": "6 · Result with original soundtrack"
+ }
+ }
+}
diff --git a/workflows/picture/from_picture_prepare_flux3.api.json b/workflows/picture/from_picture_prepare_flux3.api.json
new file mode 100644
index 0000000..806a936
--- /dev/null
+++ b/workflows/picture/from_picture_prepare_flux3.api.json
@@ -0,0 +1,331 @@
+{
+ "1": {
+ "class_type": "VHS_LoadVideo",
+ "inputs": {
+ "video": "instagram1_normal_source_20261027.mp4",
+ "force_rate": 24.0,
+ "custom_width": 0,
+ "custom_height": 0,
+ "frame_load_cap": 1,
+ "skip_first_frames": 0,
+ "select_every_nth": 1,
+ "format": "None"
+ },
+ "_meta": {
+ "title": "1 · Source video — first selected frame"
+ }
+ },
+ "2": {
+ "class_type": "ImageFromBatch",
+ "inputs": {
+ "image": [
+ "1",
+ 0
+ ],
+ "batch_index": 0,
+ "length": 1
+ },
+ "_meta": {
+ "title": "Raw first frame"
+ }
+ },
+ "3": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "2",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 768,
+ "height": 1376,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "Image 2 · First frame / pose and body cut"
+ }
+ },
+ "4": {
+ "class_type": "LoadImage",
+ "inputs": {
+ "image": "Stylish%20Blonde%20in%20a%20Warm%20Cafe.png"
+ },
+ "_meta": {
+ "title": "2 · Image 1 / character and background"
+ }
+ },
+ "5": {
+ "class_type": "ImageScale",
+ "inputs": {
+ "image": [
+ "4",
+ 0
+ ],
+ "upscale_method": "lanczos",
+ "width": 768,
+ "height": 1376,
+ "crop": "center"
+ },
+ "_meta": {
+ "title": "Image 1 · Character / editor canvas"
+ }
+ },
+ "6": {
+ "class_type": "PrimitiveStringMultiline",
+ "inputs": {
+ "value": "change <image 1> character pose follow the <image 2> pose. keep the final image as same body cut as <image 2> . do not change the background of <image 1> and do not add anything extra in <image 1>."
+ },
+ "_meta": {
+ "title": "Edit request · image 1 character / image 2 raw frame"
+ }
+ },
+ "7": {
+ "class_type": "ImageBatch",
+ "inputs": {
+ "image1": [
+ "5",
+ 0
+ ],
+ "image2": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Character first, raw frame second"
+ }
+ },
+ "8": {
+ "class_type": "ImageScaleToMaxDimension",
+ "inputs": {
+ "image": [
+ "7",
+ 0
+ ],
+ "largest_size": 768,
+ "upscale_method": "area"
+ },
+ "_meta": {
+ "title": "Images for the prompt upsampler"
+ }
+ },
+ "9": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "qwen3.5_9b_flux3_prompt_upsampler_int8_convrot.safetensors",
+ "type": "flux3",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 image-edit prompt upsampler"
+ }
+ },
+ "10": {
+ "class_type": "UNETLoader",
+ "inputs": {
+ "unet_name": "flux3_image_klein_sd_int8_convrot.safetensors",
+ "weight_dtype": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 Image Klein SD"
+ }
+ },
+ "11": {
+ "class_type": "CLIPLoader",
+ "inputs": {
+ "clip_name": "qwen3vl_4b_fp8_scaled.safetensors",
+ "type": "flux3",
+ "device": "default"
+ },
+ "_meta": {
+ "title": "FLUX 3 text encoder"
+ }
+ },
+ "12": {
+ "class_type": "VAELoader",
+ "inputs": {
+ "vae_name": "flux2-vae.safetensors"
+ },
+ "_meta": {
+ "title": "FLUX VAE"
+ }
+ },
+ "13": {
+ "class_type": "CLIPTextEncode",
+ "inputs": {
+ "clip": [
+ "11",
+ 0
+ ],
+ "text": [
+ "23",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Expanded FLUX editing instruction"
+ }
+ },
+ "14": {
+ "class_type": "ConditioningZeroOut",
+ "inputs": {
+ "conditioning": [
+ "13",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Empty negative"
+ }
+ },
+ "15": {
+ "class_type": "ReferenceMultiLatent",
+ "inputs": {
+ "positive": [
+ "13",
+ 0
+ ],
+ "negative": [
+ "14",
+ 0
+ ],
+ "vae": [
+ "12",
+ 0
+ ],
+ "resolution": "keep resolution",
+ "images.image0": [
+ "5",
+ 0
+ ],
+ "images.image1": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Both raw image references reach FLUX"
+ }
+ },
+ "19": {
+ "class_type": "KSampler",
+ "inputs": {
+ "model": [
+ "10",
+ 0
+ ],
+ "seed": 0,
+ "steps": 16,
+ "cfg": 1.0,
+ "sampler_name": "euler",
+ "scheduler": "simple",
+ "denoise": 1.0,
+ "positive": [
+ "15",
+ 0
+ ],
+ "negative": [
+ "15",
+ 1
+ ],
+ "latent_image": [
+ "15",
+ 2
+ ]
+ },
+ "_meta": {
+ "title": "Prepare pose · FLUX 3"
+ }
+ },
+ "20": {
+ "class_type": "VAEDecode",
+ "inputs": {
+ "samples": [
+ "19",
+ 0
+ ],
+ "vae": [
+ "12",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Prepared first frame"
+ }
+ },
+ "21": {
+ "class_type": "SaveImage",
+ "inputs": {
+ "images": [
+ "20",
+ 0
+ ],
+ "filename_prefix": "openjutsu_picture/flux3/prepared_frame"
+ },
+ "_meta": {
+ "title": "3 · Save prepared first frame"
+ }
+ },
+ "22": {
+ "class_type": "PreviewImage",
+ "inputs": {
+ "images": [
+ "3",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Raw first frame — compare composition"
+ }
+ },
+ "23": {
+ "class_type": "TextGenerate",
+ "inputs": {
+ "clip": [
+ "9",
+ 0
+ ],
+ "image": [
+ "8",
+ 0
+ ],
+ "prompt": [
+ "6",
+ 0
+ ],
+ "system_prompt": [
+ "25",
+ 0
+ ],
+ "max_length": 700,
+ "sampling_mode": "off",
+ "thinking": false,
+ "use_default_template": true,
+ "mtp": "off"
+ },
+ "_meta": {
+ "title": "Describe the raw frame's pose for the edit"
+ }
+ },
+ "24": {
+ "class_type": "PreviewAny",
+ "inputs": {
+ "source": [
+ "23",
+ 0
+ ]
+ },
+ "_meta": {
+ "title": "Expanded editing instruction"
+ }
+ },
+ "25": {
+ "class_type": "PrimitiveStringMultiline",
+ "inputs": {
+ "value": "You are an image-editing prompt upsampler. The attached images are ordered: image 1 is the character image and image 2 is the raw first frame from a video. Expand the user's request into one precise editing instruction. Keep every requested constraint. Use gender-neutral wording such as 'the character'; do not add a fixed gender.\n\nImage 1 supplies the identity, hairstyle, complete outfit, background and lighting. Image 2 supplies only the starting body pose, head orientation, arm positions, hand positions, leg positions, camera perspective, relative character size, position within the frame and body cut. Describe those pose and framing changes concretely from image 2. Replace the original pose of image 1 instead of retaining it. Keep the character and the background of image 1; do not copy the identity, hairstyle, clothes, props, setting or colors of image 2, and do not add extra objects. Describe the intended still image, not later video movements. Output only one English editing instruction, without Markdown or explanation."
+ },
+ "_meta": {
+ "title": "Image-edit prompt expansion rules"
+ }
+ }
+}