🧬 COF Identity Weights · Reference Latents (RefMods)
A file-drop node that puts pre-encoded refs where a loader can find them
- cof
- paths
- base_models
The odd one out - and that's the point
Most of this pack hands you tensors. This one hands you file paths.
COF Reference Latents exports the preset's pre-encoded reference weights - the reference-latent kind inside a .cof, which the author's own docstring names as MiniMax H3's RefMods - into a models folder, and returns where they landed plus which base model each one is for. That's it. No tensor output, no IMAGE, no MODEL. You run it, it writes files, and then a different node picks them up from its own dropdown.
If that sounds anticlimactic, consider what the alternative is. Encoders that produce a precomputed identity conditioning blob - the "encode once, reuse everywhere" family that lives between IP-Adapter-style injection and a full LoRA - expect that blob to sit in a models directory, indexed at node-import time. Which means a two-step dance: export the file, then refresh the loader that lists it. This node is the first half.
How it works
The reader filters the preset's identity weights to kind reference-latent, and for each one that has an embedded asset, extracts it to:
ComfyUI/models/<folder>/cof/<cof-file-stem>/
folder is a plain STRING widget, default refmods, and it's sanitised to [A-Za-z0-9_.-] before use - so refmods gives you models/refmods/cof/clara-mercier/…. The per-file subfolder is deliberate: two characters can ship identically-named reference files and not collide.
It refuses to extract anything that isn't on its whitelist of loadable formats - weights, audio, images, motion clips, 3D meshes - and it validates the .safetensors header before writing, so a truncated archive fails loudly instead of producing a file that crashes your sampler three nodes later. If the character is a real person without a consent record in the file, you get a console warning, same as the LoRA node.
Inputs and outputs
Required: cof, folder (STRING, default refmods).
paths- newline-separated absolute paths of the exported files. Wire into Preview Any to copy one, or into any node that takes a path string.base_models- one line per file, the base model each reference was built against (?if the file doesn't say).
Those two lines up, and they're a matched pair by index. That's your sanity check: if base_models says something your checkpoint isn't, stop here. A reference latent encoded against a different model family is noise, not a weak hint.
Note what's missing: no count, no labels, no image. This is the thinnest node in the pack, and if you were hoping it would also apply the references, it doesn't. Applying them is the job of whichever loader consumes that folder.
Install
No dependencies - pack pyproject.toml declares none - and nothing to download beyond the .cof itself.
cd ComfyUI/custom_nodes
git clone https://github.com/yannsouetre/ComfyUI-COF
mkdir -p ComfyUI/models/cof
cp your-character.cof ComfyUI/models/cof/
Restart, press R for new files. The workflow to see this one is the package's own cof_preview set, minus this node - it needs a model-consuming pipeline to show anything, which is why the preview workflow leaves the identity-weight nodes to cof_txt2img_api.json.
Common issues
paths is empty. The preset has no reference-latent weights. Files with a LoRA instead of a reference latent are common; this node ignores lora, lycoris and dora entirely, and COFApplyLoRA is the node for those.
The exported files exist but the loader's dropdown doesn't show them. Model folder lists in ComfyUI are built at import and cached. Restart ComfyUI (a plain refresh often isn't enough for a folder listing, unlike the .cof file list which has its own live route), then check the loader again.
You changed folder and the old files are still around. Nothing cleans up after you. The node only writes; delete models/<old-folder>/cof/<stem>/ yourself, or you'll end up with three copies and no idea which one your workflow is reading.
Base model row says ?. The file didn't declare one. That's not a bug, it's a hole in the .cof, and you'll have to work out compatibility by trial - or ask whoever built the file.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| cof | COF | — | |
| folder | STRING | refmods | models subfolder to export to |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| paths | STRING | — |
| base_models | STRING | — |