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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
feat(webv2): drive the Upscale widget from an architecture table, and add FLUX.1
Alexander Eichhorna9b3587f9299
diff --git a/invokeai/frontend/webv2/public/locales/en.json b/invokeai/frontend/webv2/public/locales/en.jsonindex ff6ce62634..7b4d69954b 100644--- a/invokeai/frontend/webv2/public/locales/en.json+++ b/invokeai/frontend/webv2/public/locales/en.json@@ -982,6 +982,18 @@"Structure controls how closely the output image will keep to the layout of the original. Low structure allows major changes, while high structure strictly maintains the original composition and layout."]},+ "clipEmbed": {+ "heading": "CLIP Embed",+ "paragraphs": [+ "FLUX.1 pairs its T5 encoder with a CLIP text encoder. A bare FLUX checkpoint does not carry one, so it must be chosen explicitly."+ ]+ },+ "t5Encoder": {+ "heading": "T5 Encoder",+ "paragraphs": [+ "FLUX.1 reads your prompt with a T5 text encoder. Most FLUX transformers ship as a bare checkpoint and cannot supply one, so it has to be selected here."+ ]+ },"tileControlNet": {"heading": "ControlNet","paragraphs": [@@ -2554,7 +2566,7 @@"lorasRemoved": "Removed {{count}} incompatible LoRA model(s).","loraWeight": "{{name}} weight","mainModel": "Main model",- "mainModelRequired": "Select an SD1.5 or SDXL main model.",+ "mainModelRequired": "Select a supported main model.","negativePrompt": "Negative prompt","negativePromptAdd": "Negative prompt…","negativePromptHide": "Turn off negative prompt",@@ -2585,7 +2597,7 @@"scheduler": "Scheduler","seed": "Seed","selectLora": "Select a compatible LoRA…",- "selectMainModel": "Select an SD1.5 or SDXL model…",+ "selectMainModel": "Select a supported model…","selectSpandrelModel": "Select a Spandrel model…","selectTileControlNet": "Select a Tile or Union ControlNet…","settingsAdjusted": "Adjusted incompatible settings",@@ -2598,6 +2610,14 @@"steps": "Steps","structure": "Structure","structureHelp": "Higher values preserve the source composition more strictly.",+ "clipEmbed": "CLIP Embed",+ "clipEmbedRequired": "This model needs a CLIP Embed model selected.",+ "selectClipEmbed": "Select a CLIP Embed model",+ "selectVae": "Select a VAE",+ "selectT5Encoder": "Select a T5 encoder",+ "t5Encoder": "T5 Encoder",+ "t5EncoderRequired": "This model needs a T5 encoder selected.",+ "vaeRequired": "This model needs a VAE selected.","tileControlNet": "Tile ControlNet","tileControlNetHelp": "Guides detail generation with the source image and must match the main model architecture.","tileControlNetRequired": "Select a compatible Tile or Union ControlNet.",diff --git a/invokeai/frontend/webv2/src/features/upscale/core/architectures.ts b/invokeai/frontend/webv2/src/features/upscale/core/architectures.tsnew file mode 100644index 0000000000..9ad75d6bfd--- /dev/null+++ b/invokeai/frontend/webv2/src/features/upscale/core/architectures.ts@@ -0,0 +1,95 @@+import type { MainModelConfig } from '@features/generation/contracts';++/**+ * Which main-model architectures the Upscale widget can drive, and what each one needs.+ *+ * This is the single source of truth: the graph compiler keys its builders off the same record+ * (`UPSCALE_PATH_BUILDERS`, enforced by `satisfies`), validation reads the requirements from here,+ * and the widget shows a control only where the architecture has something for it to steer. Adding+ * an architecture should mean adding one entry and one builder, not hunting for a base string.+ */+export interface UpscaleArchitecture {+ /**+ * A tile ControlNet anchors the second pass to the upscaled frame. Where one exists the widget+ * requires it and the Structure slider drives its weights; where it does not, Structure has+ * nothing to scale and is hidden rather than left inert.+ */+ readonly usesTileControlNet: boolean;+ /**+ * Whether the pipeline's parts must be picked separately. FLUX transformers ship as bare+ * checkpoints far more often than not, and `flux_model_loader` refuses those without an explicit+ * T5 encoder, CLIP Embed *and* VAE -- only a complete SDNQ pipeline install can supply its own.+ */+ readonly needsExplicitComponents: boolean;+ /**+ * The size granularity the architecture's denoise node demands. Spandrel's autoscale rounds to a+ * multiple of 8, which `flux_denoise` (multiple_of=16) rejects outright — after the upscale has+ * already run. Where this is coarser than 8 the compiler resizes the frame down to it and passes+ * the size as a literal, so the graph cannot be built with a size the backend will refuse.+ */+ readonly denoiseGrid: number;+ /** Guidance-distilled architectures ignore a negative prompt; showing one invites a silent no-op. */+ readonly usesNegativePrompt: boolean;+ /** Shown in validation messages, so a user reads "FLUX.1" rather than "flux". */+ readonly label: string;+}++export const UPSCALE_ARCHITECTURES = {+ 'sd-1': {+ denoiseGrid: 8,+ label: 'SD1.5',+ needsExplicitComponents: false,+ usesNegativePrompt: true,+ usesTileControlNet: true,+ },+ sdxl: {+ denoiseGrid: 8,+ label: 'SDXL',+ needsExplicitComponents: false,+ usesNegativePrompt: true,+ usesTileControlNet: true,+ },+ flux: {+ denoiseGrid: 16,+ label: 'FLUX.1',+ needsExplicitComponents: true,+ usesNegativePrompt: false,+ usesTileControlNet: false,+ },+} as const satisfies Record<string, UpscaleArchitecture>;++export type UpscaleBase = keyof typeof UPSCALE_ARCHITECTURES;++export const isUpscaleBase = (base: unknown): base is UpscaleBase =>+ typeof base === 'string' && base in UPSCALE_ARCHITECTURES;++export const upscaleArchitectureFor = (model: MainModelConfig | null): UpscaleArchitecture | null =>+ model && isUpscaleBase(model.base) ? UPSCALE_ARCHITECTURES[model.base] : null;++/** "SD1.5, SDXL or FLUX.1" — built from the table so the copy cannot go stale. */+export const supportedUpscaleArchitectureLabels = (): string => {+ const labels = Object.values(UPSCALE_ARCHITECTURES).map((architecture) => architecture.label);+ const last = labels[labels.length - 1];++ return labels.length > 1 ? `${labels.slice(0, -1).join(', ')} or ${last}` : (last ?? '');+};++/**+ * A self-contained SDNQ pipeline carries its own transformer, CLIP, T5 and VAE, so asking the user+ * to pick them would be busywork. Every other FLUX format must have them chosen explicitly.+ *+ * The backend is stricter still -- it also checks the pipeline actually contains those submodels+ * (`is_self_contained_sdnq_flux1_pipeline`), which the model list does not expose. An SDNQ install+ * missing a submodel therefore passes here and is refused by the loader with a precise message,+ * which is the right way round.+ */+export const needsExplicitComponents = (model: MainModelConfig | null): boolean =>+ (upscaleArchitectureFor(model)?.needsExplicitComponents ?? false) && model?.format !== 'sdnq_quantized';++/** What Spandrel's autoscale produces: the scaled dimension floored to a multiple of 8. */+export const spandrelAutoscaleDimension = (dimension: number, scale: number): number =>+ Math.floor(Math.trunc(dimension * scale) / 8) * 8;++/** The same dimension floored to what the architecture's denoise node will accept. */+export const upscaleDenoiseDimension = (dimension: number, scale: number, grid: number): number =>+ Math.max(grid, Math.floor(spandrelAutoscaleDimension(dimension, scale) / grid) * grid);diff --git a/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts b/invokeai/frontend/webv2/src/features/upscale/core/graph.test.tsindex 70c2694fe9..d2228ee3ac 100644--- a/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts+++ b/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts@@ -124,3 +124,82 @@ describe('compileUpscaleGraph', () => {expect(graph.nodes.core_metadata?.rand_device).toBe('xpu');});});++const createFluxValues = (options: { withEncoders?: boolean } = {}) => {+ const { withEncoders = true } = options;+ const models = [+ model('main', 'main', 'flux'),+ model('spandrel', 'spandrel_image_to_image', 'any'),+ model('lora', 'lora', 'flux'),+ model('fluxvae', 'vae', 'flux'),+ ...(withEncoders ? [model('t5', 't5_encoder', 'any'), model('clip', 'clip_embed', 'any')] : []),+ ];+ const values = createDefaultUpscaleWidgetValues(models);++ return {+ ...values,+ inputImage: { height: 101, image_name: 'input.png', width: 203 },+ loras: [{ isEnabled: true, model: models[2] as GenerateLora['model'], weight: 0.7 }],+ positivePrompt: 'detail',+ };+};++describe('compileUpscaleGraph for FLUX.1', () => {+ it('drives the second pass with flux nodes and tiles both VAE ends', () => {+ const { edges, nodes } = compileUpscaleGraph(createFluxValues(), 'gallery', { useCpuNoise: true }).backendGraph;++ expect(nodes.model_loader).toMatchObject({ type: 'flux_model_loader' });+ expect(nodes.model_loader?.t5_encoder_model).toMatchObject({ key: 't5' });+ expect(nodes.model_loader?.clip_embed_model).toMatchObject({ key: 'clip' });+ expect(nodes.i2l).toMatchObject({ tile_size: 1024, tiled: true, type: 'flux_vae_encode' });+ expect(nodes.upscale_output).toMatchObject({ tile_size: 1024, tiled: true, type: 'flux_vae_decode' });+ expect(nodes.denoise_latents).toMatchObject({ guidance: 2, num_steps: 30, type: 'flux_denoise' });+ expect(nodes.denoise_latents?.denoising_start).toBeCloseTo(0.499);+ expect(hasEdge(edges, 'i2l', 'latents', 'denoise_latents', 'latents')).toBe(true);+ expect(hasEdge(edges, 'pos_cond_collect', 'collection', 'denoise_latents', 'positive_text_conditioning')).toBe(+ true+ );+ expect(Object.values(nodes).some((node) => node.type.includes('lora_collection_loader'))).toBe(true);+ });++ it('fits the frame to the grid flux_denoise accepts, instead of whatever Spandrel rounded to', () => {+ // Spandrel's autoscale floors to a multiple of 8; `flux_denoise` declares multiple_of=16 and+ // raises on anything else -- after the upscale has already been paid for. The 203x101 fixture+ // at 4x is exactly that case: Spandrel gives 808x400, and 808 is not a multiple of 16.+ const { edges, nodes } = compileUpscaleGraph(createFluxValues(), 'gallery', { useCpuNoise: true }).backendGraph;++ expect(nodes.fit_to_grid).toMatchObject({ height: 400, type: 'img_resize', width: 800 });+ expect(nodes.denoise_latents).toMatchObject({ height: 400, width: 800 });+ expect(hasEdge(edges, 'unsharp_2', 'image', 'fit_to_grid', 'image')).toBe(true);+ expect(hasEdge(edges, 'fit_to_grid', 'image', 'i2l', 'image')).toBe(true);+ expect(Number(nodes.denoise_latents?.width) % 16).toBe(0);+ expect(Number(nodes.denoise_latents?.height) % 16).toBe(0);+ });++ it('leaves the SD path on the size Spandrel produced, which is already the grid it needs', () => {+ const { nodes } = compileUpscaleGraph(createValues('sd-1'), 'gallery', { useCpuNoise: true }).backendGraph;++ expect(nodes.fit_to_grid).toBeUndefined();+ });++ it('wires no ControlNet, because FLUX.1 has no tile model to anchor with', () => {+ const { nodes } = compileUpscaleGraph(createFluxValues(), 'gallery', { useCpuNoise: true }).backendGraph;++ expect(Object.values(nodes).some((node) => node.type === 'controlnet')).toBe(false);+ expect(nodes.controlnet_collector).toBeUndefined();+ });++ it('names the pass without claiming a multi-diffusion that does not run', () => {+ const flux = compileUpscaleGraph(createFluxValues(), 'gallery', { useCpuNoise: true });+ const sd = compileUpscaleGraph(createValues('sd-1'), 'gallery', { useCpuNoise: true });++ expect(flux.graph.label).not.toContain('multi-diffusion');+ expect(sd.graph.label).toContain('multi-diffusion');+ });++ it('refuses to compile without the text encoders the loader demands', () => {+ expect(() =>+ compileUpscaleGraph(createFluxValues({ withEncoders: false }), 'gallery', { useCpuNoise: true })+ ).toThrow(/T5 encoder/);+ });+});diff --git a/invokeai/frontend/webv2/src/features/upscale/core/graph.ts b/invokeai/frontend/webv2/src/features/upscale/core/graph.tsindex 7aa1bb8c25..bfb2cac48f 100644--- a/invokeai/frontend/webv2/src/features/upscale/core/graph.ts+++ b/invokeai/frontend/webv2/src/features/upscale/core/graph.ts@@ -2,6 +2,7 @@ import type {BackendGraphContract,BackendInvocationContract,GenerationProjectSettings,+ MainModelConfig,ResultDestination,} from '@features/generation/contracts';@@ -9,14 +10,17 @@ import {addLoraCollectionLoader,addEdge,addNode,+ addTransformerLoraCollectionLoader,getActiveCompatibleLoras,toGraphContract,toModelIdentifier,} from '@features/generation/graph';import { coerceSchedulerForGraph } from '@features/generation/settings';+import type { UpscaleBase } from './architectures';import type { CompiledUpscaleGraph, UpscaleWidgetValues } from './types';+import { upscaleArchitectureFor, upscaleDenoiseDimension } from './architectures';import { getUpscaleValidationReasons } from './settings';export const getUpscaleDenoisingStart = (creativity: number): number => ((creativity * -1 + 10) * 4.99) / 100;@@ -51,8 +55,15 @@ const addUpscaleMetadata = (// Pass only loras; fabricating unrelated GenerateSettings fields would obscure the helper's actual dependency.const activeLoras = getActiveCompatibleLoras({ loras: settings.loras }, settings.model);+ const architecture = upscaleArchitectureFor(settings.model);+ // FLUX calls this guidance, not CFG, and its encoders have to be recalled with the rest.+ const guidanceField = architecture?.usesNegativePrompt+ ? { cfg_scale: settings.cfgScale }+ : { guidance: settings.cfgScale };const metadata = addNode(graph, {- cfg_scale: settings.cfgScale,+ ...guidanceField,+ ...(settings.t5EncoderModel ? { t5_encoder: toModelIdentifier(settings.t5EncoderModel) } : {}),+ ...(settings.clipEmbedModel ? { clip_embed_model: toModelIdentifier(settings.clipEmbedModel) } : {}),creativity: settings.creativity,id: 'core_metadata',loras: activeLoras.map((lora) => ({ model: toModelIdentifier(lora.model), weight: lora.weight })),@@ -75,44 +86,62 @@ const addUpscaleMetadata = (});addEdge(graph, graph.nodes.positive_prompt, 'value', metadata, 'positive_prompt');- addEdge(graph, graph.nodes.negative_prompt, 'value', metadata, 'negative_prompt');+ if (architecture?.usesNegativePrompt) {+ addEdge(graph, graph.nodes.negative_prompt, 'value', metadata, 'negative_prompt');+ }addEdge(graph, graph.nodes.seed, 'value', metadata, 'seed');addEdge(graph, graph.nodes.spandrel_autoscale, 'width', metadata, 'width');addEdge(graph, graph.nodes.spandrel_autoscale, 'height', metadata, 'height');addEdge(graph, metadata, 'metadata', output, 'metadata');};-export const compileUpscaleGraph = (- settings: UpscaleWidgetValues,- destination: ResultDestination,- projectSettings: GenerationProjectSettings,- randDevice = projectSettings.useCpuNoise ? 'cpu' : 'cuda'-): CompiledUpscaleGraph => {- const reasons = getUpscaleValidationReasons(settings);+/**+ * Everything the second pass needs, once the frame has been enlarged.+ *+ * The prefix — prompts, seed, Spandrel, unsharp — is identical for every architecture, so it is+ * built once and handed over. What differs is the model loader, the conditioning, the VAE ends and+ * whether anything anchors the pass to the enlarged frame.+ */+interface UpscalePathContext {+ graph: BackendGraphContract;+ settings: UpscaleWidgetValues;+ model: MainModelConfig;+ destination: ResultDestination;+ projectSettings: GenerationProjectSettings;+ positivePrompt: BackendInvocationContract;+ negativePrompt: BackendInvocationContract;+ seed: BackendInvocationContract;+ unsharpMask: BackendInvocationContract;+ /** The frame size the second pass will run at, already floored to the architecture's grid. */+ denoiseSize: { width: number; height: number };+}- if (reasons.length > 0) {- throw new Error(reasons[0]);- }+interface UpscalePathResult {+ /** The node whose image is the result; the caller hangs metadata off it. */+ output: BackendInvocationContract;+ /** Names the pass in the queue, so "multi-diffusion" is not claimed where none runs. */+ title: string;+}- const { inputImage, model, tileControlnetModel, upscaleModel } = settings;+type UpscalePathBuilder = (context: UpscalePathContext) => UpscalePathResult;- if (!inputImage || !model || !tileControlnetModel || !upscaleModel) {- throw new Error('Upscale settings are incomplete.');+const buildSdUpscalePath: UpscalePathBuilder = ({+ graph,+ settings,+ model,+ destination,+ projectSettings,+ positivePrompt,+ negativePrompt,+ seed,+ unsharpMask,+}) => {+ const { tileControlnetModel } = settings;++ if (!tileControlnetModel) {+ throw new Error('Upscale needs a Tile or Union ControlNet compatible with the main model.');}- const graph: BackendGraphContract = { edges: [], id: 'upscale-graph', nodes: {} };- const positivePrompt = addNode(graph, { id: 'positive_prompt', type: 'string' });- const negativePrompt = addNode(graph, { id: 'negative_prompt', type: 'string' });- const seed = addNode(graph, { id: 'seed', type: 'integer' });- const spandrelAutoscale = addNode(graph, {- fit_to_multiple_of_8: true,- id: 'spandrel_autoscale',- image: { image_name: inputImage.image_name },- image_to_image_model: toModelIdentifier(upscaleModel),- scale: settings.scale,- type: 'spandrel_image_to_image_autoscale',- });- const unsharpMask = addNode(graph, { id: 'unsharp_2', radius: 2, strength: 60, type: 'unsharp_mask' });const noise = addNode(graph, { id: 'noise', type: 'noise', use_cpu: projectSettings.useCpuNoise });const imageToLatents = addNode(graph, {fp32: settings.vaePrecision === 'fp32',@@ -158,7 +187,6 @@ export const compileUpscaleGraph = (let clipSource: BackendInvocationContract = modelLoader;let clip2Source: BackendInvocationContract | undefined = model.base === 'sdxl' ? modelLoader : undefined;- addEdge(graph, spandrelAutoscale, 'image', unsharpMask, 'image');addEdge(graph, seed, 'value', noise, 'seed');addEdge(graph, unsharpMask, 'width', noise, 'width');addEdge(graph, unsharpMask, 'height', noise, 'height');@@ -240,11 +268,171 @@ export const compileUpscaleGraph = (addEdge(graph, controlNet1, 'control', controlNetCollector, 'item');addEdge(graph, controlNet2, 'control', controlNetCollector, 'item');addEdge(graph, controlNetCollector, 'collection', denoise, 'control');++ return { output, title: `${model.name} multi-diffusion upscale` };+};++/**+ * FLUX.1 has no tile ControlNet, so the second pass is anchored only by where it starts on the+ * schedule. Both VAE ends tile: the frame handed to `i2l` is the largest in the graph, and an+ * untiled encode of it does not fit on consumer hardware.+ */+const buildFluxUpscalePath: UpscalePathBuilder = ({+ graph,+ settings,+ model,+ destination,+ positivePrompt,+ seed,+ unsharpMask,+ denoiseSize,+}) => {+ const modelLoader = addNode(graph, {+ clip_embed_model: settings.clipEmbedModel ? toModelIdentifier(settings.clipEmbedModel) : undefined,+ id: 'model_loader',+ model: toModelIdentifier(model),+ t5_encoder_model: settings.t5EncoderModel ? toModelIdentifier(settings.t5EncoderModel) : undefined,+ type: 'flux_model_loader',+ vae_model: settings.vae ? toModelIdentifier(settings.vae) : undefined,+ });+ const activeLoras = getActiveCompatibleLoras({ loras: settings.loras }, model);+ const loraSource = activeLoras.length+ ? addTransformerLoraCollectionLoader(graph, activeLoras, 'flux_lora_collection_loader', modelLoader, [+ 'transformer',+ 'clip',+ 't5_encoder',+ ])+ : modelLoader;+ const posCond = addNode(graph, { id: 'pos_cond', type: 'flux_text_encoder' });+ const posCondCollect = addNode(graph, { id: 'pos_cond_collect', type: 'collect' });+ // Spandrel rounds to a multiple of 8; `flux_denoise` accepts only multiples of 16 and rejects the+ // rest *after* the upscale has run. Resizing here makes the frame, its latents and the denoise+ // size agree, and lets the compiler state the size rather than defer it to an edge.+ const fitToGrid = addNode(graph, {+ height: denoiseSize.height,+ id: 'fit_to_grid',+ resample_mode: 'bicubic',+ type: 'img_resize',+ width: denoiseSize.width,+ });+ const imageToLatents = addNode(graph, {+ id: 'i2l',+ tile_size: settings.tileSize,+ tiled: true,+ type: 'flux_vae_encode',+ });+ const denoise = addNode(graph, {+ denoising_end: 1,+ denoising_start: getUpscaleDenoisingStart(settings.creativity),+ guidance: settings.cfgScale,+ height: denoiseSize.height,+ id: 'denoise_latents',+ num_steps: settings.steps,+ scheduler: coerceSchedulerForGraph(model, settings.scheduler),+ type: 'flux_denoise',+ width: denoiseSize.width,+ });+ const output = addNode(graph, {+ id: 'upscale_output',+ is_intermediate: destination === 'canvas',+ tile_size: settings.tileSize,+ tiled: true,+ type: 'flux_vae_decode',+ use_cache: false,+ });++ addEdge(graph, loraSource, 'clip', posCond, 'clip');+ addEdge(graph, loraSource, 't5_encoder', posCond, 't5_encoder');+ addEdge(graph, modelLoader, 'max_seq_len', posCond, 't5_max_seq_len');+ addEdge(graph, positivePrompt, 'value', posCond, 'prompt');+ addEdge(graph, posCond, 'conditioning', posCondCollect, 'item');+ addEdge(graph, posCondCollect, 'collection', denoise, 'positive_text_conditioning');+ addEdge(graph, loraSource, 'transformer', denoise, 'transformer');+ addEdge(graph, seed, 'value', denoise, 'seed');++ addEdge(graph, unsharpMask, 'image', fitToGrid, 'image');+ addEdge(graph, fitToGrid, 'image', imageToLatents, 'image');+ addEdge(graph, modelLoader, 'vae', imageToLatents, 'vae');+ addEdge(graph, imageToLatents, 'latents', denoise, 'latents');+ addEdge(graph, denoise, 'latents', output, 'latents');+ addEdge(graph, modelLoader, 'vae', output, 'vae');++ return { output, title: `${model.name} upscale` };+};++/**+ * Keyed by the same bases as `UPSCALE_ARCHITECTURES`, and `satisfies` makes that a compile error to+ * break: declaring an architecture supported without giving it a builder will not type-check.+ */+const UPSCALE_PATH_BUILDERS = {+ flux: buildFluxUpscalePath,+ 'sd-1': buildSdUpscalePath,+ sdxl: buildSdUpscalePath,+} satisfies Record<UpscaleBase, UpscalePathBuilder>;++export const compileUpscaleGraph = (+ settings: UpscaleWidgetValues,+ destination: ResultDestination,+ projectSettings: GenerationProjectSettings,+ randDevice = projectSettings.useCpuNoise ? 'cpu' : 'cuda'+): CompiledUpscaleGraph => {+ const reasons = getUpscaleValidationReasons(settings);++ if (reasons.length > 0) {+ throw new Error(reasons[0]);+ }++ const { inputImage, model, upscaleModel } = settings;++ if (!inputImage || !model || !upscaleModel) {+ throw new Error('Upscale settings are incomplete.');+ }++ const buildPath = UPSCALE_PATH_BUILDERS[model.base as UpscaleBase];++ if (!buildPath) {+ throw new Error(`Upscale does not support ${model.base} main models.`);+ }++ const grid = upscaleArchitectureFor(model)?.denoiseGrid ?? 8;+ const denoiseSize = {+ height: upscaleDenoiseDimension(inputImage.height, settings.scale, grid),+ width: upscaleDenoiseDimension(inputImage.width, settings.scale, grid),+ };+ const graph: BackendGraphContract = { edges: [], id: 'upscale-graph', nodes: {} };+ const positivePrompt = addNode(graph, { id: 'positive_prompt', type: 'string' });+ const negativePrompt = addNode(graph, { id: 'negative_prompt', type: 'string' });+ const seed = addNode(graph, { id: 'seed', type: 'integer' });+ const spandrelAutoscale = addNode(graph, {+ fit_to_multiple_of_8: true,+ id: 'spandrel_autoscale',+ image: { image_name: inputImage.image_name },+ image_to_image_model: toModelIdentifier(upscaleModel),+ scale: settings.scale,+ type: 'spandrel_image_to_image_autoscale',+ });+ const unsharpMask = addNode(graph, { id: 'unsharp_2', radius: 2, strength: 60, type: 'unsharp_mask' });++ addEdge(graph, spandrelAutoscale, 'image', unsharpMask, 'image');++ const { output, title } = buildPath({+ denoiseSize,+ destination,+ graph,+ model,+ negativePrompt,+ positivePrompt,+ projectSettings,+ seed,+ settings,+ unsharpMask,+ });+addUpscaleMetadata(graph, output, settings, projectSettings, randDevice);return {backendGraph: graph,- graph: toGraphContract(graph, `${model.name} multi-diffusion upscale`),+ graph: toGraphContract(graph, title),negativePromptNodeId: 'negative_prompt',outputNodeId: 'upscale_output',positivePromptNodeId: 'positive_prompt',diff --git a/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts b/invokeai/frontend/webv2/src/features/upscale/core/settings.test.tsindex 741dd74723..3ace6f83f5 100644--- a/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts+++ b/invokeai/frontend/webv2/src/features/upscale/core/settings.test.ts@@ -4,6 +4,7 @@ import type { ModelConfig } from '@features/models';import { seedArchitectureCapabilities } from '@features/generation/core/architectureCapabilities.testing';import { describe, expect, it } from 'vitest';+import { spandrelAutoscaleDimension, upscaleDenoiseDimension } from './architectures';import {clearDeletedUpscaleInput,createDefaultUpscaleWidgetValues,@@ -120,3 +121,96 @@ describe('upscale settings', () => {expect(clearDeletedUpscaleInput(values, new Set(['delete.png'])).inputImage).toBeNull();});});++describe('architecture-driven validation', () => {+ const upscaleReady = (models: ModelConfig[]) => ({+ ...createDefaultUpscaleWidgetValues(models),+ inputImage: { height: 64, image_name: 'in.png', width: 64 },+ });++ it('does not demand a tile ControlNet for an architecture that has none', () => {+ // The inversion this change is built on: compileUpscaleGraph used to throw without one.+ const values = upscaleReady([+ model('main', 'main', 'flux'),+ model('spandrel', 'spandrel_image_to_image', 'any'),+ model('t5', 't5_encoder', 'any'),+ model('clip', 'clip_embed', 'any'),+ model('fluxvae', 'vae', 'flux'),+ ]);++ expect(getUpscaleValidationReasons(values)).toEqual([]);+ expect(values.tileControlnetModel).toBeNull();+ });++ it('still demands one where the architecture uses it', () => {+ const values = upscaleReady([model('main', 'main', 'sdxl'), model('spandrel', 'spandrel_image_to_image', 'any')]);++ expect(getUpscaleValidationReasons(values)).toContain(+ 'Upscale needs a Tile or Union ControlNet compatible with the main model.'+ );+ });++ it.each([+ ['t5_encoder', 'Upscale needs a T5 encoder for this main model.'],+ ['clip_embed', 'Upscale needs a CLIP Embed model for this main model.'],+ ['vae', 'Upscale needs a VAE for this main model.'],+ ])('names the missing %s a bare FLUX checkpoint cannot supply', (missing, reason) => {+ const installed = [+ model('main', 'main', 'flux'),+ model('spandrel', 'spandrel_image_to_image', 'any'),+ model('t5', 't5_encoder', 'any'),+ model('clip', 'clip_embed', 'any'),+ model('fluxvae', 'vae', 'flux'),+ ].filter((candidate) => candidate.type !== missing);++ expect(getUpscaleValidationReasons(upscaleReady(installed))).toContain(reason);+ });++ it('exempts a self-contained SDNQ pipeline, which ships its own parts', () => {+ const sdnq = { ...model('main', 'main', 'flux'), format: 'sdnq_quantized' } as ModelConfig;+ const values = upscaleReady([sdnq, model('spandrel', 'spandrel_image_to_image', 'any')]);++ expect(getUpscaleValidationReasons(values)).toEqual([]);+ });++ it('refuses a FLUX Fill model, which the denoise node cannot run without fill conditioning', () => {+ const fill = { ...model('main', 'main', 'flux'), variant: 'dev_fill' } as ModelConfig;+ const values = upscaleReady([+ fill,+ model('spandrel', 'spandrel_image_to_image', 'any'),+ model('t5', 't5_encoder', 'any'),+ model('clip', 'clip_embed', 'any'),+ model('fluxvae', 'vae', 'flux'),+ ]);++ expect(getUpscaleValidationReasons(values)).toContain('Upscale cannot use a FLUX Fill model.');+ });++ it('blocks the run when a required component has been uninstalled', () => {+ // Without this the Invoke button stays enabled and the graph dies after Spandrel has run.+ const installed = [+ model('main', 'main', 'flux'),+ model('spandrel', 'spandrel_image_to_image', 'any'),+ model('t5', 't5_encoder', 'any'),+ model('clip', 'clip_embed', 'any'),+ model('fluxvae', 'vae', 'flux'),+ ];+ const values = upscaleReady(installed);+ const withoutT5 = installed.filter((candidate) => candidate.key !== 't5');++ expect(getUpscaleValidationReasons(values, withoutT5)).toContain('t5 is no longer installed.');+ });+});++describe('upscaleDenoiseDimension', () => {+ it('floors to the grid the architecture demands, not to the one Spandrel used', () => {+ // 1020 * 2 = 2040: a legal Spandrel size that flux_denoise rejects.+ expect(spandrelAutoscaleDimension(1020, 2)).toBe(2040);+ expect(upscaleDenoiseDimension(1020, 2, 8)).toBe(2040);+ expect(upscaleDenoiseDimension(1020, 2, 16)).toBe(2032);+ });++ it('never returns zero for a tiny frame', () => {+ expect(upscaleDenoiseDimension(4, 1, 16)).toBe(16);+ });+});diff --git a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts b/invokeai/frontend/webv2/src/features/upscale/core/settings.tsindex 591039696a..3a166dbcd9 100644--- a/invokeai/frontend/webv2/src/features/upscale/core/settings.ts+++ b/invokeai/frontend/webv2/src/features/upscale/core/settings.ts@@ -1,4 +1,5 @@import type {+ ComponentModelConfig,GenerateLora,ImageWithDims,MainModelConfig,@@ -26,6 +27,13 @@ import { isSeedMode, SEED_MAX } from '@platform/core/seed';import type { SpandrelModelConfig, TileControlNetModelConfig, UpscaleWidgetValues } from './types';+import {+ isUpscaleBase,+ needsExplicitComponents,+ supportedUpscaleArchitectureLabels,+ upscaleArchitectureFor,+} from './architectures';+export const UPSCALE_SCALE_SLIDER_MIN = 2;export const UPSCALE_SCALE_SLIDER_MAX = 8;export const UPSCALE_SCALE_MIN = 1;@@ -55,7 +63,43 @@ const normalizePromptHeight = (value: unknown, min: number, max: number, fallbacisFiniteNumber(value) ? Math.min(max, Math.max(min, value)) : fallback;export const isSupportedUpscaleMainModel = (value: unknown): value is MainModelConfig =>- isMainModelConfig(value) && (value.base === 'sd-1' || value.base === 'sdxl');+ isMainModelConfig(value) && isUpscaleBase(value.base);++const isComponentModelOfType = (value: unknown, type: string): value is ComponentModelConfig =>+ isRecord(value) && value.type === type && isModelIdentifierConfig(value);++const pickComponent = (+ stored: unknown,+ models: readonly ModelConfig[],+ type: string,+ required: boolean+): ComponentModelConfig | null => {+ if (isComponentModelOfType(stored, type)) {+ return stored;+ }++ // Only auto-pick where the architecture cannot run without one; elsewhere a stale selection is+ // simply dropped rather than replaced with an arbitrary encoder.+ return required+ ? ((models.find((model) => isComponentModelOfType(model, type)) as ComponentModelConfig) ?? null)+ : null;+};++const pickCompatibleVae = (+ stored: unknown,+ models: readonly ModelConfig[],+ model: MainModelConfig | null+): UpscaleWidgetValues['vae'] => {+ if (stored && isVaeModelConfig(stored) && model && isVaeCompatibleWithGenerateModel(model, stored)) {+ return stored;+ }++ return model+ ? ((models.find(+ (candidate) => isVaeModelConfig(candidate) && isVaeCompatibleWithGenerateModel(model, candidate)+ ) as UpscaleWidgetValues['vae']) ?? null)+ : null;+};export const isSpandrelModelConfig = (value: unknown): value is SpandrelModelConfig =>isModelIdentifierConfig(value) && value.type === 'spandrel_image_to_image';@@ -100,10 +144,12 @@ const normalizeLoras = (value: unknown): GenerateLora[] =>export const createDefaultUpscaleWidgetValues = (models: readonly ModelConfig[] = []): UpscaleWidgetValues => {const model = (models.find(isSupportedUpscaleMainModel) as MainModelConfig | undefined) ?? null;+ const needsComponents = needsExplicitComponents(model);return {batchCount: 1,cfgScale: 2,+ clipEmbedModel: pickComponent(null, models, 'clip_embed', needsComponents),clipSkip: 0,creativity: 0,inputImage: null,@@ -120,11 +166,12 @@ export const createDefaultUpscaleWidgetValues = (models: readonly ModelConfig[]seedMode: 'random',steps: 30,structure: 0,+ t5EncoderModel: pickComponent(null, models, 't5_encoder', needsComponents),tileControlnetModel: models.find((candidate) => isTileControlNetCandidate(candidate, model)) ?? null,tileOverlap: 128,tileSize: 1024,upscaleModel: (models.find(isSpandrelModelConfig) as SpandrelModelConfig | undefined) ?? null,- vae: null,+ vae: needsComponents ? pickCompatibleVae(null, models, model) : null,vaePrecision: 'fp32',};};@@ -143,6 +190,7 @@ export const normalizeUpscaleWidgetValues = (value: unknown): UpscaleWidgetValuereturn {batchCount: sanitizeBatchCount(value.batchCount),cfgScale: isFiniteNumber(value.cfgScale) ? value.cfgScale : defaults.cfgScale,+ clipEmbedModel: isComponentModelOfType(value.clipEmbedModel, 'clip_embed') ? value.clipEmbedModel : null,clipSkip: isFiniteNumber(value.clipSkip) ? value.clipSkip : defaults.clipSkip,creativity: isFiniteNumber(value.creativity) ? value.creativity : defaults.creativity,inputImage:@@ -182,6 +230,7 @@ export const normalizeUpscaleWidgetValues = (value: unknown): UpscaleWidgetValue: defaults.seedMode,steps: isFiniteNumber(value.steps) ? value.steps : defaults.steps,structure: isFiniteNumber(value.structure) ? value.structure : defaults.structure,+ t5EncoderModel: isComponentModelOfType(value.t5EncoderModel, 't5_encoder') ? value.t5EncoderModel : null,tileControlnetModel: isTileControlNetModelConfig(value.tileControlnetModel) ? value.tileControlnetModel : null,tileOverlap: isFiniteNumber(value.tileOverlap) ? value.tileOverlap : defaults.tileOverlap,tileSize: isFiniteNumber(value.tileSize) ? value.tileSize : defaults.tileSize,@@ -208,11 +257,26 @@ export const syncUpscaleWidgetValuesWithModels = (const tileControlnetModel = isTileControlNetCandidate(storedControlNet, model)? storedControlNet: (models.find((candidate) => isTileControlNetCandidate(candidate, model)) ?? null);+ const needsComponents = needsExplicitComponents(model);+ const t5EncoderModel = pickComponent(+ values.t5EncoderModel ? modelsByKey.get(values.t5EncoderModel.key) : undefined,+ models,+ 't5_encoder',+ needsComponents+ );+ const clipEmbedModel = pickComponent(+ values.clipEmbedModel ? modelsByKey.get(values.clipEmbedModel.key) : undefined,+ models,+ 'clip_embed',+ needsComponents+ );const storedVae = values.vae ? modelsByKey.get(values.vae.key) : undefined;const vae =storedVae && isVaeModelConfig(storedVae) && model && isVaeCompatibleWithGenerateModel(model, storedVae)? storedVae- : null;+ : needsComponents+ ? pickCompatibleVae(null, models, model)+ : null;const loras = model? values.loras.flatMap((lora) => {const installed = modelsByKey.get(lora.model.key);@@ -227,6 +291,8 @@ export const syncUpscaleWidgetValuesWithModels = (values.model === model &&values.upscaleModel === upscaleModel &&values.tileControlnetModel === tileControlnetModel &&+ values.t5EncoderModel === t5EncoderModel &&+ values.clipEmbedModel === clipEmbedModel &&values.vae === vae &&loras.length === values.loras.length &&loras.every((lora, index) => lora.model === values.loras[index]?.model)@@ -234,7 +300,7 @@ export const syncUpscaleWidgetValuesWithModels = (return values;}- return { ...values, loras, model, tileControlnetModel, upscaleModel, vae };+ return { ...values, clipEmbedModel, loras, model, t5EncoderModel, tileControlnetModel, upscaleModel, vae };};const addRangeReason = (reasons: string[], label: string, value: number, min: number, max: number): void => {@@ -252,15 +318,39 @@ export const getUpscaleValidationReasons = (values: UpscaleWidgetValues, models?if (!values.upscaleModel) {reasons.push('Upscale needs a Spandrel image-to-image model.');}+ const architecture = upscaleArchitectureFor(values.model);+if (!values.model) {- reasons.push('Upscale needs an SD1.5 or SDXL main model.');- } else if (!isSupportedUpscaleMainModel(values.model)) {- reasons.push('Upscale supports only SD1.5 and SDXL main models.');+ reasons.push(`Upscale needs a ${supportedUpscaleArchitectureLabels()} main model.`);+ } else if (!architecture) {+ reasons.push(`Upscale supports only ${supportedUpscaleArchitectureLabels()} main models.`);}- if (!values.tileControlnetModel) {- reasons.push('Upscale needs a Tile or Union ControlNet compatible with the main model.');- } else if (!isTileControlNetCandidate(values.tileControlnetModel, values.model)) {- reasons.push('The Tile ControlNet must match the main model base and be a Tile or Union model.');++ // `flux_denoise` refuses a Fill model without fill conditioning, which an upscale never supplies.+ if (values.model?.base === 'flux' && values.model.variant === 'dev_fill') {+ reasons.push('Upscale cannot use a FLUX Fill model.');+ }++ // Only asked for where the architecture has a tile ControlNet to anchor the second pass with.+ if (architecture?.usesTileControlNet) {+ if (!values.tileControlnetModel) {+ reasons.push('Upscale needs a Tile or Union ControlNet compatible with the main model.');+ } else if (!isTileControlNetCandidate(values.tileControlnetModel, values.model)) {+ reasons.push('The Tile ControlNet must match the main model base and be a Tile or Union model.');+ }+ }++ // A bare FLUX transformer cannot supply these itself, and `flux_model_loader` refuses without them.+ if (needsExplicitComponents(values.model)) {+ if (!values.t5EncoderModel) {+ reasons.push('Upscale needs a T5 encoder for this main model.');+ }+ if (!values.clipEmbedModel) {+ reasons.push('Upscale needs a CLIP Embed model for this main model.');+ }+ if (!values.vae) {+ reasons.push('Upscale needs a VAE for this main model.');+ }}addRangeReason(reasons, 'Scale', values.scale, UPSCALE_SCALE_MIN, UPSCALE_SCALE_MAX);@@ -278,6 +368,10 @@ export const getUpscaleValidationReasons = (values: UpscaleWidgetValues, models?...(values.model ? [values.model] : []),...(values.upscaleModel ? [values.upscaleModel] : []),...(values.tileControlnetModel ? [values.tileControlnetModel] : []),+ // Required for FLUX, so a deleted encoder must block the run rather than fail mid-graph.+ ...(values.t5EncoderModel ? [values.t5EncoderModel] : []),+ ...(values.clipEmbedModel ? [values.clipEmbedModel] : []),+ ...(values.vae ? [values.vae] : []),];for (const selected of required) {diff --git a/invokeai/frontend/webv2/src/features/upscale/core/types.ts b/invokeai/frontend/webv2/src/features/upscale/core/types.tsindex ac3f9dada8..97610cbae9 100644--- a/invokeai/frontend/webv2/src/features/upscale/core/types.ts+++ b/invokeai/frontend/webv2/src/features/upscale/core/types.ts@@ -1,5 +1,6 @@import type {CompiledGenerateGraph,+ ComponentModelConfig,GenerateLora,ImageWithDims,MainModelConfig,@@ -36,6 +37,9 @@ export interface UpscaleWidgetValues {clipSkip: number;vae: VaeModelConfig | null;vaePrecision: VaePrecision;+ /** Only used by architectures whose `needsExplicitComponents` is set; null elsewhere. */+ t5EncoderModel: ComponentModelConfig | null;+ clipEmbedModel: ComponentModelConfig | null;tileControlnetModel: TileControlNetModelConfig | null;tileSize: number;diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleFormFields.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleFormFields.tsxindex 8fb28e0f92..d3ef4aa420 100644--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleFormFields.tsx+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleFormFields.tsx@@ -5,6 +5,7 @@ import type { UpscaleWidgetValues } from '@features/upscale/core/types';import { HStack, NumberInput, Stack, Switch, Text } from '@chakra-ui/react';import { NegativePromptField, PositivePromptField } from '@features/generation/components';import { areProjectPromptDraftsEqual } from '@features/generation/settings';+import { upscaleArchitectureFor } from '@features/upscale/core/architectures';import { IconButton } from '@platform/ui/Button';import { MiddleTruncate } from '@platform/ui/MiddleTruncate';import { Trash2Icon } from 'lucide-react';@@ -89,18 +90,20 @@ export const UpscalePromptFields = memo(onResizeEnd={handlePositiveResizeEnd}onUsePrompt={handleUsePrompt}/>- <NegativePromptField- heightPx={negativePromptHeightPx}- isEnabled={promptDraft.negativePromptEnabled}- loras={loras}- projectId={projectId}- selectedModel={model ?? undefined}- showSyntaxHighlighting={showSyntaxHighlighting}- value={promptDraft.negativePrompt}- onChange={handleNegativeChange}- onEnabledChange={handleNegativeEnabledChange}- onResizeEnd={handleNegativeResizeEnd}- />+ {(upscaleArchitectureFor(model)?.usesNegativePrompt ?? true) && (+ <NegativePromptField+ heightPx={negativePromptHeightPx}+ isEnabled={promptDraft.negativePromptEnabled}+ loras={loras}+ projectId={projectId}+ selectedModel={model ?? undefined}+ showSyntaxHighlighting={showSyntaxHighlighting}+ value={promptDraft.negativePrompt}+ onChange={handleNegativeChange}+ onEnabledChange={handleNegativeEnabledChange}+ onResizeEnd={handleNegativeResizeEnd}+ />+ )}</Stack>);},diff --git a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsxindex 2df9301222..87fc2cac2b 100644--- a/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx+++ b/invokeai/frontend/webv2/src/features/upscale/ui/UpscaleWidgetView.tsx@@ -10,11 +10,13 @@ import {isLoraCompatibleWithModel,isLoraModelConfig,isMainModelConfig,+ isModelIdentifierConfig,isVaeModelConfig,SCHEDULER_OPTIONS,} from '@features/generation/settings';import { ensureModelsLoaded, useModelsSelector } from '@features/models';import { ModelSelect } from '@features/models/react';+import { needsExplicitComponents, upscaleArchitectureFor } from '@features/upscale/core/architectures';import {createDefaultUpscaleWidgetValues,getUpscaleOutputDimensions,@@ -65,6 +67,8 @@ const MAIN_MODEL_TYPES: readonly ModelTaxonomyType[] = ['main'];const LORA_MODEL_TYPES: readonly ModelTaxonomyType[] = ['lora'];const CONTROLNET_MODEL_TYPES: readonly ModelTaxonomyType[] = ['controlnet'];const VAE_MODEL_TYPES: readonly ModelTaxonomyType[] = ['vae'];+const T5_ENCODER_MODEL_TYPES: readonly ModelTaxonomyType[] = ['t5_encoder'];+const CLIP_EMBED_MODEL_TYPES: readonly ModelTaxonomyType[] = ['clip_embed'];const SCALE_MARKS = [1, 2, 4, 8, 16];const CREATIVITY_MARKS = [UPSCALE_CREATIVITY_MIN, 0, UPSCALE_CREATIVITY_MAX];@@ -328,12 +332,22 @@ export const UpscaleWidgetView = () => {);const selectedLoraKeys = useMemo(() => new Set(values.loras.map((lora) => lora.model.key)), [values.loras]);+ // A control with nothing to steer is worse than no control, so the widget follows the table+ // rather than showing every field for every architecture.+ const architecture = upscaleArchitectureFor(values.model);+ const showTileControlNet = architecture?.usesTileControlNet ?? false;+ const showComponentPickers = needsExplicitComponents(values.model);+const activePresetId = useMemo(() =>PRESET_ENTRIES.find(- ([, preset]) => values.creativity === preset.creativity && values.structure === preset.structure+ ([, preset]) =>+ values.creativity === preset.creativity &&+ // Structure is hidden where nothing consumes it, so a stale value must not keep every+ // preset unhighlighted with nothing on screen to explain why.+ (!showTileControlNet || values.structure === preset.structure))?.[0] ?? null,- [values.creativity, values.structure]+ [showTileControlNet, values.creativity, values.structure]);const applyPreset = useCallback(({ value }: { value: string | null }) => {@@ -393,6 +407,15 @@ export const UpscaleWidgetView = () => {const vaePrecisionValue = useMemo(() => [values.vaePrecision], [values.vaePrecision]);+ const setT5Encoder = useCallback(+ (model: ModelConfig | null) => patch({ t5EncoderModel: isModelIdentifierConfig(model) ? model : null }),+ [patch]+ );+ const setClipEmbed = useCallback(+ (model: ModelConfig | null) => patch({ clipEmbedModel: isModelIdentifierConfig(model) ? model : null }),+ [patch]+ );+const sharedBadge = useMemo(() => (<Badge fontFamily="mono" size="xs">@@ -481,18 +504,20 @@ export const UpscaleWidgetView = () => {value={values.creativity}onChange={set.creativity}/>- <ScrubberField- error={errors.structure}- helpText={t('widgets.upscale.structureHelp')}- hint="structure"- label={t('widgets.upscale.structure')}- marks={STRUCTURE_MARKS}- max={UPSCALE_STRUCTURE_MAX}- min={UPSCALE_STRUCTURE_MIN}- step={1}- value={values.structure}- onChange={set.structure}- />+ {showTileControlNet && (+ <ScrubberField+ error={errors.structure}+ helpText={t('widgets.upscale.structureHelp')}+ hint="structure"+ label={t('widgets.upscale.structure')}+ marks={STRUCTURE_MARKS}+ max={UPSCALE_STRUCTURE_MAX}+ min={UPSCALE_STRUCTURE_MIN}+ step={1}+ value={values.structure}+ onChange={set.structure}+ />+ )}</Stack></GenerationSettingsSection>@@ -586,22 +611,56 @@ export const UpscaleWidgetView = () => {<GenerationSettingsSection label={t('widgets.upscale.advanced')}><Stack gap="3" p="2">- <Field- error={values.tileControlnetModel ? undefined : t('widgets.upscale.tileControlNetRequired')}- helpText={values.tileControlnetModel ? t('widgets.upscale.tileControlNetHelp') : undefined}- hint="tileControlNet"- label={t('widgets.upscale.tileControlNet')}- >- <ModelSelect- filter={tileControlNetFilter}- invalid={!values.tileControlnetModel}- modelTypes={CONTROLNET_MODEL_TYPES}- placeholder={t('widgets.upscale.selectTileControlNet')}- size="xs"- value={values.tileControlnetModel?.key ?? null}- onChange={setTileControlNet}- />- </Field>+ {showTileControlNet && (+ <Field+ error={values.tileControlnetModel ? undefined : t('widgets.upscale.tileControlNetRequired')}+ helpText={values.tileControlnetModel ? t('widgets.upscale.tileControlNetHelp') : undefined}+ hint="tileControlNet"+ label={t('widgets.upscale.tileControlNet')}+ >+ <ModelSelect+ filter={tileControlNetFilter}+ invalid={!values.tileControlnetModel}+ modelTypes={CONTROLNET_MODEL_TYPES}+ placeholder={t('widgets.upscale.selectTileControlNet')}+ size="xs"+ value={values.tileControlnetModel?.key ?? null}+ onChange={setTileControlNet}+ />+ </Field>+ )}+ {showComponentPickers && (+ <>+ <Field+ error={values.t5EncoderModel ? undefined : t('widgets.upscale.t5EncoderRequired')}+ hint="t5Encoder"+ label={t('widgets.upscale.t5Encoder')}+ >+ <ModelSelect+ invalid={!values.t5EncoderModel}+ modelTypes={T5_ENCODER_MODEL_TYPES}+ placeholder={t('widgets.upscale.selectT5Encoder')}+ size="xs"+ value={values.t5EncoderModel?.key ?? null}+ onChange={setT5Encoder}+ />+ </Field>+ <Field+ error={values.clipEmbedModel ? undefined : t('widgets.upscale.clipEmbedRequired')}+ hint="clipEmbed"+ label={t('widgets.upscale.clipEmbed')}+ >+ <ModelSelect+ invalid={!values.clipEmbedModel}+ modelTypes={CLIP_EMBED_MODEL_TYPES}+ placeholder={t('widgets.upscale.selectClipEmbed')}+ size="xs"+ value={values.clipEmbedModel?.key ?? null}+ onChange={setClipEmbed}+ />+ </Field>+ </>+ )}<ScrubberFielderror={errors.tileSize}helpText={t('widgets.upscale.tileSizeHelp')}@@ -628,15 +687,17 @@ export const UpscaleWidgetView = () => {/><SimpleGrid columns={ADVANCED_GRID_COLUMNS} gap="2"><Field+ error={showComponentPickers && !values.vae ? t('widgets.upscale.vaeRequired') : undefined}hint="vae"label={t('widgets.upscale.vae')}- helpText={values.vae ? undefined : t('widgets.upscale.bundledVae')}+ helpText={values.vae || showComponentPickers ? undefined : t('widgets.upscale.bundledVae')}><ModelSelectfilter={vaeFilter}- isClearable+ invalid={showComponentPickers && !values.vae}+ isClearable={!showComponentPickers}modelTypes={VAE_MODEL_TYPES}- placeholder={t('widgets.upscale.bundledVae')}+ placeholder={showComponentPickers ? t('widgets.upscale.selectVae') : t('widgets.upscale.bundledVae')}size="xs"value={values.vae?.key ?? null}onChange={set.vae}diff --git a/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts b/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.tsindex b63a211ff2..224b8f0cb1 100644--- a/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts+++ b/invokeai/frontend/webv2/src/platform/ui/hints/hintRegistry.ts@@ -20,6 +20,7 @@ export const FEATURE_HINTS = {aspectRatio: {},cfgRescale: { href: SUPPORT_ADVANCED_SETTINGS },cfgScale: { href: 'https://www.youtube.com/watch?v=1OeHEJrsTpI' },+ clipEmbed: {},clipSkip: { href: SUPPORT_ADVANCED_SETTINGS },colorCompensation: {},concepts: { href: SUPPORT_CONCEPTS },@@ -58,6 +59,7 @@ export const FEATURE_HINTS = {},steps: {},structure: {},+ t5Encoder: {},tileControlNet: { href: 'https://support.invoke.ai/support/solutions/articles/151000105880' },tileOverlap: {},tileSize: {},diff --git a/invokeai/frontend/webv2/src/workbench/invocation.test.ts b/invokeai/frontend/webv2/src/workbench/invocation.test.tsindex 44f9d36aea..55017ab618 100644--- a/invokeai/frontend/webv2/src/workbench/invocation.test.ts+++ b/invokeai/frontend/webv2/src/workbench/invocation.test.ts@@ -220,18 +220,28 @@ describe('resolveInvocationRoute — upscale source', () => {);});- it('rejects unsupported main-model bases and non-Tile ControlNets', () => {+ it('rejects a main-model base the widget has no builder for', () => {+ // FLUX.1 used to stand in for "unsupported" here; it is supported now, so this needs a base+ // that genuinely has no entry in UPSCALE_ARCHITECTURES.+ const input = createInput();+ const values = { ...input.upscaleValues, model: upscaleModel('sd3-upscale', 'main', 'sd-3', 'SD3') };+ const models = [values.model, upscaleModels[1]!];+ const result = resolveInvocationRouteInput({ ...input, upscaleValues: values }, 'global', route, models);++ expect(result.sourceValid).toBe(false);+ expect(result.validationReasons).toContain('Upscale supports only SD1.5, SDXL or FLUX.1 main models.');+ });++ it('rejects a ControlNet that is not a Tile model for its base', () => {const input = createInput();const values = {...input.upscaleValues,- model: upscaleModel('flux-upscale', 'main', 'flux', 'FLUX'),- tileControlnetModel: upscaleModel('depth-upscale', 'controlnet', 'flux', 'FLUX Depth ControlNet'),+ tileControlnetModel: upscaleModel('depth-upscale', 'controlnet', 'sdxl', 'SDXL Depth ControlNet'),};- const models = [values.model, values.tileControlnetModel, upscaleModels[1]!];+ const models = [...upscaleModels, values.tileControlnetModel];const result = resolveInvocationRouteInput({ ...input, upscaleValues: values }, 'global', route, models);expect(result.sourceValid).toBe(false);- expect(result.validationReasons).toContain('Upscale supports only SD1.5 and SDXL main models.');expect(result.validationReasons).toContain('The Tile ControlNet must match the main model base and be a Tile or Union model.');