ComfyUI-Flux2Klein9Mod
Refmod for Flux2 Klein9
Nodes (4)
Stop Re-Encoding Your References on Every Single Run
Turn a Pile of Reference Photos Into One Reusable Latent File
It Reads Your Disk, and the Default Path Is the Author's
Eight Slots, Three Dials, and a Dropdown That's Empty Until It Isn't
ComfyUI-Flux2Klein9Mod
No-training "RefMod" reference adapters for FLUX.2 and Klein9.
RefMods pre-encode reference images and datasets into compact, reusable .safetensors adapters stored in models/refmods-klein9/. Rather than loading and VAE-encoding raw 4K/1024px image files on every generation run (which adds 4096+ tokens and heavy attention latency), RefMods inject pre-computed reference latents directly into the FLUX.2 / Klein9 2D RoPE sequence with instant loading, zero VAE overhead, and full multi-character scaling.
π Links & Resources
- More Info & Documentation: Hugging Face Dataset (klein9)
- RefMods Library Browser: RefMods Browser on Hugging Face Spaces
π¦ Features
- Pre-encoded Latent Storage: Stored in
ComfyUI/models/refmods-klein9/. - Zero VAE Generation Latency: Latents are loaded directly from disk without runtime VAE encoding.
- Configurable Token Budgets: Native resolution or spatial pooling to target budgets (e.g. 512, 1024, 2048 tokens).
- Multi-Subject Scaling: Load up to 8 distinct RefMods simultaneously (
mod_1throughmod_8) with independent strengths. - Manifold Blending: Smooth weakening and strength attenuation using spatial low-pass filtering along the latent manifold instead of noise degradation.
- Universal Compatibility: Works with any standard ComfyUI
CONDITIONINGgraph for FLUX.2, Klein 4B, Klein 8B, and Klein 9B models.
π Installation
- Navigate to your ComfyUI
custom_nodesfolder:cd ComfyUI/custom_nodes - Clone or place this repository:
git clone https://github.com/malcolmrey/ComfyUI-Flux2Klein9Mod.git - Ensure the model folder exists:
ComfyUI/models/refmods-klein9/ - Restart ComfyUI.
π§© Nodes
| Node Name | Category | Description |
| :--- | :--- | :--- |
| Load Klein9 RefMods (FLUX.2) (Klein9RefModsLoader) | model/conditioning/klein9 | Loads 1β8 RefMod .safetensors files from models/refmods-klein9/ with individual strengths (0.0β3.0) and repeat counts. |
| Apply Klein9 RefMods (FLUX.2) (Klein9RefModApply) | model/conditioning/klein9 | Injects the loaded RefMod bundle into standard ComfyUI CONDITIONING (reference_latents). |
| Extract Klein9 RefMod (FLUX.2) (Klein9RefModExtract) | model/conditioning/klein9 | In-graph VAE encode & token compression of input images directly into a saved .safetensors file in models/refmods-klein9/. |
| Load RefMod Folder (Images) (Klein9RefModFolderLoader) | model/conditioning/klein9 | Batch loads an entire folder of reference images for extraction. |
π οΈ Graph Wiring
[ CLIPTextEncode ] (Prompt)
β
βΌ
[ Apply Klein9 RefMods (FLUX.2) ] βββ [ Load Klein9 RefMods (FLUX.2) ]
β (conditioning out) (Selects models from models/refmods-klein9/)
βΌ
[ CFGGuider / SamplerCustomAdvanced ]
π» CLI Extraction Tool
You can also pre-encode image datasets using the CLI:
python custom_nodes/ComfyUI-Flux2Klein9Mod/extract_klein9_mod.py \
--name fk9_billieeilish_v1_refmod \
--dataset-dir C:/Development/ai-toolkit/datasets/billieeilish \
--concept-type identity \
--token-budget 1024 \
--output-dir C:/Development/ComfyUI/models/refmods-klein9/