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.
This commit is contained in:
psychedelicious 2024-02-26 11:52:28 +11:00
parent 04545e792c
commit 7326c78ab5

View File

@ -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<typeof zParameterWidth>;
export const isParameterWidth = (val: unknown): val is ParameterWidth => zParameterWidth.safeParse(val).success;
// #endregion