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.

feat(upscale): apply MOSS-Image LoRAs in the Upscale detail pass (#10300)

Francois Brodeur0083903ad71e
diff --git a/docs/src/content/docs/Users Guide/04.Image Generation/upscale.mdx b/docs/src/content/docs/Users Guide/04.Image Generation/upscale.mdx
index e7d614e694..708b825dd3 100644
--- a/docs/src/content/docs/Users Guide/04.Image Generation/upscale.mdx
+++ b/docs/src/content/docs/Users Guide/04.Image Generation/upscale.mdx
@@ -142,7 +142,7 @@ Where a family has no Tile ControlNet, **Structure** is hidden. Where it ignores
- **CFG scale**: set when you pick the model: 3.
- **Steps**: kept as you set it, 30 by default, not the 50 the model uses for a full image. MOSS-Image runs all of **Steps** in the detail pass, so 30 steps really run 30 times, each at the enlarged size and, above CFG 1, as two network passes. Lower it if the pass is slow.
- **Components**: a **Qwen3.5 Encoder** (9B, not the 4B Anima-3.8B uses) and a FLUX.2 **VAE**. A Diffusers install brings its own.
- - **Not supported**: LoRAs, which MOSS-Image has no loader for.
+ - **LoRAs**: MOSS-Image LoRAs apply to the detail pass, on the transformer only.
</TabItem>
</Tabs>
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/__snapshots__/upscaleGraphNodeTypes.json b/invokeai/frontend/webv2/src/features/upscale/core/__snapshots__/upscaleGraphNodeTypes.json
index 85281f3857..d9648dcced 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/__snapshots__/upscaleGraphNodeTypes.json
+++ b/invokeai/frontend/webv2/src/features/upscale/core/__snapshots__/upscaleGraphNodeTypes.json
@@ -23,6 +23,7 @@
"collect collection krea2_denoise positive_conditioning",
"collect collection krea2_lora_collection_loader loras",
"collect collection lora_collection_loader loras",
+ "collect collection moss_image_lora_collection_loader loras",
"collect collection qwen_image_lora_collection_loader loras",
"collect collection sdxl_lora_collection_loader loras",
"collect collection tiled_multi_diffusion_denoise_latents control",
@@ -105,8 +106,9 @@
"main_model_loader vae i2l vae",
"main_model_loader vae l2i vae",
"moss_image_denoise latents flux2_vae_decode latents",
+ "moss_image_lora_collection_loader transformer moss_image_denoise transformer",
"moss_image_model_loader qwen3_5_encoder moss_image_text_encoder qwen3_5_encoder",
- "moss_image_model_loader transformer moss_image_denoise transformer",
+ "moss_image_model_loader transformer moss_image_lora_collection_loader transformer",
"moss_image_model_loader vae flux2_vae_decode vae",
"moss_image_model_loader vae flux2_vae_encode vae",
"moss_image_model_loader vae moss_image_denoise vae",
@@ -305,12 +307,15 @@
},
"moss-image": {
"nodeTypes": [
+ "collect",
"core_metadata",
"flux2_vae_decode",
"flux2_vae_encode",
"img_resize",
"integer",
+ "lora_selector",
"moss_image_denoise",
+ "moss_image_lora_collection_loader",
"moss_image_model_loader",
"moss_image_text_encoder",
"spandrel_image_to_image_autoscale",
@@ -1268,6 +1273,23 @@
"latents"
]
},
+ "moss_image_lora_collection_loader": {
+ "inputs": [
+ "loras",
+ "transformer"
+ ],
+ "literalInputs": {
+ "is_intermediate": [
+ true
+ ],
+ "use_cache": [
+ true
+ ]
+ },
+ "outputs": [
+ "transformer"
+ ]
+ },
"moss_image_model_loader": {
"inputs": [],
"literalInputs": {
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts b/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts
index aa46d4ec1f..fd42858725 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts
+++ b/invokeai/frontend/webv2/src/features/upscale/core/graph.test.ts
@@ -916,3 +916,45 @@ describe('upscale metadata', () => {
expect(recorded).toEqual(loaded);
});
});
+
+describe('compileUpscaleGraph for MOSS-Image', () => {
+ const createMossImageValues = () => {
+ const models = [
+ { ...model('main', 'main', 'moss-image'), format: 'diffusers' },
+ model('spandrel', 'spandrel_image_to_image', 'any'),
+ model('lora', 'lora', 'moss-image'),
+ ] as ModelConfig[];
+
+ return {
+ ...createDefaultUpscaleWidgetValues(models),
+ inputImage: { height: 101, image_name: 'input.png', width: 203 },
+ loras: [{ isEnabled: true, model: models[2] as GenerateLora['model'], weight: 0.7 }],
+ positivePrompt: 'detail',
+ };
+ };
+
+ it('patches the refine pass transformer with the active LoRAs and leaves the encoder and VAE on the loader', () => {
+ const { edges, nodes } = compileUpscaleGraph(createMossImageValues(), 'gallery', {
+ useCpuNoise: true,
+ }).backendGraph;
+ const loraLoaderId = Object.entries(nodes).find(
+ ([, node]) => node.type === 'moss_image_lora_collection_loader'
+ )?.[0];
+
+ expect(loraLoaderId).toBeDefined();
+ expect(hasEdge(edges, 'model_loader', 'transformer', loraLoaderId ?? '', 'transformer')).toBe(true);
+ expect(hasEdge(edges, loraLoaderId ?? '', 'transformer', 'denoise_latents', 'transformer')).toBe(true);
+ expect(hasEdge(edges, 'model_loader', 'transformer', 'denoise_latents', 'transformer')).toBe(false);
+ expect(hasEdge(edges, 'model_loader', 'qwen3_5_encoder', 'pos_cond', 'qwen3_5_encoder')).toBe(true);
+ expect(hasEdge(edges, 'model_loader', 'vae', 'denoise_latents', 'vae')).toBe(true);
+ });
+
+ it('takes the transformer straight from the model loader without LoRAs', () => {
+ const { edges, nodes } = compileUpscaleGraph({ ...createMossImageValues(), loras: [] }, 'gallery', {
+ useCpuNoise: true,
+ }).backendGraph;
+
+ expect(Object.values(nodes).some((node) => node.type === 'moss_image_lora_collection_loader')).toBe(false);
+ expect(hasEdge(edges, 'model_loader', 'transformer', 'denoise_latents', 'transformer')).toBe(true);
+ });
+});
diff --git a/invokeai/frontend/webv2/src/features/upscale/core/graph.ts b/invokeai/frontend/webv2/src/features/upscale/core/graph.ts
index d8dd7572d1..7fb402d70d 100644
--- a/invokeai/frontend/webv2/src/features/upscale/core/graph.ts
+++ b/invokeai/frontend/webv2/src/features/upscale/core/graph.ts
@@ -891,7 +891,8 @@ const addPromptConditioning = (
};
/**
- * `moss_image_denoise` uses the FLUX.2 VAE's raw latent layout, so FLUX.2's tiled encode/decode nodes fit.
+ * `moss_image_denoise` uses the FLUX.2 VAE's raw latent layout, so FLUX.2's tiled encode/decode nodes fit. Its LoRAs
+ * load on the transformer only.
* Generate's layout prompt is left out: it only compiles layout drafts or canvas regions.
*/
const buildMossImageUpscalePath: UpscalePathBuilder = ({
@@ -914,6 +915,13 @@ const buildMossImageUpscalePath: UpscalePathBuilder = ({
type: 'moss_image_model_loader',
vae_model: settings.vae ? toModelIdentifier(settings.vae) : undefined,
});
+ // MOSS-Image LoRAs train the transformer only; the VAE and the Qwen3.5 encoder stay on the model loader.
+ const activeLoras = getActiveCompatibleLoras({ loras: settings.loras }, model);
+ const loraSource = activeLoras.length
+ ? addTransformerLoraCollectionLoader(graph, activeLoras, 'moss_image_lora_collection_loader', modelLoader, [
+ 'transformer',
+ ])
+ : modelLoader;
const imageToLatents = addNode(graph, {
id: 'i2l',
tile_size: settings.tileSize,
@@ -947,7 +955,7 @@ const buildMossImageUpscalePath: UpscalePathBuilder = ({
negativePrompt: wiresUpscaleNegativePrompt(model, settings.cfgScale) ? negativePrompt : null,
positivePrompt,
});
- addEdge(graph, modelLoader, 'transformer', denoise, 'transformer');
+ addEdge(graph, loraSource, 'transformer', denoise, 'transformer');
addEdge(graph, seed, 'value', denoise, 'seed');
const fitted = fitFrameToDenoiseSize(graph, frame, denoiseSize);