Skip to main content

Two approaches to dataset organization

sd-scripts supports two complementary dataset styles. You can use either one, or mix them in the same training run by defining them as separate [[datasets]] entries in your config file.

DreamBooth style

Point to an image directory and supply class tokens (e.g. sks dog). Caption .txt files are optional — if no caption file exists for an image, the class tokens are used automatically.

Fine-tuning style

Point to an image directory and a JSON metadata file that maps each image to its caption and tags. Gives you precise per-image control and is required when using pre-generated metadata from scripts like merge_captions_to_metadata.py.
The key difference is how captions are supplied:
When mixing both styles in one training run, each style must live in its own [[datasets]] block. You cannot mix DreamBooth and fine-tuning subsets within the same dataset.

Datasets and subsets

A dataset is a group of images that share training settings like resolution and batch_size. A subset is a partition of a dataset — typically a single image directory.
Settings cascade from [general] → [[datasets]] → [[datasets.subsets]]. More specific settings always win. This lets you set shuffle_caption = true globally and override it for one subset that should not shuffle.

Directory structure

Images must be placed directly inside the directory you specify as image_dir. Sub-directories are not automatically traversed (use --recursive only when generating tags). A common convention is to prefix folders with a repeat count:
The folder-name prefix (e.g. 5_dog) is a human convention — the scripts do not parse it automatically when using a TOML config file. Set num_repeats and class_tokens explicitly in your config.
When running scripts in the legacy command-line mode (without --dataset_config), the N_token folder-name convention is parsed automatically. In TOML config mode you have full explicit control.

Caption file format

For DreamBooth-style subsets, place a caption file next to each image with the same base name:
Caption files contain plain text. The default separator between tags is , . A caption can span multiple lines when enable_wildcard = true — one line is then selected randomly per training step.
Use the WD14 Tagger to generate caption .txt files automatically from your images.

Aspect ratio bucketing

By default, all images are resized to the square resolution you specify (e.g. 512 or 1024). Enabling aspect ratio bucketing lets images keep their original proportions by grouping them into resolution buckets and padding or cropping minimally. Enable it in your dataset config:
Aspect ratio bucketing is strongly recommended for real-photograph datasets and any mixed-orientation image sets. It significantly reduces distortion from forced squaring.

Next steps

Dataset configuration

Full reference for the TOML config file format, including all dataset and subset options.

Automatic image tagging

Use WD14 Tagger to generate per-image caption files automatically.