Captioning

How to caption a LoRA training dataset with tags

The short answer

Give every image a plain-text caption file with the same base name (mira_001.png → mira_001.txt) that holds one line of comma-separated tags. Put a unique trigger word first, auto-tag the rest, then delete the tags that describe what the LoRA should learn and keep tags for everything you want to stay changeable. Review the whole batch tag by tag before you export. Then tell your trainer to read .txt files, because kohya-ss sd-scripts looks for .caption by default.

A LoRA learns from pairs: an image and the text that describes it. The caption decides which parts of each image get linked to your trigger word and which parts get linked to ordinary tags you can still change at prompt time. Captions are why one character LoRA can wear any outfit while another always draws the same jacket.

This guide walks through the whole job, from a folder of images to a ZIP of matching caption files, using the ImgTagger auto-tagger in your browser. Trainer settings have their own section near the end, because people use different trainers.

What a captioned dataset looks like

Almost every LoRA trainer uses the same convention. Each image has a sidecar text file with the same base name, and the trainer pairs them by name. A small character dataset looks like this:

mira_001.png
mira_001.txt
mira_002.jpg
mira_002.txt
mira_003.webp
mira_003.txt

Each .txt file holds one line of tags separated by a comma and a space:

miraoc, 1girl, solo, smile, looking at viewer, school uniform, upper body, outdoors, cherry blossoms

The file rules (matching names, encoding, separators) have their own page: caption .txt sidecar files. If your images aren't final yet, clear out duplicates and near-duplicates first with the duplicate image finder. A repeated image gets extra weight in training.

Step 1: Pick a trigger word

The trigger word is what you will type in prompts to call up your concept. It works best when the base model has no strong existing meaning for it, so a made-up word such as miraoc is safer than a real one. Avoid ordinary words and existing booru tags such as red or scarf, which already mean something to the model.

Put the trigger first in every caption, spelled exactly the same way each time. A fixed position lets trainers keep it in place when they shuffle tags (see the trainer section), and it makes a missing trigger easy to spot.

In ImgTagger, open the Auto-tag panel and type the trigger into Always add these tags first before you run the tagger. Prepend tags go at the very start of every caption, ahead of anything the image already had, in the order you type them. To add the trigger to images that are already tagged, use the Add Tags panel with the mode set to Prepend (Add to start). It also keeps the order you type, but it skips images that already have the tag anywhere in their list, so it won't move an existing copy to the front. Remove the tag with the Remove Tags panel first, then prepend it again.

Step 2: Auto-tag the batch

Drop the images onto the tagger. Pick a model (ViT v3 is the default, and our WD14 model comparison explains the others) and leave the confidence threshold at 0.35 for a first pass. The confidence threshold guide covers when to raise or lower it.

Fill in the blacklist with tags you already know you don't want, such as the four rating tags if you won't use them. The blacklist matches whole tags and ignores case and underscores, so simple_background and simple background both work. Then click Auto-tag all.

Each caption comes out in this order: prepend tags, then any tags the image already had, then new model tags from most to least confident. When the run finishes, a summary lists every added tag with a count, and each tag's remove button takes it back off the images that just received it. That is a quick way to drop obvious misfires.

Step 3: Decide what to tag and what to leave out

This is the step that shapes your LoRA. The usual rule of thumb is: caption what should stay variable, and leave out what should be baked into the concept.

During training, the model tries to explain each image using its caption. A feature named by a tag becomes linked to that tag, so you can still switch it on and off by prompting. A feature that appears in every image but is never tagged has nothing else to attach to, so it gets absorbed by the trigger word, the one tag that is always there. Leaving a feature out is how you tell the LoRA "this is part of the concept".

Example: a character LoRA

Say your original character always has grey hair, green eyes and a hairclip, and you have drawn her in different outfits, poses and places. One image comes back from the tagger as:

miraoc, general, 1girl, solo, grey hair, green eyes, hairclip, hair ornament, smile, school uniform, jacket, upper body, outdoors, tree
TagsKeep or cutWhy
grey hair, green eyes, hairclip, hair ornamentCutThey are the character. Cutting them lets miraoc carry them.
school uniform, jacketKeepThe outfit changes between images, and you want to change it at prompt time.
smile, upper body, outdoors, treeKeepExpression, framing and setting should stay under your control.
1girl, soloKeepThey describe the composition, and anime models know them extremely well.
generalYour choiceA rating tag. Keep it only if you prompt with ratings.

The pruned caption becomes miraoc, 1girl, solo, smile, school uniform, jacket, upper body, outdoors, tree. If she only ever wears one outfit, you could cut those tags too, at the cost of making the outfit hard to change later.

Example: a style LoRA

A style LoRA flips the logic. The subjects change from image to image, and the look stays the same. Say you are training a soft ink-and-watercolor illustration style across portraits, animals and landscapes, and one image comes back as:

inkwash, general, no humans, cat, flower, outdoors, traditional media, watercolor (medium), limited palette

Here you cut traditional media, watercolor (medium) and limited palette, because they describe the style you want the trigger to learn. You keep no humans, cat, flower and outdoors, because the point of a style LoRA is to apply the look to any subject. Cut the subject tags instead, and the LoRA starts to tie the style to cats and flowers.

Make these cuts across the whole batch at once instead of image by image. The tag pruning guide covers redundant tags, misleading ones and starter blacklists for both kinds of LoRA.

Step 4: Review the batch with the Filter panel

Tagger errors are spread thinly across a batch, so reading one caption at a time misses them. Review by tag instead: the Filter panel lists every tag in the batch with the number of images that carry it.

  • Sort by count, high to low. Your trigger should be at the top, with a count equal to the number of images. Other tags near the top are on almost every image. Decide whether each is part of the concept (cut) or a real variable (keep).
  • Sort by count, low to high. Tags on only one or two images are often misfires. Check each against its image.
  • Any mode. Check a tag to show only the images that have it, then step through them with the left and right arrow keys.
  • All mode. Check two tags that shouldn't appear together, such as solo and multiple girls, or long hair and short hair. Any image left on screen has a contradiction to fix.
  • None mode. Check your trigger word. Any image still showing is missing it, which often happens to images added after the first run.

When some images have no tags at all, the list also shows a ∅ untagged entry; check it in Any mode to see them. To fix a problem in bulk, filter down to the images you want, click Select All (it selects only the visible images), then use the Add Tags or Remove Tags panel with its "Selected" button. Selected-image actions ignore anything the current filter hides. The trash button next to a tag in the Filter panel is different: it removes that tag from every image in the batch.

Don't re-run Auto Tag after pruning

Auto Tag keeps existing tags and adds any model tags that are missing. If you run it again after cutting grey hair by hand, the tag comes straight back, unless it is also in the blacklist.

Step 5: Keep captions consistent

Consistency matters more than any single tag. A trainer can't tell that long hair and long_hair mean the same thing, and ImgTagger's Filter panel lists them as two separate tags. So keep to:

  • One spelling style. ImgTagger writes spaces, so type spaces in hand-added tags too, and convert older underscore captions before you mix them in.
  • One trigger, one place. Always first, always spelled the same.
  • One set of rules. Apply the same keep-and-cut decisions to every image, rather than hand-describing a few in far more detail than the rest.

Hand-added tags work best when they are real booru tags the base model already knows. The booru tag glossary lists common ones by topic.

Step 6: Export the captions

Click Download in the tagger's bottom bar. Tick .txt tag files, and also Image files if you want a self-contained copy, then choose All Items or Selected Only. ImgTagger builds a ZIP such as images_tags.zip. Each caption is saved as a .txt named after its image, with tags joined by a comma and a space. Images go in exactly as you dropped them, and the ZIP has no subfolders.

Before you export, check the ∅ untagged entry one last time. An image with no tags is exported with an empty .txt file, and some trainers refuse to start when they find one.

Datasets with more than one concept

One LoRA can hold more than one trigger. Two common setups are two characters in one file, and a character whose signature outfit gets its own switch. Both follow the same rule as a single character, applied once per trigger.

Two characters

Give each character a made-up trigger, say miraoc and kaioc, and prune each one's fixed features from her own images only. Mira's grey hair goes from Mira's captions, Kai's red hair from Kai's. Don't blacklist either set of features, because the blacklist would also strip Kai's hair color from Mira's images, where a second person may appear with it.

Images with both characters need both triggers, and here tags hit their limit: a caption with miraoc, kaioc, grey hair, red hair can't say whose hair is whose. Keep shared images to a minority of the set, or write those few captions as sentences. Our comparison of tags and sentence captions covers that binding problem and the hybrid format that solves it.

A character plus a switchable outfit

If Mira wears one costume in half the images and other clothes in the rest, give the costume its own trigger, such as mirauniform. On costume images, the caption starts miraoc, mirauniform, and the costume's own tags (sailor collar, pleated skirt) are cut so the second trigger absorbs them. On the other images, leave out mirauniform and tag the clothes she does wear. The model then sees the character without the costume often enough to separate them, and you can prompt either one alone.

Working on each concept separately in ImgTagger

ImgTagger's export is flat, so a dataset split into one folder per concept is easiest to caption one folder at a time. If everything is loaded together, use the Filter panel: check kaioc in Any mode, click Select All, and do Kai's pruning with the panels' Selected buttons. To pull one concept's files out, export with Selected Only and get selected_images_tags.zip holding just those images and captions. How many images each concept needs, and how repeats balance an uneven split, is in the image count guide.

Trainer settings: kohya-ss sd-scripts

This section applies to kohya-ss sd-scripts and tools built on it, and was checked against its source and docs. Other trainers read the same files but name their options differently.

  • --caption_extension=".txt". The default is .caption, so without this the trainer won't find ImgTagger's files. In a dataset config file, the same setting is caption_extension = ".txt".
  • Folder naming. --train_data_dir points at a parent folder, and each subfolder inside it is named <repeats>_<name>, such as 10_miraoc. The number sets how many times each image is repeated per epoch. The text after the underscore is used as the caption only for images that have no caption file. Folders that don't start with a number are skipped. If you use a --dataset_config file instead, folder names are not parsed, and you set num_repeats in the file.
  • --shuffle_caption shuffles the comma-separated tags each time an image is used, so the model doesn't come to depend on tag order.
  • --keep_tokens=1 keeps the first tag (your trigger) in place while the rest are shuffled. Use a higher number if you put more than one fixed tag at the front. (--keep_tokens_separator is an alternative.)
  • File rules. sd-scripts reads captions as UTF-8, uses only the first line of each file unless --enable_wildcard is on, and stops with a "caption file is empty" error if it meets an empty one.

A typical layout and the matching flags:

train/
  10_miraoc/
    mira_001.png
    mira_001.txt
    ...

--train_data_dir="train" --caption_extension=".txt" --shuffle_caption --keep_tokens=1

The same setup as a dataset config file

Many projects move these settings into a TOML file passed with --dataset_config. The sd-scripts dataset config guide documents every key. Here is the two-character set from above, one folder per character:

[general]
caption_extension = ".txt"
shuffle_caption = true
keep_tokens = 1
enable_bucket = true

[[datasets]]
resolution = 1024
batch_size = 2

  [[datasets.subsets]]
  image_dir = "train/mira"
  num_repeats = 10
  class_tokens = "miraoc"

  [[datasets.subsets]]
  image_dir = "train/kai"
  num_repeats = 10
  class_tokens = "kaioc"

A setting under [general] applies everywhere unless a dataset or subset sets its own. With a config file, folder names are not read, so num_repeats and class_tokens do the job of the 10_miraoc name: class_tokens becomes the caption only for an image that has no caption file. In the version we read (late October 2026), an image with neither gets a warning and trains with an empty caption, so read the trainer's log for "No caption file found" before you leave a run going.

Adding the trigger in the trainer instead of the files

Subsets accept caption_prefix and caption_suffix, which the trainer joins to every caption with a space. caption_prefix = "miraoc," puts the trigger in front of each caption without touching the .txt files, which is handy when the same captions feed two LoRAs with different triggers. End the prefix with a comma so it splits into its own tag.

The prefix is added before shuffling, so it is shuffled like any other tag unless keep_tokens holds it. With a one-tag prefix, keep_tokens = 1 keeps it first. Pick one place for the trigger: if it is in the files and in the prefix, every caption carries it twice.

Caption dropout and tag dropout

Three options make the trainer leave text out on purpose. They work on the caption as it is read at each step, so your files stay unchanged.

OptionWhat it doesEffect on the trigger
caption_dropout_rateTrains that share of samples with an empty captionDropped too, with the rest of the caption
caption_dropout_every_n_epochsEmpties every caption in every Nth epochDropped too
caption_tag_dropout_rateDrops each shuffled tag with that chance, one tag at a timeSafe: tags held by keep_tokens or before a keep_tokens_separator are never dropped

Tag dropout has the most to do with captioning. Each time an image comes round, a few of its tags are missing, and the usual reasoning is that the model then leans less on any single tag. Whether that helps depends on the dataset. The sd-scripts docs give no recommended rate (the config guide's example uses 0.1), so treat any value as an experiment and compare checkpoints. One limit applies to all three options and to shuffle_caption: with --cache_text_encoder_outputs, the trainer encodes each caption once in advance, and the advanced training notes say caption augmentations are then disabled.

Reading a test run: caption problems and fixes

The first trained checkpoint is the best caption review you will get. Prompt it for things that are not in the dataset, such as a different outfit, a new background or a second person, and compare what comes back with this table. These are patterns trainers commonly report. Each has a usual caption cause, though image choice and settings can produce the same symptom.

What you seeLikely caption causeFix
The character always wears the same jacketThe jacket was in most images and never tagged, so the trigger absorbed itTag the outfit where it appears, and add images in other clothes
Hair or eye color drifts when you change the promptFixed features were left in the captions, so the trigger never took them onCut them, as in step 3
The same room or sky shows up behind everythingA background common to many images was left untaggedTag it, so it belongs to a tag instead of the trigger
A signature or watermark appears in outputsThe mark was in the pixels with no tag to explain itCrop it out, or tag it and use the tag in your negative prompt (see the pruning guide)
The trigger does little or nothingIt is missing from some captions, or it is a word the base model already knows wellCheck None mode for the trigger, and switch to a made-up word
A style LoRA only draws the subjects of its training imagesSubject tags were cut along with the style tagsRestore the subject tags and cut only the style
Two characters swap features in shared scenesTags can't say whose hair is whoseFewer shared images, or sentence captions for those
Put this into practice

Run WD14 tagger models on a whole folder, then search, filter and bulk-edit the tags before exporting .txt caption files. It runs in your browser. Open the Batch WD14 Tagger & Editor.

Frequently asked questions

What happens to images that have no caption file?

It depends on the trainer. With the folder method in kohya-ss sd-scripts, an image without a .txt falls back to the text in its folder name, so an image in 10_miraoc is trained with the caption miraoc alone. Other trainers may use an empty caption or skip the image. A mix is usually an accident, so check for gaps before training.

Should I caption with tags or with full sentences?

Match the base model. Anime-focused models trained on booru-tagged images respond best to tags, while models trained on descriptive sentences tend to do better with sentences. Our comparison of booru tags and natural-language captions goes through the trade-offs.

Will my trigger word and blacklist carry over to my next project?

Yes. ImgTagger remembers the blacklist and the "always add these tags first" text in your browser, so they are filled in on your next visit. Clear or change them before you tag a new dataset, or every image will get the old trigger and lose the old blacklisted tags.

Where does the tagging happen?

ImgTagger downloads the tagger model from Hugging Face once, caches it in your browser and runs it there. Our privacy policy describes what data we may collect, and how in-browser AI works explains the technology.

Does the trigger go on images where the face isn't visible?

Yes, if the character is in the picture. A back view or a distant shot teaches the trigger her silhouette, hair and clothes from angles a portrait never shows, and those images are often what lets the LoRA draw her from behind later. Tag the view (from behind, facing away) so the trainer knows why no face is there, and keep the usual cuts. Leave the trigger off only when she isn't in the image at all.