A ComfyUI custom node that implements CoMPaSS for FLUX.1-dev models. CoMPaSS enhances the spatial understanding capabilities of text-to-image diffusion models.
Paper: CoMPaSS: Enhancing Spatial Understanding in Text-to-Image Diffusion Models (ICCV 2025)
Official Repository: https://github.com/blurgyy/CoMPaSS
CoMPaSS improves how diffusion models understand spatial relationships in text prompts by adding positional encoding to the text attention mechanism. This results in better adherence to spatial descriptions like "above", "below", "left of", "right of", etc.
- Clone this repository into your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/
git clone https://github.com/blurgyy/CoMPaSS-FLUX.1-dev-ComfyUI.git-
Download the CoMPaSS weights for FLUX.1-dev from Hugging Face:
- FLUX.1-dev weights: https://huggingface.co/blurgy/CoMPaSS-FLUX.1
- Place the downloaded LoRA weights (
CoMPaSS-FLUX.1-comfyui.safetensors) in your ComfyUImodels/loras/directory
-
Restart ComfyUI or refresh your browser if ComfyUI is already running.
- Load a FLUX.1-dev model in your workflow
- IMPORTANT: Add the "CoMPaSS for FLUX.1-dev" node between your model loader and sampler
- IMPORTANT: Load the CoMPaSS LoRA weights
- Connect the model output through the CoMPaSS node
- Use the patched model for generation
The node will automatically patch the FLUX.1-dev model's attention mechanism to include CoMPaSS's spatial understanding improvements. For best results, use the official CoMPaSS LoRA weights alongside this node.
An example ComfyUI workflow is provided in example-comfyui-workflow.json. Load this
workflow to see CoMPaSS in action with a complete setup.
The following comparison demonstrates CoMPaSS's improved spatial understanding using the prompt: "A photo of a sheep below a sink"
| Image 1 | Image 2 |
|---|---|
![]() |
![]() |
| Image 1 | Image 2 |
|---|---|
![]() |
![]() |
As seen above, CoMPaSS significantly improves the model's ability to correctly position the sheep below the sink, demonstrating better spatial understanding of the text prompt.
- ComfyUI
- FLUX.1-dev model
- PyTorch
Input:
model: A FLUX.1-dev model (MODEL type)
Output:
model: The same model with CoMPaSS spatial attention patching applied (MODEL type)
Category: Conditioning
This implementation patches the DoubleStreamBlock forward method in FLUX.1-dev models
to include positional encoding in the text attention mechanism. The key modification
adds learned positional embeddings to text queries and keys while preserving the
original values, enabling better spatial relationship understanding.
If you use CoMPaSS in your research, please cite the original paper:
@inproceedings{zhang2025compass,
title={CoMPaSS: Enhancing Spatial Understanding in Text-to-Image Diffusion Models},
author={Zhang, Gaoyang and Fu, Bingtao and Fan, Qingnan and Zhang, Qi and Liu, Runxing and Gu, Hong and Zhang, Huaqi and Liu, Xinguo},
booktitle={ICCV},
year={2025}
}- Official Repository: https://github.com/blurgyy/CoMPaSS
- Project Page: https://compass.blurgy.xyz
- arXiv: https://arxiv.org/abs/2412.13195
- FLUX.1-dev Weights: https://huggingface.co/blurgy/CoMPaSS-FLUX.1



