Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(workflow): TextEncodeQwenImage21 bekommt resolution auch ohne Referenzbild

purple3db50a05df94
diff --git a/src/api/__tests__/qwen-image-21-workflow.test.ts b/src/api/__tests__/qwen-image-21-workflow.test.ts
index 734389a4..0297c700 100644
--- a/src/api/__tests__/qwen-image-21-workflow.test.ts
+++ b/src/api/__tests__/qwen-image-21-workflow.test.ts
@@ -219,6 +219,10 @@ describe('buildDynamicWorkflow, Qwen-Image 2.1 generate (no reference image)', (
// latents, and the node keeps its vision path instead.
expect(enc.inputs.vae).toBeUndefined()
expect(enc.inputs['images.image_1']).toBeUndefined()
+ // resolution is a REQUIRED widget of the node, so it has to be there even
+ // on the path that never reads it. Leaving it off gets the whole prompt
+ // rejected with "Required input is missing".
+ expect(enc.inputs.resolution).toBe(1024)
expect(nodeOf(wf, 'CLIPTextEncode')).toBeUndefined()
expect(nodeOf(wf, 'LoadImage')).toBeUndefined()
})
@@ -244,6 +248,22 @@ describe('buildDynamicWorkflow, Qwen-Image 2.1 generate (no reference image)', (
expect(nodeOf(wf, 'KSampler')![1].inputs.latent_image).toEqual([latentId, 0])
})
+ // ComfyUI rejects a whole prompt when ANY required input of a node is
+ // absent ("Required input is missing", execution.py validate_inputs), and
+ // that happens before a single step is sampled. The node's required set is
+ // clip, prompt, negative_prompt and resolution, so the guard is asserted
+ // against the schema rather than against a list typed out by hand.
+ it('carries every input the node declares as required, on both paths', async () => {
+ const required = Object.keys(QWEN_NODES.TextEncodeQwenImage21.input.required)
+ for (const params of [baseParams, { ...baseParams, inputImage: 'lu_source.png', denoise: 0.7 }]) {
+ const wf = await buildDynamicWorkflow({ ...params } as never)
+ const enc = nodeOf(wf, 'TextEncodeQwenImage21')![1]
+ for (const key of required) {
+ expect(enc.inputs[key], `${key} missing`).toBeDefined()
+ }
+ }
+ })
+
it('decodes and saves like every other image lane', async () => {
const wf = await buildDynamicWorkflow({ ...baseParams } as never)
const [decodeId] = nodeOf(wf, 'VAEDecode')!
diff --git a/src/api/dynamic-workflow.ts b/src/api/dynamic-workflow.ts
index dc1653c5..5279231d 100644
--- a/src/api/dynamic-workflow.ts
+++ b/src/api/dynamic-workflow.ts
@@ -471,7 +471,8 @@ function resolveLoaderName(req: string, installed: string[]): string | null {
* a zero that would silently switch the node back to original size.
*/
function qwenEditResolution(width: number, height: number): number {
- const side = Math.sqrt(Math.max(1, width) * Math.max(1, height))
+ const px = (v: number) => (Number.isFinite(v) && v > 0 ? v : 1024)
+ const side = Math.sqrt(px(width) * px(height))
return Math.min(4096, Math.max(32, Math.round(side / 32) * 32))
}
@@ -842,10 +843,16 @@ export async function buildDynamicWorkflow(
// template does, and takes its latent from EmptyLatentImage below.
// negId is allocated but unused on this path; the graph is keyed by id,
// so a gap costs nothing (the I2I override below already leaves one).
+ // `resolution` is declared REQUIRED by the node (no optional flag on its
+ // Int input), so it goes on BOTH paths or ComfyUI answers "Required input
+ // is missing" before anything runs. It only does work when a reference
+ // image is attached; on the generate path it is inert, exactly as in the
+ // t2i template, which also carries the widget and never uses it.
const qwenInputs: ComfyNodeInputs = {
clip: [clipSourceId, clipOutputSlot],
prompt: params.prompt,
negative_prompt: params.negativePrompt || '',
+ resolution: qwenEditResolution(params.width, params.height),
}
if (isQwenEdit) {
const qwenImageId = String(n++)
@@ -855,7 +862,6 @@ export async function buildDynamicWorkflow(
}
qwenInputs['images.image_1'] = [qwenImageId, 0]
qwenInputs.vae = [vaeSourceId, vaeOutputSlot]
- qwenInputs.resolution = qwenEditResolution(params.width, params.height)
}
workflow[posId] = { class_type: 'TextEncodeQwenImage21', inputs: qwenInputs }
} else {
diff --git a/src/api/model-bundles.ts b/src/api/model-bundles.ts
index 7fef23f5..67fdee3d 100644
--- a/src/api/model-bundles.ts
+++ b/src/api/model-bundles.ts
@@ -343,7 +343,7 @@ export function getImageBundles(): ModelBundle[] {
},
{
name: 'Qwen-Image 2.1 (Generate and Edit)',
- description: 'One model for both: write a prompt to generate, or add a reference image plus a prompt to edit it, no mask needed. Qwen Research License, non-commercial use: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE',
+ description: 'Generates from a prompt and edits a reference image from a prompt, no mask needed. Qwen Research License, non-commercial use: https://huggingface.co/Qwen/Qwen-Image-2.1/blob/main/LICENSE',
tags: ['Qwen Image 2.1', 'Image', 'Edit', '1024px'],
uncensored: false,
verified: true,