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.

Merge origin/main into fix/audio-reference-default-conditioning

Lincoln Stein437126049ec2
diff --cc invokeai/frontend/webv2/public/locales/en.json
index 4d0cc739d4,b8b7b87a6f..9faafcbd3a
--- a/invokeai/frontend/webv2/public/locales/en.json
+++ b/invokeai/frontend/webv2/public/locales/en.json
@@@ -3571,13 -3571,14 +3571,14 @@@
"referenceExtendCapFullDescription": "All 3 video reference slots are in use, so there is no room for the continuity reference this clip needs. Remove a video reference, then drop the clip again.",
"referenceExtendHelp": "The generated video is appended to this clip at its End Frame. A linked video reference samples up to the last ~5 seconds before that cutpoint for continuity — never more than the generated clip's own length, since the model discards the overrun at the seam. Its trim re-derives whenever the cutpoints or the frame count change.",
"referenceImageCapRace": "All {{max}} image reference slots filled while this one was loading, so it was not added.",
+ "referenceImageCost": "{{width}}×{{height}} · {{rows}} rows per step",
- "referenceVideoCapRace": "All {{max}} video reference slots filled while this one was loading, so it was not added.",
+ "referenceVideoCapRace": "All {{max}} video or audio reference slots filled while this one was loading, so it was not added.",
"referenceFromInitialVideo": "Initial video",
"references": "References",
- "referencesHelp": "Up to 3 videos and 9 images condition the generation, in order — reordering references changes the result. A video reference can contribute its image track, its soundtrack, or both. An uploaded audio file becomes a waveform clip that fills a video slot and conditions on its soundtrack.",
- "referencesHelp": "Up to 3 videos and 9 images condition the generation, in order — reordering references changes the result. A video reference can contribute its image track, its soundtrack, or both. Every reference adds rows to each denoising step, so the first image reference starts at maximum detail and later ones match the generation size.",
++ "referencesHelp": "Up to 3 videos and 9 images condition the generation, in order — reordering references changes the result. A video reference can contribute its image track, its soundtrack, or both. An uploaded audio file becomes a waveform clip that fills a video slot and conditions on its soundtrack. Every reference adds rows to each denoising step, so the first image reference starts at maximum detail and later ones match the generation size.",
"removeReference": "Remove reference",
"staleReferences": "References are set but the selected model cannot use them.",
- "uploadVideoReference": "Upload video"
+ "uploadVideoReference": "Upload video or audio"
}
},
"workflowLibrary": {
diff --cc invokeai/frontend/webv2/src/features/video/core/settings.test.ts
index ec322a1cc2,8225441a90..70b35d9194
--- a/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.test.ts
@@@ -14,7 -14,7 +14,8 @@@ import
cloneVideoWidgetValues,
createVideoSourceClip,
deriveReferenceExtendClip,
+ getDefaultReferenceConditioning,
+ getDefaultReferenceImageDetail,
isVideoSettings,
isVideoSourceClip,
normalizeVideoSettings,
@@@ -263,23 -263,29 +264,46 @@@ describe('createVideoSourceClip', () =
});
});
+describe('getDefaultReferenceConditioning', () => {
+ it('starts a wrapped audio upload on its soundtrack alone', () => {
+ expect(getDefaultReferenceConditioning({ media_origin: 'audio_upload' })).toBe('audio');
+ });
+
+ it('keeps video + audio for ordinary videos', () => {
+ expect(getDefaultReferenceConditioning({ generation_mode: 'minimax_h3_ref2v' })).toBe('video_audio');
+ expect(getDefaultReferenceConditioning({ media_origin: 'something_else' })).toBe('video_audio');
+ });
+
+ it('keeps video + audio when there is no metadata to read', () => {
+ expect(getDefaultReferenceConditioning(null)).toBe('video_audio');
+ expect(getDefaultReferenceConditioning(undefined)).toBe('video_audio');
+ expect(getDefaultReferenceConditioning({})).toBe('video_audio');
+ });
+});
+
+ describe('getDefaultReferenceImageDetail', () => {
+ const imageReference = {
+ detail: 'max',
+ image: { height: 1080, image_name: 'ref.png', width: 1920 },
+ kind: 'image',
+ } as const;
+ const videoReference = {
+ clip: SOURCE_VIDEO,
+ conditioning: 'video_audio',
+ kind: 'video',
+ } as const;
+
+ it('starts the first image reference at maximum detail', () => {
+ expect(getDefaultReferenceImageDetail([])).toBe('max');
+ expect(getDefaultReferenceImageDetail([videoReference])).toBe('max');
+ });
+
+ it('matches the generation size once an image reference is placed', () => {
+ expect(getDefaultReferenceImageDetail([imageReference])).toBe('match');
+ expect(getDefaultReferenceImageDetail([videoReference, imageReference])).toBe('match');
+ });
+ });
+
describe('clearDeletedVideoMedia', () => {
const withMedia = createSettings({
firstFrameImage: FIRST_FRAME,
diff --cc invokeai/frontend/webv2/src/features/video/core/settings.ts
index e23b31b37f,97ad1ebdec..67ff8bd225
--- a/invokeai/frontend/webv2/src/features/video/core/settings.ts
+++ b/invokeai/frontend/webv2/src/features/video/core/settings.ts
@@@ -18,7 -18,7 +18,8 @@@ import type
MiniMaxH3TargetResolution,
VideoAspectRatioId,
VideoGenerationMode,
+ VideoReferenceConditioning,
+ VideoReferenceImageDetail,
VideoReferenceItem,
VideoSettings,
VideoSourceClip,
@@@ -538,20 -538,22 +539,36 @@@ export const createVideoSourceClip = (i
};
};
+/**
+ * The conditioning a video reference starts on when it is added from the gallery or an
+ * upload.
+ *
+ * Audio uploads are stored as videos: the server wraps an uploaded audio file into a
+ * rendered-waveform clip at ingest and stamps `media_origin: audio_upload` on it. Those
+ * frames are a picture of the sound rather than footage anyone means to condition on, so
+ * such a reference defaults to its soundtrack alone. Everything else keeps video + audio.
+ * This is only the starting value — the card's selector still offers all three.
+ */
+export const getDefaultReferenceConditioning = (
+ metadata: Record<string, unknown> | null | undefined
+): VideoReferenceConditioning => (metadata?.media_origin === 'audio_upload' ? 'audio' : 'video_audio');
+
+ /**
+ * The detail a newly added image reference starts on.
+ *
+ * The FIRST image reference keeps upstream's rule, a 2048px short edge: it is usually the
+ * subject the generation is about, and that is where the extra detail earns its cost.
+ * Later ones match the generation size instead. Reference rows are re-attended at every
+ * denoising step and attention is quadratic in the sequence, so a second and third 2048px
+ * reference are what turn a modest surcharge into a doubling — while the marginal value of
+ * conditioning a supporting reference at seven times the output's pixel density is small.
+ *
+ * Only the starting value: every card's selector still offers both, and the card shows the
+ * size and row count each choice produces.
+ */
+ export const getDefaultReferenceImageDetail = (references: VideoReferenceItem[]): VideoReferenceImageDetail =>
+ references.some((entry) => entry.kind === 'image') ? 'match' : 'max';
+
/** The minimum frames a trim must keep — video_concat's crossfade consumes a 2-frame tail. */
export const MIN_VIDEO_TRIM_FRAMES = 2;
diff --cc invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
index 99f0dab6c1,ce54bbb59f..3f0f03b12a
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
@@@ -10,13 -10,14 +10,15 @@@ import type { ChangeEvent } from 'react
import { Badge, Box, createListCollection, HStack, Icon, Image, Input, Spinner, Stack, Text } from '@chakra-ui/react';
import { useDndContext, useDndMonitor, useDroppable } from '@dnd-kit/core';
-import { galleryItems, galleryTransfers, toGalleryItemKey } from '@features/gallery';
+import { galleryItems, galleryTransfers, galleryVideos, toGalleryItemKey } from '@features/gallery';
import { GalleryPickerPopover } from '@features/gallery/picker';
import { galleryImageUrls, galleryVideoUrls, isGalleryItemDragData } from '@features/gallery/utility';
+ import { resolveMiniMaxH3ReferenceImage } from '@features/video/core/dimensions';
import {
createVideoSourceClip,
DEFAULT_REFERENCE_SAMPLE_FRAMES,
+ getDefaultReferenceConditioning,
+ getDefaultReferenceImageDetail,
resizeReferenceSampleWindow,
slideReferenceSampleWindow,
} from '@features/video/core/settings';