capitan01R/ComfyUI-qwen_img_2_1_enhancer

Qwen image 2.1 Enhancement Nodes

Python

0

8 commits

updated Oct 4, 2026

See the code

See what people are saying

SourceMessageScoreDate

ComfyUI Qwen image 2.1 Enhancer (Two nodes) (r/StableDiffusion)

I put together an enhancer pack for Qwen Image 2.1 with two nodes for controlling what the model pays attention to during editing. **Reference Strength** lets you select a reference image and increase or decrease its attention priority. If you're working with multiple references, you can adjust…

2

Oct 4, 2026

README

ComfyUI-qwen_img_2_1_enhancer

Buy Me A Coffee

Reference-image strength and prompt phrase weighting for Qwen Image 2.1 in ComfyUI.

Adjust the influence of individual reference images and emphasize selected parts of a prompt. The two nodes can be used independently or together.

Installation

cd ComfyUI/custom_nodes
git clone https://github.com/capitan01R/ComfyUI-qwen_img_2_1_enhancer.git

Restart ComfyUI after installing or updating.

Requires ComfyUI with native Qwen Image 2.1 support and a working model, text encoder, and VAE setup. No additional Python packages or ComfyUI core-file edits are required.

Included Nodes

NodeOutputsPurpose
Qwen Image 2.1 Reference StrengthMODELControls attention priority for a selected reference image.
Qwen Image 2.1 Edit — Phrase Weightspositive, negative, latent, phrase_reportAdds (phrase:weight) syntax to positive and negative prompts.

Reference Strength

Place Qwen Image 2.1 Reference Strength after your model and LoRA loaders, then connect its MODEL output to the sampler.

Load Diffusion Model -> LoRA loaders (optional) -> Reference Strength -> sampler

Connect your reference images and VAE to Text Encode Qwen Image 2.1 or the included Phrase Weights encoder.

InputDefaultDescription
model—Qwen Image 2.1 MODEL, including any applied LoRAs.
reference_index1Reference to adjust: 1 is the first connected image, 2 is the second, and so on.
strength1.2Attention-odds multiplier for the selected reference.
StrengthBehavior
1.0Native reference weighting.
Above 1.0Increases reference priority.
Between 0.0 and 1.0Reduces reference priority.
0.0Blocks direct attention to the selected reference's latent tokens. Information about it can remain elsewhere in the conditioning.

Reference selection follows the encoder's connected-image order; empty inputs are skipped. The adjustment applies to the whole reference image.

Chain nodes to adjust multiple references. Repeating an index replaces its earlier strength. Setting that index's strength to 1.0 removes its adjustment.

Phrase Weights

Use Qwen Image 2.1 Edit — Phrase Weights in place of the native Text Encode Qwen Image 2.1 node.

Connect your Qwen Image 2.1 CLIP, reference images, and VAE. Send the positive, negative, and latent outputs to the sampler. The model follows its normal path to the sampler; this encoder does not require a MODEL connection.

Syntax

Wrap a word or phrase in parentheses followed by a colon and a nonnegative weight:

Add (warm lighting:1.3) and (soft shadows:1.1).
WeightBehavior
1.0Native phrase weighting.
Above 1.0Increases phrase priority.
Between 0.0 and 1.0Reduces phrase priority.
0.0Strongly suppresses attention to the selected phrase tokens.

Positive and negative prompts have independent weights. Only the marked occurrence of a phrase receives the adjustment. Use complete words or phrases in separate, non-nested sections.

Controls and outputs

Input/outputDescription
clipNative Qwen Image 2.1 text encoder, loaded with CLIP type qwen_image.
promptPositive prompt with optional weighted phrases.
negative_promptNegative prompt with its own optional weighted phrases.
vaeNative Qwen Image 2.1 VAE. Required when combining with Reference Strength.
resolutionReference resizing target. Default 1024; 0 keeps references near their original dimensions, rounded to multiples of 32.
imagesReference images; additional sockets appear as needed.
positive, negativeConditioning outputs for the sampler.
latentEmpty latent sized from the first reference after resizing.
phrase_reportOptional JSON text report showing the clean prompts, weights, and selected token rows.

Using Both Nodes

Connect Reference Strength to the sampler's MODEL input and Phrase Weights to its conditioning and latent inputs:

MODEL -> Reference Strength -------------------------> sampler MODEL

CLIP + VAE + images -> Phrase Weights
                           |------------------------> sampler positive
                           |------------------------> sampler negative
                           `------------------------> sampler latent_image

Adjust one control at a time while keeping other settings fixed to compare its effect.

How It Works

Both nodes adjust attention scores inside the native Qwen Image 2.1 transformer. For a positive weight w, the selected scores receive log(w) before softmax, changing their relative attention priority while retaining normalization.

Reference Strength selects reference-image keys. Phrase Weights selects the text keys belonging to marked phrases and carries their weights with the conditioning. Text embeddings and reference pixels are not rescaled or composited into the output. Native prefix caching is preserved.

Weights control attention priority, so a value of 2.0 does not imply twice the visible effect. Large values can dominate other instructions or references and reduce editing flexibility.

Compatibility

  • Requires the native Qwen Image 2.1 implementation.
  • Attention backends must support additive masks.
  • Phrase mapping requires whole tokenizer pieces and does not support textual-inversion embeddings.
  • Changes to conditioning token rows after phrase encoding can invalidate the mapping.

License

MIT.

capitan01R/ComfyUI-qwen_img_2_1_enhancer

Qwen image 2.1 Enhancement Nodes

Python

0

8 commits

updated Oct 4, 2026

See the code

See what people are saying

SourceMessageScoreDate

ComfyUI Qwen image 2.1 Enhancer (Two nodes) (r/StableDiffusion)

I put together an enhancer pack for Qwen Image 2.1 with two nodes for controlling what the model pays attention to during editing. **Reference Strength** lets you select a reference image and increase or decrease its attention priority. If you're working with multiple references, you can adjust…

2

Oct 4, 2026

README

ComfyUI-qwen_img_2_1_enhancer

Buy Me A Coffee

Reference-image strength and prompt phrase weighting for Qwen Image 2.1 in ComfyUI.

Adjust the influence of individual reference images and emphasize selected parts of a prompt. The two nodes can be used independently or together.

Installation

cd ComfyUI/custom_nodes
git clone https://github.com/capitan01R/ComfyUI-qwen_img_2_1_enhancer.git

Restart ComfyUI after installing or updating.

Requires ComfyUI with native Qwen Image 2.1 support and a working model, text encoder, and VAE setup. No additional Python packages or ComfyUI core-file edits are required.

Included Nodes

NodeOutputsPurpose
Qwen Image 2.1 Reference StrengthMODELControls attention priority for a selected reference image.
Qwen Image 2.1 Edit — Phrase Weightspositive, negative, latent, phrase_reportAdds (phrase:weight) syntax to positive and negative prompts.

Reference Strength

Place Qwen Image 2.1 Reference Strength after your model and LoRA loaders, then connect its MODEL output to the sampler.

Load Diffusion Model -> LoRA loaders (optional) -> Reference Strength -> sampler

Connect your reference images and VAE to Text Encode Qwen Image 2.1 or the included Phrase Weights encoder.

InputDefaultDescription
model—Qwen Image 2.1 MODEL, including any applied LoRAs.
reference_index1Reference to adjust: 1 is the first connected image, 2 is the second, and so on.
strength1.2Attention-odds multiplier for the selected reference.
StrengthBehavior
1.0Native reference weighting.
Above 1.0Increases reference priority.
Between 0.0 and 1.0Reduces reference priority.
0.0Blocks direct attention to the selected reference's latent tokens. Information about it can remain elsewhere in the conditioning.

Reference selection follows the encoder's connected-image order; empty inputs are skipped. The adjustment applies to the whole reference image.

Chain nodes to adjust multiple references. Repeating an index replaces its earlier strength. Setting that index's strength to 1.0 removes its adjustment.

Phrase Weights

Use Qwen Image 2.1 Edit — Phrase Weights in place of the native Text Encode Qwen Image 2.1 node.

Connect your Qwen Image 2.1 CLIP, reference images, and VAE. Send the positive, negative, and latent outputs to the sampler. The model follows its normal path to the sampler; this encoder does not require a MODEL connection.

Syntax

Wrap a word or phrase in parentheses followed by a colon and a nonnegative weight:

Add (warm lighting:1.3) and (soft shadows:1.1).
WeightBehavior
1.0Native phrase weighting.
Above 1.0Increases phrase priority.
Between 0.0 and 1.0Reduces phrase priority.
0.0Strongly suppresses attention to the selected phrase tokens.

Positive and negative prompts have independent weights. Only the marked occurrence of a phrase receives the adjustment. Use complete words or phrases in separate, non-nested sections.

Controls and outputs

Input/outputDescription
clipNative Qwen Image 2.1 text encoder, loaded with CLIP type qwen_image.
promptPositive prompt with optional weighted phrases.
negative_promptNegative prompt with its own optional weighted phrases.
vaeNative Qwen Image 2.1 VAE. Required when combining with Reference Strength.
resolutionReference resizing target. Default 1024; 0 keeps references near their original dimensions, rounded to multiples of 32.
imagesReference images; additional sockets appear as needed.
positive, negativeConditioning outputs for the sampler.
latentEmpty latent sized from the first reference after resizing.
phrase_reportOptional JSON text report showing the clean prompts, weights, and selected token rows.

Using Both Nodes

Connect Reference Strength to the sampler's MODEL input and Phrase Weights to its conditioning and latent inputs:

MODEL -> Reference Strength -------------------------> sampler MODEL

CLIP + VAE + images -> Phrase Weights
                           |------------------------> sampler positive
                           |------------------------> sampler negative
                           `------------------------> sampler latent_image

Adjust one control at a time while keeping other settings fixed to compare its effect.

How It Works

Both nodes adjust attention scores inside the native Qwen Image 2.1 transformer. For a positive weight w, the selected scores receive log(w) before softmax, changing their relative attention priority while retaining normalization.

Reference Strength selects reference-image keys. Phrase Weights selects the text keys belonging to marked phrases and carries their weights with the conditioning. Text embeddings and reference pixels are not rescaled or composited into the output. Native prefix caching is preserved.

Weights control attention priority, so a value of 2.0 does not imply twice the visible effect. Large values can dominate other instructions or references and reduce editing flexibility.

Compatibility

  • Requires the native Qwen Image 2.1 implementation.
  • Attention backends must support additive masks.
  • Phrase mapping requires whole tokenizer pieces and does not support textual-inversion embeddings.
  • Changes to conditioning token rows after phrase encoding can invalidate the mapping.

License

MIT.

Languages

Python

100.0%