ComfyUI Node

Visualize Loss

Plot the training loss curve right in your graph

By kijai·Created 2 years ago·Updated about a year ago· 1,156
Visualize Loss
  • network_trainer
  • plot
  • loss_list
plot_styledefault
window_size100
normalize_ytrue
width768
height512
log_scalefalse

Loss is the number that tells you whether training is actually going anywhere, and VisualizeLoss turns that stream of numbers into a chart you can read at a glance. Instead of squinting at console logs scrolling past, you get an actual loss curve as an image node in your graph. Feed it your trainer, get back a plot.

A quick caveat, because it saves grief: in diffusion LoRA training, loss is noisy and only loosely tracks quality. A falling curve is reassuring, but the real judge of a LoRA is the preview images from FluxTrainValidate, not the loss line. Use this to catch obvious problems - loss flat-lining, or exploding - not to fine-tune quality.

How it works

VisualizeLoss takes the network_trainer (NETWORKTRAINER), reads the loss values recorded so far, and renders them. Outputs are a plot (IMAGE) you wire to a Preview Image node, and the raw loss_list (FLOAT) if you want the numbers for something else.

The inputs that matter for readability:

  • window_size (default 100) - a moving-average smoothing window. Raw per-step loss is jagged; averaging over ~100 steps turns the mess into a trend you can actually read. This is the knob you'll adjust most.
  • log_scale (default false) - plots loss on a log axis, which helps when values span a wide range.
  • normalize_y (default true) - scales the y-axis to fit.
  • width / height - the plot image size.
  • plot_style - matplotlib styling (ggplot, dark_background, fivethirtyeight, and a couple dozen more). Purely cosmetic; pick whatever's easy on your eyes.

Reading the curve

What you want is a curve that trends down and then flattens. A flat line from the start usually means the learning rate is too low or something isn't wired right; a curve that shoots up means it exploded (too high an LR, or a bad optimizer for the base - Chroma is notorious for this). Beyond spotting those failure modes, don't over-read it. The step where loss looks lowest is not reliably your best checkpoint - that call belongs to the validation previews.

Installing the pack

ComfyUI Manager: search ComfyUI Flux Trainer, install, restart. Or:

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

Torch 2.4.0+ recommended, plus kijai's ComfyUI-KJNodes for the example workflows.

Common issues

The plot looks like static. That's raw, unsmoothed loss - it's genuinely that noisy. Raise window_size to smooth it into a readable trend.

Loss went down but the LoRA is bad. Loss and quality aren't the same thing in diffusion training. Low loss can coincide with an overfit, memorized LoRA. Trust the validation images over the curve.

Nothing to plot early on. With only a handful of steps recorded there's barely a curve to draw. Let training accumulate some steps before expecting a meaningful chart.

CategoryFluxTrainer

Inputs (7)

NameTypeDefaultDescription
network_trainerNETWORKTRAINER
plot_styleCOMBOdefaultmatplotlib plot style
window_sizeINT1000–10000the window size of the moving average
normalize_yBOOLEANtruenormalize the y-axis to 0
widthINT768256–4096width of the plot in pixels
heightINT512256–4096height of the plot in pixels
log_scaleBOOLEANfalseuse log scale on the y-axis

Outputs (2)

NameTypeDescription
plotIMAGE
loss_listFLOAT