TF Tokens Preview
The sanity check that stops Trajectory Forcing edits from doing nothing
- tokens
- image
- coords
When an edit in a Trajectory Forcing workflow "does nothing," the problem is almost never the model. It's that your selection wasn't where you thought it was. TF Tokens Preview is the node you add to catch that before it costs you another GPU run.
Here's the context. This pack wraps Trajectory Forcing, a research method (ECCV 2026) that builds an image in four coarse-to-fine passes through a hierarchical DINOv2 latent space instead of one full diffusion denoise. Every intermediate level decodes to a picture, which is what makes editing possible at all: you pick a set of tokens, replace their feature vectors, and re-sample only the levels above the edit. But every edit starts from a selection - a handful of cells on a 16×16 token grid that no normal ComfyUI mask tool knows about. Selections get built by mask painting, by clicking a grid, by typing coordinates, or by snapping a stroke onto whole regions, and all of those can quietly produce something other than what you meant. That's where this node comes in: it draws the selection on its own so you can actually look at it.
How it works
The nice part is how cheap it is. The node takes a TF_TOKENS input - a TokenSelection, which is basically a boolean mask over the token grid plus a note about where it came from - and renders it with numpy and PIL, no pipeline, no model, no JAX. The source draws the selected cells in a red tint with borders on a dark background, overlays the grid lines, and numbers every fourth row and column so the row,col notation maps to something you can see. It even shows the result in its own node body ("N tokens: ..."), so you don't need a Preview Image node hanging off it just to read it.
The inputs and outputs that matter
-
tokens - the selection to draw. Wire it from TF Tokens From Mask, TF Tokens From Coords, TF Tokens Combine, or anything else that emits
TF_TOKENS. -
size (advanced, default 512, 128–2048) - how many pixels wide to render the grid. Leave it unless you want a bigger or smaller readout.
-
image - the rendered preview, if you want it in a Preview or Save node.
-
coords - the selection written out in the pack's coordinate text, like
7,6:9. The comment in the source says it deliberately matches the notation someone would have typed, runs collapsed, so it pastes straight back into TF Tokens From Coords. That's the round-trip that keeps a selection quotable in a writeup.
Where it slots in: after you build a selection and before it reaches TF Feature Edit or TF Shape Edit. Workflow 02-feature-edit-coords has this exact shape - the README's own troubleshooting says that when an edit appears to do nothing, check the "what was selected" preview first, because most of the time the selection isn't where you thought.
Installing it
Real talk about this pack: it's heavy and it's unusual. The README is upfront that a ComfyUI Manager install (search Trajectory Forcing, or git clone https://github.com/korayulusan/ComfyUI-TrajectoryForcing into custom_nodes) registers the nodes but usually does not finish the job. The pack runs a JAX model inside the ComfyUI process, and its JAX stack only coexists with ComfyUI's torch on CUDA 12 at torch 2.8 or above - so requirements.txt is deliberately empty, to stop Manager from rewriting the torch your other nodes depend on. Most current ComfyUI builds ship CUDA 13, which the pinned jax 0.4.36 can't use, so expect install.py to decline and point you at building a separate Python 3.11 venv with env/setup.sh. Budget roughly 11 GB for that environment, another ~13 GB of weights fetched on first use, and an 8 GB VRAM card minimum. TF Tokens Preview itself is pure CPU, so it'll run even before the JAX stack is happy - but it's not a reason to install this pack alone. It's the debugging habit you adopt inside an install you're committing to.
When it saves you
Two failure modes this node catches cleanly. Empty selection: the body reads 0 tokens: (none), which beats discovering it two nodes later at TF Feature Edit, where it reads as a crash. Wrong spot: a mask stroke that clipped a token's corner, or a region map snapped at a different level than the one you're editing - the preview shows the mismatch instantly. And if you ever need to verify that a typed coordinate string means what you think, run it through here and read the coords output back.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tokens | TF_TOKENS | — | |
| size | INT | 512128–2048 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| coords | STRING | — |