Nodes/ComfyUI Flux Trainer/TrainDatasetAdd
ComfyUI Node

TrainDatasetAdd

Point FluxTrainer at your images

By kijai·Created 2 years ago·Updated about a year ago· 1,157
TrainDatasetAdd
  • dataset_config
  • regularization
  • dataset
width1024
height1024
batch_size2
dataset_path
class_tokens
enable_buckettrue
bucket_no_upscalefalse
num_repeats1
min_bucket_reso256
max_bucket_reso1024

This is where your training data enters the graph. TrainDatasetAdd takes a folder of images (and their caption files), plus the resolution and batching rules to train them at, and turns all of that into the dataset config the rest of ComfyUI-FluxTrainer consumes. If FluxTrainer is a car, this is where you load the passengers - nothing trains until this node knows where your pictures are.

The name has "Add" in it for a reason: you can stack more than one of these to build a dataset out of several folders, each with its own resolution and repeat count. Most people start with one and never need more, but the door's open.

How it works

It reads a base config coming into dataset_config (the global settings from a TrainDatasetGeneralConfig node), then appends a subset: a folder path, a resolution, how many times to repeat those images per epoch, and the bucketing rules. Bucketing is the thing that lets a folder of mixed aspect ratios train together - instead of forcing everything to a square crop, it sorts images into resolution "buckets" so a portrait and a landscape can both keep their framing. The output dataset (JSON) carries all of that forward to the training loop.

The inputs that matter

There are a lot of knobs here, but a beginner really only needs a handful:

  • dataset_path - the folder holding your training images and matching .txt caption files. This is the input people get wrong most often (see below).
  • class_tokens - your trigger word / activation tag. A rare token like ohwx or ch9ractername that won't collide with real vocabulary, prepended to captions so the model has a handle to summon the concept.
  • num_repeats - how many times each image is seen per epoch. This multiplies into your total step count (images × repeats × epochs), so it's a real lever, not a formality.
  • width / height - the training resolution, 1024×1024 by default. batch_size - how many images per step (default 2); higher is smoother but eats VRAM.

The bucketing inputs - enable_bucket (on by default, keep it), bucket_no_upscale, min_bucket_reso, max_bucket_reso - control that mixed-aspect-ratio handling. The defaults are sane for a first run. There's also an optional regularization input that accepts a subset from TrainDatasetRegularization if you're using reg images to fight overfitting.

Installing ComfyUI-FluxTrainer

ComfyUI Manager: search "ComfyUI Flux Trainer", install, restart. Manual install:

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

Restart ComfyUI. Torch 2.4.0+ recommended. The example workflow uses ComfyUI-KJNodes.

Common issues

The dataset path is the classic trap. The number one FluxTrainer help thread is someone whose training won't start because the trainer can't find their images - and the fix is almost always about where the folder lives and how the path is written. One user hit exactly this on Windows and only got unstuck by moving the dataset inside the ComfyUI directory tree and pointing at it from there. If your run errors immediately with a folder/file complaint, that's your first suspect: check the path is correct, absolute if in doubt, and that your .txt captions sit right next to the images with matching filenames.

Captions matter more than any slider here. The whole training community agrees curation and captioning beat every knob. Describe what you want to stay variable (clothing, pose, background) and leave what should be fixed (the identity itself) undescribed, so the trigger word absorbs it. Bad or lazy captions will sink a run that has perfect settings.

Watch your step math. num_repeats quietly multiplies your total steps. Crank it without adjusting epochs and you can blow straight past the sweet spot into overfitting - outputs that look like photocopies of your training set. For a small character dataset, keep repeats modest and let the total land in the low thousands of steps.

CategoryFluxTrainer

Inputs (12)

NameTypeDefaultDescription
dataset_configJSON
widthINT1024base resolution width
heightINT1024base resolution height
batch_sizeINT2Higher batch size uses more memory and generalizes the training more
dataset_pathSTRINGpath to dataset, root is the 'ComfyUI' folder, with windows portable 'ComfyUI_windows_portable'
class_tokensSTRINGaka trigger word, if specified, will be added to the start of each caption, if no captions exist, will be used on it's own
enable_bucketBOOLEANtrueenable buckets for multi aspect ratio training
bucket_no_upscaleBOOLEANfalsedon't allow upscaling when bucketing
num_repeatsINT1number of times to repeat dataset for an epoch
min_bucket_resoINT25664–4096min bucket resolution
max_bucket_resoINT102464–4096max bucket resolution
regularizationoptJSONreg data dir

Outputs (1)

NameTypeDescription
datasetJSON