Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(webv2): randomize a fixed seed when an external video remix applies

Lincoln Steinb4718920878f
diff --git a/docs/src/content/docs/development/Guides/video-recall-api.mdx b/docs/src/content/docs/development/Guides/video-recall-api.mdx
index 328629c41d..6bf19e5095 100644
--- a/docs/src/content/docs/development/Guides/video-recall-api.mdx
+++ b/docs/src/content/docs/development/Guides/video-recall-api.mdx
@@ -51,7 +51,7 @@ gallery or a video file, which is uploaded into the gallery first.
| Query parameter | Default | Meaning |
|---|---|---|
-| `mode` | `recall` | `recall` sends every field; `remix` never sends `seed`, so the panel's own seed stands |
+| `mode` | `recall` | `recall` sends every field. `remix` never sends `seed`, and when the remix applies, a panel whose seed mode is *fixed* switches it to *random* so the next generation is a new take; *increment* and *decrement* are left as they are. |
| `strict` | `false` | `false` changes only the fields you send. `true` treats the body as a whole generation record: LoRAs, media and a MiniMax H3 hybrid base you do not send are cleared, as the gallery's *Recall All* does with a video's own metadata. |
Fields naming a model or medium that cannot be used are dropped and listed in the
@@ -216,7 +216,7 @@ curl -X POST http://localhost:9090/api/v1/recall/video/default \
"first_frame_image": {"image_name": "0b6f…png"}
}'
-# Remix: the seed is never sent
+# Remix: the seed is never sent, and a fixed seed mode becomes random
curl -X POST "http://localhost:9090/api/v1/recall/video/default?mode=remix" \
-H "Content-Type: application/json" \
-d '{"positive_prompt": "a heron lands on a misty lake", "model": "Wan 2.2 I2V A14B"}'
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
index 856bc36ffa..011ae384d2 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/index.ts
@@ -19,6 +19,7 @@ export { executeImageRecall, getCurrentGenerateValues } from './executeImageReca
export {
appendReferenceVideo,
applyVideoRecallMetadata,
+ getCurrentVideoValues,
placeInitialVideo,
type PlaceableVideo,
} from './executeVideoRecall';
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
index 4b5d16c58e..cd1c9b8fa6 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.test.ts
@@ -203,6 +203,37 @@ describe('createVideoRecallRuntime', () => {
runtime.dispose();
});
+ it.each([
+ ['fixed', 'random'],
+ ['random', 'random'],
+ ['increment', 'increment'],
+ ['decrement', 'decrement'],
+ ])('a remix turns a %s seed into %s', async (before, after) => {
+ const { runtime, socket, store, projectId, videoValues } = setup();
+ store.commands.widgets.patchValues('video', { seed: 42, seedMode: before }, projectId);
+
+ socket.emit(parametersEvent({ positive_prompt: 'a heron' }, { mode: 'remix' }));
+ await flush();
+
+ expect(videoValues()).toMatchObject({ positivePrompt: 'a heron', seed: 42, seedMode: after });
+
+ runtime.dispose();
+ });
+
+ it('keeps a fixed seed for a recall, and for a remix that applied nothing', async () => {
+ const { runtime, socket, store, projectId, videoValues } = setup();
+ store.commands.widgets.patchValues('video', { seedMode: 'fixed' }, projectId);
+
+ socket.emit(parametersEvent({ positive_prompt: 'a heron' }));
+ await flush();
+ socket.emit(parametersEvent({ model: { key: 'not-installed' } }, { mode: 'remix' }));
+ await flush();
+
+ expect(videoValues().seedMode).toBe('fixed');
+
+ runtime.dispose();
+ });
+
it('applies to the project it arrived for, without pulling a different project to the front', async () => {
const { videoShown, projectId, runtime, socket, store, videoValues } = setup();
let releaseModels: () => void = () => {};
diff --git a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.ts b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.ts
index 72214d2e57..2209ec8f40 100644
--- a/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.ts
+++ b/invokeai/frontend/webv2/src/workbench/image-actions/videoRecallRuntime.ts
@@ -12,7 +12,7 @@ import type { PendingRecallEvent, RecallRevealContext, RecallRuntime } from './r
// Through the package entry, not the modules themselves: the gallery's actions share these modules, and importing
// them from this lazy runtime directly would split them out of the image-actions chunk into one more request on
// every editor route.
-import { appendReferenceVideo, applyVideoRecallMetadata, placeInitialVideo } from './index';
+import { appendReferenceVideo, applyVideoRecallMetadata, getCurrentVideoValues, placeInitialVideo } from './index';
import { bringRecallWidgetToFront, createRecallEventRuntime } from './recallEventRuntime';
/** The `video` of a `video_recall_requested` event: a gallery video, as the backend describes it. */
@@ -135,6 +135,12 @@ export const createVideoRecallRuntime = ({
projectId,
requireGenerationMode: false,
});
+
+ // A remix asks for a new take, which a fixed seed would not give; increment and decrement already vary it.
+ const current = applied && event.mode === 'remix' ? readVideoValues() : null;
+ if (current && getCurrentVideoValues({ models, videoValues: current }).seedMode === 'fixed') {
+ commands.widgets.patchValues('video', { seedMode: 'random' }, projectId);
+ }
} else if (event.action === 'initial_video') {
const placement = placeInitialVideo({ models, video: toPlaceableVideo(event.video), videoValues });