Nodes/ComfyUI Neural Network Toolkit NNT /NNT Visualize Training Metrics
ComfyUI Node

NNT Visualize Training Metrics

Watch your loss and accuracy bend as you train

By inventorado·Created 2 years ago·Updated 2 years ago· 69
NNT Visualize Training Metrics
  • metrics
  • IMAGE
  • STRING
image_width1024
image_height768
plot_typecombined

A training run without a loss curve is just trusting the process. NNT Visualize Training Metrics turns the metrics dict that NntTrainModel produces into actual plots - loss, accuracy, learning rate, batch losses - rendered as a ComfyUI IMAGE you can preview or save. It's the closest thing this pack has to a TensorBoard, and for the "watch the model learn" experience that's the whole point of the toolkit, it's the finishing touch on every workflow.

In practice this is the node you wire right after NntTrainModel: train a few epochs, and this draws what happened. If loss is flat, you'll see it immediately. If the curve is jagged or the accuracy is stuck, you'll see that too - and you'll know to touch the learning rate or the architecture before wasting more runs.

How it works

The metrics input is the DICT from NntTrainModel (keys: loss, accuracy, learning_rates, batch_losses, epoch_times, plus best-loss/best-accuracy). Pick a plot_type:

  • loss - training loss per epoch. The single most useful curve in ML.
  • accuracy - training accuracy per epoch.
  • combined - loss and accuracy side by side (well, stacked). The default.
  • learning_rate - how your scheduler moved the learning rate over training. Insightful once you realize your "loss plateau" is just a scheduler step.
  • all_metrics - a 2×2 grid: loss, accuracy, learning rate, and batch losses all at once.
  • loss_with_lr - loss with the learning rate on a twin axis, so you can literally see the correlation between LR steps and loss movement.

image_width/image_height (default 1024×768) size the figure, and it renders at 100 DPI via matplotlib, converted to a ComfyUI IMAGE. There's also a STRING output with the summary.

How to read it like you mean it

This node is a teaching tool, so here's the lesson it's designed to teach. If loss falls fast then flattens, and accuracy flattens right along with it, the classic culprits are: learning rate too high (loss plateaus or oscillates), too low (loss barely moves), or the network is too small for the problem. Compare loss against loss_with_lr and you'll see whether the scheduler is helping or hurting. And if loss drops but accuracy stays flat, your model is memorizing the training set without generalizing - which is exactly the kind of thing a learning pack should make obvious.

One caveat: these are training metrics - the pack doesn't compute validation loss here. A curve that looks great can still overfit; that's what NntVisualizePredictionMetrics on a held-out set is for. Use this node to watch training, and the other one to judge the model.

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"). Needs matplotlib (in requirements). Full install is heavy - torch, numpy, pandas, sklearn, transformers, statsmodels, onnx, shap 0.41.0, and friends - so the first run takes a while. It's the last node you add and the one that makes the whole pack feel like a real training setup.

CategoryNNT Neural Network Toolkit/Models

Inputs (4)

NameTypeDefaultDescription
metricsDICT
image_widthINT1024256–4096
image_heightINT768256–4096
plot_typeCOMBOcombined6 options: loss, accuracy, combined, learning_rate, all_metrics, loss_with_lr

Outputs (2)

NameTypeDescription
IMAGEIMAGE
STRINGSTRING