A practical workflow for cleaning an image dataset
The short answer
Back up the originals, then go from the cheapest filters to the most detailed work. Remove exact and near duplicates first. Filter by faces or expressions if your subject is a person or character. Correct color only where it's a fault rather than part of the style. Auto-tag and review last, then prune the tags and export captions. In this order every step runs on fewer images, and nothing you caption gets thrown away afterwards.
A folder of images collected from different places isn't a dataset yet. It has copies, off-topic pictures, odd color casts and no captions. The four ImgTagger tools can fix all of that in your browser, but the order matters: each step changes what the next one sees, and some, like re-encoding, can't be undone.
Below is the order we recommend, why each stage sits where it does, and what to check along the way.
The workflow at a glance
| Stage | Tool | Goal |
|---|---|---|
| 1. Gather and back up | Your file manager | One working folder, originals kept safe |
| 2. Remove duplicates | Duplicate Image Finder | One copy of each picture, the best one |
| 3. Filter by faces | Face & Expression Sorter | Only images that show your subject (if relevant) |
| 4. Even out color | Batch Color Fixer | Fix casts and flat exposure, not style |
| 5. Auto-tag and review | Auto Tagger & Tag Editor | A tag list for every image |
| 6. Prune and export | Auto Tagger & Tag Editor | Clean, consistent .txt captions |
The logic: steps that remove images come before steps that work on them, and steps that change pixels come before the step that describes them.
Which stages your dataset needs
Deduplication and tagging apply to every dataset. The stages in between depend on what you are training and where the pictures came from.
| Dataset | Face sorting | Color correction | Cropping |
|---|---|---|---|
| Anime character from screenshots and fan art | Useful, but expect drawn faces to be missed; review the "No Faces" group | Rarely; artists' palettes vary on purpose | Often: other characters, subtitles, borders |
| Your own photos of a person or pet | Yes for a person; skip for a pet (the detector looks for human faces) | Often: phone photos under mixed indoor light | Sometimes: other people, clutter at the edges |
| An art style | Skip | Never; the color is part of the style | Only to remove signatures, frames and interface |
| An object or product | Skip | Sometimes, to make the object's true color consistent | Often, to give the object a fair share of the frame |
| Scenery or backgrounds | Skip, or use it to find and drop shots with people | Sometimes, for scans and old photos | Rarely |
The face-sorting row for scenery works backwards: sort, then keep the "No Faces Detected" group. It is a quick way to strip tourist snaps out of a landscape set, though small figures in the distance can slip through.
Set up folders and keep the originals
First, copy the raw images into a folder you never edit, and back it up elsewhere too. Every ImgTagger tool leaves your files alone and returns results as a new ZIP, so a numbered layout keeps the stages separate:
my-dataset/
00-originals/ untouched, also backed up elsewhere
01-deduped/ keepers from the duplicate finder
02-filtered/ after face or expression sorting
03-color/ after color correction, if any
04-captioned/ images + .txt files from the tagger
Keeping every stage lets you step back: if the color pass was a mistake, restart from 02-filtered.
ZIP downloads store images by filename only, so when you merge sources, two different files called image_01.png collide and one is lost. The tagger also treats a same-named file as a replacement, and the color fixer skips it. Rename files first, for example with a source prefix.
Step 1: Gather
Collect more than you need, since later stages only remove images. While gathering:
- Use formats your browser can open. JPEG, PNG and WebP are safe. Phone photos are often HEIC, which many browsers can't display; convert those first with the image converter, which reads HEIC in any browser.
- Get the largest, most original version. A thumbnail or re-posted copy has already lost detail, and the duplicate finder can only pick from what you collected.
- Note each image's source if licensing or credit matters. Nothing later records it.
Step 2: Remove exact and near duplicates
Deduplicate first because it's the cheapest filter and it shrinks every later stage. It also protects training: an image that appears three times is learned three times, which pulls a model toward that one picture.
Load the working folder into the duplicate image finder. Byte-identical files are dropped automatically, and the rest are grouped by visual similarity. The default DCT mode at its default threshold of 3 catches re-saves and resized copies. If you also want lightly edited copies, raise it one step at a time; if it groups different pictures, drop to 2. Our guide to how perceptual hashing works explains what that threshold measures.
What to check: in each group, keep the copy with the largest pixel size and no watermark or border. Decide on purpose about near-duplicates such as alternate expressions. One or two can add variety, but a run of near-identical frames over-weights one pose and background. The finder can't catch mirrored copies, so look for those by eye.
Common mistakes:
- Raising the threshold too far without looking. From about 4 or 5 upward, unrelated images with a similar layout start to group.
- Keeping the first image of each group by habit. It's just the earliest file.
- Deduplicating after color correction. You've corrected copies you'll delete, and once every file has been re-encoded, file size no longer tells you which copy was the best.
Step 3: Filter by faces or expressions
If your dataset is about a person or character, the next question is whether each image actually shows them. The face and expression sorter splits a batch into "Faces Detected" and "No Faces Detected" and lets you filter by face count (1, 2, 3, 4 or 5+). It can also score seven expressions: neutral, happy, sad, angry, surprised, fearful and disgusted.
It runs after deduplication because face detection runs a neural network on every image, and before color and tagging so you don't spend effort on images you'll drop.
What to check: the "No Faces Detected" group starts unchecked, so those images are left out of the download unless you select them. Look through it anyway. Back views, profiles, small faces in wide shots and drawn or stylized faces are easy to miss, and those shots often give a dataset its variety. For a single-subject set, use the face-count filter to find group shots. Our guide to curating images with face detection covers the input size and score threshold settings.
When to skip it: for style, scenery, object or architecture datasets, faces don't matter.
Common mistakes: treating "no face detected" as "no person", and filtering on expressions so tightly that every image has the same smile, which teaches the model a single expression.
Step 4: Even out color, or leave it alone
Color correction fixes faults that would otherwise be learned, such as a yellow cast from indoor lighting or a washed-out scan. The batch color fixer applies white balance, histogram normalization, brightness, contrast, saturation and gamma to every image at once, with per-image overrides.
It comes after filtering, since there's no point correcting images you'll delete. It comes before tagging because the tagger describes the pixels it sees. Hair and eye colors, monochrome and greyscale all come from the image, so a strong cast can change the tags you get.
For a style dataset, skip this stage. An artist's palette or a deliberate tint is the style, and "fixing" it teaches the model a look the artist never used. Be careful with Auto white balance on images dominated by one color: it uses the gray-world idea, scaling red, green and blue until their averages match, so a character in a blue outfit against a blue sky gets pushed toward gray.
Histogram normalization is gentler on illustrations than it sounds. It stretches each color channel from its darkest to its lightest value, and an image with black line art on a white background already spans the full range, so it changes little or nothing. The white balance and histogram guide covers both methods and lists the images to leave alone.
What to check: the fixer re-encodes every image you loaded when it exports. JPEGs come back with a .jpeg extension, WebP stays WebP, and everything else is saved as PNG. Base filenames are kept, so captions still pair up later. But each JPEG goes through another round of lossy compression, so correct once, from the cleanest copies.
Common mistakes: applying one automatic correction to a mixed batch without checking individual results, and correcting a style dataset into blandness.
Before tagging: crop, rotate and resize if needed
Some images need their pixels changed in ways color correction doesn't cover. These steps belong in the same place in the order, after the images that will be dropped are gone and before the tagger sees anything.
| Job | Tool | What to know |
|---|---|---|
| Cut out borders, captions, a second person | Crop Image, one picture at a time | Copies the pixels in the box 1:1 with no resizing. Saves as <name>-cropped.<ext>, so rename it back to the original name if you keep a record by file name. |
| Fix photos that open sideways | Rotate & Flip | Applies the phone's rotation tag and saves the pixels upright with no tag. Quarter turns are pixel-exact. |
| Shrink very large files, or make every image one exact size | Bulk Image Resizer | Keeps original names by default. Turn on Do not enlarge so small images aren't blown up. An exact size crops to fill, with a crop editor per picture. |
Most LoRA trainers resize images themselves, so the resizer is for files too big to handle comfortably or for a trainer that wants one fixed size. Our guide to LoRA image size, crop and buckets covers when a trainer needs that.
Count the re-saves
Every one of these tools, like the color fixer, writes a new file, and each JPEG save costs a little quality. A picture that is cropped, then resized, then color-corrected, all as JPEG, has been compressed three more times than the original. Two habits keep that in check:
- Save in-between steps as PNG. PNG is lossless, so the extra saves cost disk space and nothing else. The color fixer keeps a PNG as a PNG, so a PNG made earlier stays lossless to the end.
- Combine steps where one tool can do both. If you need a fixed size and a better framing, the bulk resizer's exact size with its crop editor does both in one save, where Crop Image followed by the resizer takes two.
Step 5: Auto-tag and review
With the final images in place, run the auto tagger. It runs a WD14 model in your browser and writes Danbooru-style tags for each image, the most confident ones first. The default confidence threshold of 0.35 is a reasonable place to start.
Tagging comes this late for two reasons. Tags describe pixels, so they should come from the final pixels. And every image runs through a model of several hundred megabytes, the slowest step per image in this workflow, so it should run on the smallest set.
What to review:
- Count tags.
solo,1girl,multiple_girlsandno_humanscarry a lot of weight in a caption, so make sure each one matches its image. - Quality flags. Use the Filter panel to pull up images tagged
watermark,signatureorblurry. Each one is a reason to drop or replace the image; deleting the tag leaves the problem in the picture. ImgTagger only outputsblurryat 0.9 confidence or higher, so it flags clear cases only. - Resolution. The models can't output
lowresorjpeg_artifacts, so small or heavily compressed images won't flag themselves. Check the pixel size shown in the preview pane. - Rare tags. Sort the filter list from low to high count. A tag on only one or two images often points to a wrong guess or an off-topic picture.
Step 6: Prune tags and export captions
Raw tagger output is a starting point. Pruning makes captions consistent and steers what the model learns:
- Drop tags for things that never change. In a character set, many trainers remove tags such as a fixed hair or eye color so the trigger word absorbs them. It's a common convention with real trade-offs, covered in our tag pruning guide.
- Add a trigger word with the prepend option, so it comes first in every caption.
- Add tags you never want to the "Never add these tags" box, such as the rating tags if you don't use them.
- Fix batch-wide mistakes in one click from the Filter panel or the post-run summary.
Then download a ZIP with the images and their .txt files. Each caption is saved under the image's base name, with tags separated by a comma and a space. The guide to caption .txt files covers what training tools expect.
Common mistakes: pruning so hard that visibly different images get identical captions, and removing or renaming images after export without checking that every image still has its .txt file.
An example project, stage by stage
Here is the order applied to one plausible project: a character LoRA for an original character, from a folder of 180 files gathered from an old art folder, a phone and a few chat exports. The counts are an illustration of how the stages shrink a set; your own will differ.
- Gather. Copy everything into
00-originals. Thirty phone photos of sketches are HEIC; convert them to PNG in the image converter, so the later steps on them stay lossless. Rename every file with a source prefix (art_,phone_,chat_) so no two names collide. - Deduplicate. Load all 180 into the duplicate finder with the default "Resized or re-saved" preset. Chat exports are often smaller re-saves of art files, so many groups pair a chat copy with its original; keep the original. Say 150 remain in
01-deduped. - Sort by faces. The character is drawn, so look through "No Faces Detected" by hand instead of dropping it. Remove reference sheets that squeeze four small poses onto one page, and pictures where she is a speck in a landscape. Say 110 remain.
- Color. Skip it for the drawings. The phone photos of sketches have a yellow cast from a desk lamp, so correct only those; the fixer keeps them as PNG.
- Crop. Trim the phone photos to the paper's edge, and crop a second character out of a few images where they would otherwise share the frame.
- Tag and prune. Put the trigger in "Always add these tags first", blacklist the four ratings, auto-tag, and prune the fixed hair and eye colors. Export images and captions to
04-captioned.
Notice which decisions came from the dataset rather than from the workflow: the face-sorter results were reviewed instead of trusted, color was corrected on a subset only, and the crop step existed because of where the images came from. The order stayed the same.
How many images, and how good?
There's no single right dataset size. It depends on what you're training, the base model and your settings, and published advice varies widely. Our guide on how many images a LoRA needs, and at what size and crop goes into the sources and the arithmetic. A few principles hold regardless:
- Quality beats quantity. Every image teaches something, including blur, watermarks and off-model drawings, and in a small set each one carries more weight.
- Vary what should vary. For a character, different poses, angles, outfits, backgrounds and lighting help the model separate the character from the setting. If every image has the same background, the model may treat it as part of the character.
- Keep constant what shouldn't vary. For a style, every image should really be in that style. A few off-style images dilute it.
- Watch the balance. If most images share one outfit, expect the model to default to it. Tag counts in the Filter panel make imbalances easy to spot.
- Mind the pixels. Images much smaller than your training resolution get upscaled and look soft, so dropping them is usually better.
When in doubt, start with a smaller, carefully checked set, train, study the results, and add images that fix specific weaknesses.
When something goes wrong
| Symptom | Likely cause | Fix |
|---|---|---|
| Fewer images in a downloaded ZIP than you kept | Two files with the same name; the ZIP stores names only, so one overwrote the other | Rename with source prefixes and download again |
| Some files never appear in a tool | A format the browser can't open, often HEIC | Convert them first |
| The duplicate finder groups pictures that only look alike | The "Similar-looking" preset, or a raised threshold in Advanced | Go back to "Resized or re-saved" and review groups by eye |
| Drawn characters land in "No Faces Detected" | The face detector is a small model trained mostly on photos | Review the group; see the face detection guide for the input size and score threshold |
| Tags describe a color the character doesn't have | A color cast in the image, or a wrong guess | Correct the cast before tagging, or prune the tag |
Every caption contains general | ImgTagger lets the general rating through at 0.1 confidence | Blacklist the four ratings unless you use them |
| The trainer finds fewer images or captions than you exported | Extension case, an unsupported format, or a renamed file | Run the folder check in the caption file guide |
Keep a short dataset log
ImgTagger remembers your blacklist and trigger in the browser, but not which project they belonged to, and none of the tools record where an image came from. A plain text file in the dataset folder fills the gap. Write down the sources and their licenses, the duplicate preset you used, which images were color-corrected, the tagger model and threshold, the blacklist, the trigger and the pruning rules. When you add images six months later, or a trained LoRA shows a quirk, the log tells you what the captions were meant to say.
Checklist
Before you start
- Originals copied to a folder you never edit, and backed up elsewhere
- Filenames unique across all sources
- Every file in a format your browser can open
Duplicates
- Exact and visual duplicates removed, starting from a strict threshold
- Best copy kept in each group: largest size, no watermark or border
- Mirrored copies checked by eye
Faces (people and character sets only)
- "No Faces Detected" group reviewed for back views, profiles and small faces
- Group shots removed or kept on purpose
Color
- Corrected only where color is a fault, not a style
- Individual results checked after any automatic correction
Tags and captions
- Count tags correct on every image
- Images tagged
watermark,signatureorblurryreviewed - Small images found and dropped or replaced
- Trigger word prepended, unwanted tags blacklisted or removed
- Every image in the export has a matching
.txtfile
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
Can I run the stages in a different order?
Yes, when your data calls for it. If a huge folder is mostly off-topic, sorting by faces first can be quicker, because the duplicate finder's comparisons grow with the square of the image count. The rule worth keeping is to tag last, since any later image change means re-checking captions.
Do I have to start over when I add new images?
No. Run the new images through the duplicate finder together with your existing keepers to catch overlaps. Then load the whole set, images and .txt files, into the tagger. Captions pair with images by filename, and you can auto-tag only the selected new images.
Should I convert everything to PNG first?
No. Converting a JPEG to PNG doesn't restore any detail; it only makes the file bigger. Keep each image in its original format. The duplicate finder compares decoded pixels, so mixed formats aren't a problem.
Should I crop or resize images before tagging?
Crop when it removes distractions, borders or other people, and do it before tagging so the tags describe the final image. Resizing usually isn't needed, because most training tools resize images themselves. The section on cropping, rotating and resizing above lists our tools for each job.
How long does the tagging step take?
On our test laptop (Apple M1 Max, Chromium), the default ViT v3 model took about 4.3 seconds per picture on one worker. One worker would therefore need about 21 minutes for 300 pictures. The batch tagger runs several workers at once, 80% of the processor cores the browser reports, at least 4 and at most 20, and they share out the pictures, so a real run is shorter. Phones and computers reporting 4 GB of memory or less get the smaller 8-bit model and one worker. The first run also includes the model download.