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
strengthvalues 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_indexto 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_indexto be within the valid range of 1 to 16.
"Reference strength must be finite and nonnegative."
- Explanation: The
strengthparameter is either not a finite number or is negative. - Solution: Ensure that the
strengthvalue is a finite, nonnegative number within the specified range.
"Mask threshold must be between 0 and 1."
- Explanation: The
mask_thresholdvalue is outside the valid range. - Solution: Adjust the
mask_thresholdto be within the range of 0 to 1.
"Choose focus_only or zero_unmasked_tokens."
- Explanation: An invalid
mask_behavioroption was selected. - Solution: Select either "focus_only" or "zero_unmasked_tokens" for the
mask_behaviorparameter.
"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.
