Nodes/ComfyUI-TrajectoryForcing/TF Tokens From Coords
ComfyUI Node

TF Tokens From Coords

Edit targets you can write down, paste, and reproduce

By KorayUlusan·Created 3 days ago·Updated about 21 hours ago· 1
TF Tokens From Coords
  • levels
  • regions
  • tokens
  • info
coords

Every edit in this pack comes down to choosing tokens on a 16×16 grid, and TF Tokens From Coords is the most exact way to make that choice: click the grid, or type coordinates, and out comes a tokens selection. The reason this node exists alongside the painting route isn't convenience - it's quotability. A selection made with a brush exists nowhere except as pixels in a mask. A selection made here is text, and text is what survives in a writeup, a GitHub issue, or a workflow comparison.

The grid and the text field are two views of one value. Click cells, or drag to paint several, and the clickable grid writes into the same coords field rather than replacing it - so a selection you build by clicking stays readable as text, and text you type gets drawn on the grid. The coordinate syntax is worth learning because it's compact: 7,6 means row 7, column 6, and 7,6:9 means row 7, columns 6 through 9 - a run. A whole line reads like 3,1:5 4,2 5,3:4, which is a selection you can paste into an issue and have mean something.

The optional regions wire is where this becomes the paper's region-select rather than raw token picking. With a TF Region Map connected, one click takes the whole region containing that token - the paper's R_tgt, a semantic part rather than an arbitrary cell - and the grid draws the region boundaries so you can see what you're grabbing. The node learns the regions from the first run, so before that a click picks one token and the node expands it on re-run. Alt-click (option on a Mac) writes just that single coordinate: it doesn't narrow the selection - with a region map wired, clicking snaps to whole regions either way - but 7,7 is a much better line in a writeup than a nine-coordinate list of everything that region expanded to. Unwire regions entirely if you genuinely want sub-region tokens: sometimes the thing you want to edit is smaller than a region, and raw token selection is the way to get it.

levels is optional and only its token-grid size is read - unwired assumes 16×16, which every released checkpoint uses, so you can mostly leave it alone. Outputs are tokens (into any edit node or TF Tokens Combine) and info (the resolved selection, for checking).

Where people get tripped up, three things. Row/column numbering here is 0-based and matches the labels TF Level Canvas draws, so turn label_coords on and read numbers off the canvas instead of counting. A selection that resolves to zero tokens is the classic "edit did nothing" cause - the README's own first suspect when an edit appears inert is that the selection isn't where you thought, so check the what-was-selected preview. And with a region map wired in, remember your selection is implicitly tied to that map's level: apply it at a different level's edit and you'll get the drift error this pack is careful to raise, so wire TF Region Map's level output into the edit node to keep the two in agreement.

Install

Same pack-wide route as its siblings: Manager → search Trajectory Forcing, or git clone https://github.com/korayulusan/ComfyUI-TrajectoryForcing into custom_nodes/. The recurring caveat: JAX inside ComfyUI needs its own Python 3.11 environment on CUDA 12; requirements.txt is deliberately empty, and install.py adds the JAX stack or declines with a printed reason. Declining is a normal outcome - README's env/setup.sh builds the separate venv. When in doubt:

cd ComfyUI/custom_nodes/ComfyUI-TrajectoryForcing
python -m tf_nodes.doctor

Want to combine this selection with a painted one? TF Tokens Combine unions, intersects, or subtracts two TF_TOKENS sets - a region minus the sub-region you clicked away, exactly.

CategoryTrajectoryForcing/select

Inputs (3)

NameTypeDefaultDescription
coordsSTRINGClick the grid above, or type here -- they are the same value. '7,6:9' means row 7, columns 6 through 9.
levelsoptTF_LEVELSOnly its token-grid size is read. Unwired assumes 16x16, which is what every released checkpoint uses.
regionsoptTF_REGIONSExpand each typed token to the whole region containing it -- the editing env's cluster-select, as one click per region.

Outputs (2)

NameTypeDescription
tokensTF_TOKENS
infoSTRING