From d0bfb11e4c2bc1f0809c4cf413a96ec569510a92 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Sun, 24 May 2026 14:06:26 +0000 Subject: [PATCH] Studio: validate vision_image_size in YAML/model-default loader mapBackendModelConfigToTrainingPatch now mirrors the backend validator at studio/backend/models/training.py:169 by dropping any value that is not an integer in [256, 2048]. Pre-fix, an imported YAML like vision_image_size: 4096 or 640.5 would land in the store and the UI would happily display it, only to fail when Start Training posted to the backend. With this guard the store never holds a value the backend would reject. --- .../src/features/training/lib/model-defaults.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/studio/frontend/src/features/training/lib/model-defaults.ts b/studio/frontend/src/features/training/lib/model-defaults.ts index 00008f026a..c567c280f2 100644 --- a/studio/frontend/src/features/training/lib/model-defaults.ts +++ b/studio/frontend/src/features/training/lib/model-defaults.ts @@ -131,10 +131,18 @@ export function mapBackendModelConfigToTrainingPatch( if (randomSeed !== undefined) patch.randomSeed = randomSeed; if (Object.hasOwn(training ?? {}, "vision_image_size")) { - const visionImageSize = training?.vision_image_size == null - ? null - : toNumber(training.vision_image_size); - if (visionImageSize !== undefined) patch.visionImageSize = visionImageSize; + const raw = training?.vision_image_size; + if (raw == null) { + patch.visionImageSize = null; + } else { + // Mirror the backend validator at studio/backend/models/training.py:169. + // Anything not an integer in [256, 2048] is dropped so the store and UI + // never show a value the backend would reject. + const n = toNumber(raw); + if (n !== undefined && Number.isInteger(n) && n >= 256 && n <= 2048) { + patch.visionImageSize = n; + } + } } const packing = toBoolean(training?.packing);