Save 4 hours! We auto-setup your workflow! Free!

Drop your workflow.json — we handle every dependency, custom node, and model. Just open the link and run.

Auto-Setup Workflow Json (Free) Now!
ComfyUI > Nodes > ComfyUI-qwen_img_2_1_enhancer > Qwen Image 2.1 Reference Strength Masked

ComfyUI Node: Qwen Image 2.1 Reference Strength Masked

Class Name

QwenImage21ReferenceStrengthMasked

Category
model/patch/qwen image
Author
capitan01R (Account age: 276days)
Extension
ComfyUI-qwen_img_2_1_enhancer
Latest Updated
2026-10-10
Github Stars
0.04K

How to Install ComfyUI-qwen_img_2_1_enhancer

Install this extension via the ComfyUI Manager by searching for ComfyUI-qwen_img_2_1_enhancer
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI-qwen_img_2_1_enhancer in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Qwen Image 2.1 Reference Strength Masked Description

Enhances attention mechanism in image processing models by adjusting reference strength on selected tokens through a mask.

Qwen Image 2.1 Reference Strength Masked:

QwenImage21ReferenceStrengthMasked is a specialized node designed to enhance the attention mechanism in image processing models by applying reference strength to specific source tokens selected through a mask. This node is particularly useful in scenarios where you want to emphasize or de-emphasize certain areas of a reference image during the diffusion process. By allowing you to adjust the attention strength on selected tokens, it provides a nuanced control over how much influence a reference image has on the final output. The node also offers flexibility in resizing the mask to match the encoded reference dimensions, ensuring that the attention is applied accurately. This capability is crucial for artists and designers who wish to maintain or alter specific visual elements in their creative projects, making it a powerful tool for fine-tuning image generation processes.

Qwen Image 2.1 Reference Strength Masked Input Parameters:

model

This parameter represents the model to which the node will be applied. It is essential for ensuring that the node operates within the correct framework, specifically requiring the native Qwen Image 2.1 model. The model serves as the foundation upon which the reference strength adjustments are made.

mask

The mask parameter allows you to specify which parts of the reference image should be affected by the reference strength adjustments. It should be painted on the selected reference photo with the same proportions and uses the first mask batch item. The mask is crucial for targeting specific areas of the image, and its coverage is averaged over each reference token's footprint. The mask must be nonempty and have a shape of either [H,W] or [B,H,W].

reference_index

This integer parameter determines which reference image is being targeted, with a default value of 1. It ranges from 1 to 16, corresponding to the order of nonempty encoder inputs. This index allows you to chain nodes for independent reference settings, and repeating an index will replace the node's earlier rule.

strength

The strength parameter is a float that controls the attention multiplier on selected tokens, with a default value of 4.0. It ranges from 0.0 to 64.0, with higher values indicating stronger attention and lower values indicating weaker attention. A value of 1 represents the native attention strength, while 0 blocks direct target attention. This parameter is key to adjusting the influence of the reference image.

mask_resize_method

This parameter specifies the method used to resize the source mask to the actual encoded reference pixel size before pooling 16x16 tokens. It offers two options: "nearest-exact" and "lanczos," with "nearest-exact" as the default. This choice affects how accurately the mask aligns with the reference image, ensuring that the attention is applied correctly.

mask_threshold

The mask_threshold parameter is a float that determines the threshold for mask application, with a default value of 1.0. It must be between 0 and 1, and it influences which parts of the mask are considered active. This threshold is important for fine-tuning the areas of the image that receive attention adjustments.

mask_behavior

This parameter defines the behavior of the mask, with options "focus_only" and "zero_unmasked_tokens." It dictates how unselected reference tokens are treated as attention sources throughout the diffusion transformer. This choice is crucial for controlling the overall impact of the mask on the image processing.

Qwen Image 2.1 Reference Strength Masked Output Parameters:

model

The output parameter is the modified model with the applied reference strength adjustments. This model reflects the changes made by the node, incorporating the specified attention modifications based on the input parameters. It serves as the basis for further image processing or generation tasks, allowing you to see the effects of the reference strength adjustments in the final output.

Qwen Image 2.1 Reference Strength Masked Usage Tips:

  • Ensure that the mask is correctly aligned with the reference image by choosing the appropriate mask_resize_method. Use "nearest-exact" for external resizing and "lanczos" for native encoder resizing.
  • Experiment with different strength values to achieve the desired level of influence from the reference image. Start with the default value and adjust as needed to emphasize or de-emphasize specific areas.
  • Use the reference_index to target specific reference images when working with multiple inputs. This allows for precise control over which image's influence is being adjusted.

Qwen Image 2.1 Reference Strength Masked Common Errors and Solutions:

"Reference Strength Masked requires the native Qwen Image 2.1 model."

  • Explanation: This error occurs when the node is applied to a model that is not the native Qwen Image 2.1 model.
  • Solution: Ensure that you are using the correct model type before applying this node.

"Reference indices start at 1: <image1>, <image2>, and so on."

  • Explanation: The reference index provided is less than 1, which is not valid.
  • Solution: Adjust the reference_index to be within the valid range of 1 to 16.

"Reference strength must be finite and nonnegative."

  • Explanation: The strength parameter is either not a finite number or is negative.
  • Solution: Ensure that the strength value is a finite, nonnegative number within the specified range.

"Mask threshold must be between 0 and 1."

  • Explanation: The mask_threshold value is outside the valid range.
  • Solution: Adjust the mask_threshold to be within the range of 0 to 1.

"Choose focus_only or zero_unmasked_tokens."

  • Explanation: An invalid mask_behavior option was selected.
  • Solution: Select either "focus_only" or "zero_unmasked_tokens" for the mask_behavior parameter.

"Connect a nonempty MASK with shape [H,W] or [B,H,W]."

  • Explanation: The mask provided is either empty or not in the correct shape.
  • Solution: Ensure that the mask is nonempty and has the correct shape before applying it to the node.

Qwen Image 2.1 Reference Strength Masked Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-qwen_img_2_1_enhancer
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Qwen Image 2.1 Reference Strength Masked