From e7eee2982519d6c26e828a7755d1cc5e1f758bd7 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:52:28 +1100 Subject: [PATCH] feat(ui): add transformation to width/height parameter schemas to round to multiple of 8 This allows image dimensions that are not multiples of 8 to still be recalled with best effort. --- .../src/features/parameters/types/parameterSchemas.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts index 8d46add8c8..0fc912a6d6 100644 --- a/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts +++ b/invokeai/frontend/web/src/features/parameters/types/parameterSchemas.ts @@ -1,8 +1,6 @@ import { NUMPY_RAND_MAX } from 'app/constants'; -import { - zModelIdentifierWithBase, - zSchedulerField, -} from 'features/nodes/types/common'; +import { roundToMultiple } from 'common/util/roundDownToMultiple'; +import { zModelIdentifierWithBase, zSchedulerField } from 'features/nodes/types/common'; import { z } from 'zod'; /** @@ -79,7 +77,10 @@ export const isParameterSeed = (val: unknown): val is ParameterSeed => zParamete // #endregion // #region Width -export const zParameterWidth = z.number().multipleOf(8).min(64); +export const zParameterWidth = z + .number() + .min(64) + .transform((val) => roundToMultiple(val, 8)); export type ParameterWidth = z.infer; export const isParameterWidth = (val: unknown): val is ParameterWidth => zParameterWidth.safeParse(val).success; // #endregion