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.

fix(generate): default missing batch count

joshistoast3660e0f35761
diff --git a/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts b/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
index 2d46a7939d..a344700a6a 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/settings.test.ts
@@ -70,6 +70,13 @@ describe('normalizeGenerateSettings', () => {
expect(normalizeGenerateSettings(null)).toBeNull();
});
+ it('defaults an omitted batch count to one', () => {
+ const { batchCount, ...storedValues } = legacyStoredValues;
+
+ expect(batchCount).toBe(2);
+ expect(normalizeGenerateSettings(storedValues)?.batchCount).toBe(1);
+ });
+
it('drops malformed values for the newer fields back to defaults', () => {
const normalized = normalizeGenerateSettings({
...legacyStoredValues,
diff --git a/invokeai/frontend/webv2/src/workbench/generation/settings.ts b/invokeai/frontend/webv2/src/workbench/generation/settings.ts
index 087025be8d..afce86f3c9 100644
--- a/invokeai/frontend/webv2/src/workbench/generation/settings.ts
+++ b/invokeai/frontend/webv2/src/workbench/generation/settings.ts
@@ -11,6 +11,7 @@ import type {
VaePrecision,
} from './types';
+import { sanitizeBatchCount } from './batch';
import { isVaeCompatibleWithGenerateModel } from './componentCompatibility';
/** Preset ratios, with the preset to switch to when dimensions are swapped. */
@@ -335,7 +336,7 @@ export const normalizeGenerateSettings = (values: unknown): GenerateSettings | n
typeof values.negativePrompt === 'string' &&
typeof values.scheduler === 'string' &&
typeof values.shouldRandomizeSeed === 'boolean' &&
- ['batchCount', 'width', 'height', 'steps', 'cfgScale', 'cfgRescaleMultiplier', 'seed'].every((key) =>
+ ['width', 'height', 'steps', 'cfgScale', 'cfgRescaleMultiplier', 'seed'].every((key) =>
hasFiniteNumber(values, key)
);
@@ -355,7 +356,7 @@ export const normalizeGenerateSettings = (values: unknown): GenerateSettings | n
: height > 0
? width / height
: 1,
- batchCount: values.batchCount as number,
+ batchCount: sanitizeBatchCount(values.batchCount),
cfgRescaleMultiplier: values.cfgRescaleMultiplier as number,
cfgScale: values.cfgScale as number,
clipSkip: hasFiniteNumber(values, 'clipSkip') ? (values.clipSkip as number) : 0,