Nodes/ComfyUI-ClipReshaper/Clip Reshaper: Linear Project Dim
ComfyUI Node

Clip Reshaper: Linear Project Dim

A learnable CLIP-to-CLIP projector — useful only if you bring the weights

By thezveroboy·Created 9 months ago·Updated 9 months ago· 2
Clip Reshaper: Linear Project Dim
  • conditioning
  • CONDITIONING
target_dim1280
weights_path
biastrue

Of the five nodes in this pack, Clip Reshaper: Linear Project Dim is the one with actual ambition, and also the one most likely to disappoint you if you expect it to work out of the box. It's a learned linear projection: a torch.nn.Linear layer that maps your conditioning embeddings from their current dimension to a target_dim. The thing is, a linear layer has to be trained to be meaningful. With no weights loaded, you get a randomly-initialized matrix, which means your conditioning gets multiplied by noise and comes out the other side as garbage of the correct shape.

That's not an oversight. The author says so in the code comments and the README: without trained weights this is "mainly an experimental tool or infrastructure for future CLIP-to-CLIP adapters." This node is the inference half of an adapter you're supposed to train yourself, or load from disk. The promise is the interesting part - a genuine learned mapping between two embedding spaces, e.g. 768-dim SD 1.5 CLIP conditioning projected into 1280-dim SDXL space in a way that (once trained) preserves meaning, unlike the blunt CR_ConditioningPadOrSlice hack.

How it works

The mechanism: the node reads the input dimension from the first conditioning item, builds nn.Linear(d_in, target_dim, bias=...), and - here's the key input - optionally loads weights from weights_path. It accepts a state dict saved with torch, either as a flat {'weight': ..., 'bias': ...} or nested under a {'layer': ...} key. Each conditioning item is then pushed through the layer, moved to the item's own device and dtype so mixed precision doesn't bite you.

Inputs to set

Inputs to set:

  • target_dim (INT, default 1280) - where you're projecting to.
  • weights_path (STRING, default empty) - the trained adapter file. Empty means random init, which you almost never want for real use.
  • bias (BOOLEAN, default true) - whether the layer includes a bias term.

Single output: the reshaped CONDITIONING, metadata carried through.

The weights file is where you need a plan. There's no training loop in this pack - you'd train the adapter separately (any PyTorch setup that saves {'weight': ..., 'bias': ...} works) and point weights_path at it. If the path doesn't exist you get a clear FileNotFoundError; if the dict has the wrong keys, an "Unsupported weights format" error. Both are the sort of explicit failure you want from a node like this.

The blunt truth

The blunt truth, same as the rest of this pack: this is scaffolding from a niche author, and there's no community-trained adapter ecosystem for it - zero real-world signal that anyone has shipped weights for it. If you're just trying to make a dimension mismatch go away, CR_ConditioningPadOrSlice is faster and this is overkill; if you're serious about a real cross-encoder adapter, this gives you the plumbing but the actual learning is on you. For that narrow, patient user - someone building toward a real CLIP-to-CLIP bridge - it's a tidy, dependency-free piece of the puzzle.

Install

Installation is the pack standard:

cd ComfyUI/custom_nodes
git clone https://github.com/thezveroboy/ComfyUI-ClipReshaper

or ComfyUI Manager → search "Clip Reshaper" → install, then restart. No pip dependencies, no models to fetch. Just remember the one rule this node lives by: the projector is only as good as the weights you give it, and random weights are worse than no change at all.

CategoryClip Reshaper

Inputs (4)

NameTypeDefaultDescription
conditioningCONDITIONING
target_dimINT12801–65536
weights_pathSTRING
biasBOOLEANtrue

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING