Nodes/ComfyUI Neural Network Toolkit NNT /NNT Visualize Model Graph
ComfyUI Node

NNT Visualize Model Graph

A real picture of your network's data flow

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT Visualize Model Graph
  • MODEL
  • input_data
  • IMAGE
  • STRING
image_width1024
image_height768

You can read your model with NntShowModelInfo, but sometimes you need to see it - every tensor flowing through every operation, drawn as an actual graph. NNT Visualize Model Graph does that: it runs your model on a real input, captures the computation graph with torchviz's make_dot, renders it to an image, and hands it back as a ComfyUI IMAGE you can preview or save. For anyone learning neural networks, there is no better "oh, that's what backprop flows through" moment than watching this node paint the graph.

It's the difference between a list of layers and the actual data flow. Layer stacks tell you what's in the model; this shows you how a tensor literally transforms at every step - and the picture includes the weight tensors as leaf nodes, which is exactly what makes it click.

How it works

Two inputs drive it: MODEL and input_data (a TENSOR). The node runs a real forward pass - output = MODEL(input_data) - then builds the graph with make_dot(output, params=...), renders it to a temp PNG via graphviz, resizes it to your image_width/image_height (default 1024×768), and returns an IMAGE plus a status STRING.

Because it runs a real forward pass, input_data must have a shape your model accepts - this is a feature and a trap at once. Feed it a wrong-shaped tensor and the graph never gets drawn; the node returns an error string and a blank image. Use data from the pack's loaders or NntRandomTensorGenerator at the shape your input layer expects.

The big gotcha: graphviz the binary, not the pip package

This is the classic failure mode, and it's not the node's fault. The Python graphviz package (which the requirements install) is just bindings - the actual rendering is done by the Graphviz DOT executable, a separate system program. On many ComfyUI installs, especially Windows and fresh Linux boxes, that binary isn't installed, and dot.render() fails with something like "graphviz's executables not found" or a subprocess error.

The fix depends on your OS:

# Ubuntu / Debian
sudo apt-get install graphviz
# macOS (Homebrew)
brew install graphviz

On Windows, download and install the Graphviz binary package from the official site, and make sure its bin folder is on your PATH (or add graphviz's bin dir to PATH in your ComfyUI startup). After that, restart ComfyUI and the node works. This is the most-asked question about this node, so if your graph comes back empty, check Graphviz before anything else.

Also worth knowing: big models produce enormous graphs - a 4-layer toy net renders fine, a deep CNN makes a spaghetti monster you can't read. For learning, small models are the sweet spot, and the image_width/image_height knobs are there to help you untangle the big ones.

Install

Pack-level install:

cd ComfyUI/custom_nodes
git clone https://github.com/inventorado/ComfyUI_NNT.git
cd ComfyUI_NNT
pip install -r requirements.txt

Restart ComfyUI (or Manager → "ComfyUI Neural Network Toolkit NNT"). Requirements include graphviz and torchview - plus the system Graphviz binary above. Full install is heavy (torch, sklearn, statsmodels, transformers, onnx, shap 0.41.0, …), so budget time. The payoff is the one image that makes a whole lecture's worth of backprop diagrams legible.

CategoryNNT Neural Network Toolkit/Models

Inputs (4)

NameTypeDefaultDescription
MODELMODEL
input_dataTENSOR
image_widthINT1024256–4096
image_heightINT768256–4096

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING