Toggle Theme

Train Your Own LoRA with ComfyUI: Data, Captions, Training, and Validation

Easton editorial illustration: central LoRA trainer module, stack of varied character dataset image cards, output safetensors file tile

"kohya-ss/sd-scripts provides LoRA training scripts and documentation for Stable Diffusion, SDXL, SD3, FLUX.1, and other model families."

You have 20 original character images and want a LoRA that can reproduce the character in later generations.

The dataset is ready, the captioning tool is installed, and you copied parameters from a screenshot. The result still falls apart: the face changes with the background; captions include words such as “wall” and “floor,” so every scene inherits the same room; an LR of 1e-3 overfits and turns details into a mess; or you copy dim/alpha 32/1, leaving alpha=1 and dim=32 at a scale of only 0.03, about 3%.

There is no promise of succeeding in one run here. The practical route goes from dataset preparation and captions through initial parameters and fit diagnosis to validation in ComfyUI.


Dataset preparation: how many images and which ones

The first step in LoRA training is not opening a training tool. It is deciding whether the material is sufficient and suitable.

The training target determines the data volume

What you want to train directly determines how many images you need.

Character LoRA: start with 15–30 images. Excellent material that is clear, consistently sized, and cleanly framed can work with as few as 10. To preserve identity across scenes, include different backgrounds and angles.

Style LoRA: usually needs more, often 50–100 images, because a style includes more variables than one character: brushwork, palette, and composition habits. With too little data, the result may look vaguely similar but disappear on a new image.

Object or clothing LoRA: similar to a character, start with 15–30 images and make the main features clear through front, side, and close-up views.

Dataset quality checklist

The count alone is not enough. Weak material teaches the LoRA the backgrounds, lighting artifacts, and defects along with the intended subject.

Training targetStarting countResolutionBackgroundOther requirements
Character LoRA15–30 images (10 can work at high quality)Consistent size (512×512 or 1024×1024)Clean or at least varied; avoid repeated scenesDifferent angles, expressions, and poses
Style LoRA50–100 imagesMatch the base model (SD1.5→512, SDXL→1024)Need not be clean, but the style must be consistentWorks from the same artist or series
Object LoRA15–30 imagesConsistent resolutionClean is preferable, though varied can workDifferent views and detail close-ups

The practical priority is consistent resolution, then background quality for characters, then varied angles and details. Large differences in source resolution produce inconsistent resizing and softer learned details.

Resolution, backgrounds, and preprocessing

Consistent resolution: training resizes every image to a target size. If sources vary from 512 to 2048 pixels, the resized detail level will vary. Crop them to the target resolution during preprocessing.

Background handling: background terms are a common character-LoRA trap. If 15 of 20 images show the same room, the captioner will repeatedly add “wall” and “floor,” and the LoRA may learn the room with the character. Choose clean backgrounds or review the captions manually, as described below.

Preprocessing flow:

  1. Select clear images with similar resolutions and obvious defining features.
  2. Crop them to one resolution with Photoshop, GIMP, or a batch script.
  3. Remove high-risk material when the same background appears in more than five images.

Captions and trigger words: how to label the dataset

Captioning is not a one-click batch job. Automatic tools include backgrounds and secondary traits, and those terms directly affect how usable the LoRA becomes.

Choosing a captioning tool

Common options include:

ToolCharacteristicsBest forComfyUI support
WD14 TaggerCommon in the Stable Diffusion ecosystem; uses Danbooru-style tags and suits characters or animeCharacter LoRAs and anime stylesNodes are available through Image-Captioning-in-ComfyUI
Florence2A Microsoft vision model that writes natural-language descriptionsRealistic characters and objectsComfyUI nodes are available
BLIPAn image-captioning model that produces natural-language outputRealistic styles and scenesSupported in ComfyUI

WD14 Tagger is common for character LoRAs, but it can insert background terms such as “simple background” and “white wall.” Florence2 is better suited to realistic material and produces prose rather than a tag list.

Trigger-word format and placement

Use a rare token or custom combination that is unlikely to collide with an existing model tag. Common forms include:

  • sks charname, where sks is an older rare-token prefix used in Stable Diffusion workflows
  • xyz_character_name, with a custom prefix
  • my_char_001

Where to put it:

  1. Place the trigger at the start of each image’s .txt or .caption file, followed by attribute terms.
  2. Some trainers expose a separate trigger field, but it is not required if every caption already includes the token.

Should the trigger be present? Yes. Without a repeated token, the model lacks a consistent name for the concept. Include it in every caption, then use it during generation to activate the LoRA.

Manually checking core attributes

After automatic captioning, check at least three things.

Background leakage: if “wall,” “floor,” or “bedroom” appears frequently in a character dataset, new backgrounds may fail. Delete those terms or replace them with a broader term such as “simple background.”

Missing triggers: confirm that every caption begins with the intended trigger.

Missing defining traits: if the character has a distinctive hairstyle, palette, or outfit that the captioner missed, add it manually.

This does not require proofreading every word. Use a text tool such as grep or a spreadsheet to inspect term frequency, then correct the anomalies.


Training-tool boundaries: what ComfyUI training actually does

ComfyUI can run LoRA training, but ComfyUI itself is not the training backend.

kohya-ss/sd-scripts is the training backend

The training work is performed by kohya-ss/sd-scripts, a widely used script collection for Stable Diffusion LoRA training. Tools such as Kohya GUI and ComfyUI training nodes wrap these scripts or closely related implementations.

ComfyUI-side nodes such as FluxTrainer and Lora-Training-in-Comfy are wrappers:

  • FluxTrainer, maintained by Kijai, wraps modified sd-scripts training code and exposes FLUX and related training in a ComfyUI workflow.
  • Lora-Training-in-Comfy similarly provides a ComfyUI interface around kohya-based training for supported Stable Diffusion families.

The boundary matters: a training node does not provide universally optimal parameters. Its defaults are examples or the author’s latest working settings, so consult the node’s current README and the upstream training documentation.

Comparing training paths

PathAdvantagesDrawbacksBest for
kohya-ss GUI desktop appFull parameter UI and many community tutorialsSeparate installation and a dense interfaceUsers who want complete parameter control
ComfyUI training nodes such as FluxTrainerRuns inside ComfyUI and keeps the workflow togetherExperimental pieces; defaults are not guaranteed to be optimalExisting ComfyUI users who want training in the same graph
Raw kohya-ss scripts in the terminalCurrent features and complete parameter controlHigher command-line barrierExperienced trainers tuning specific settings

Where to look for current parameters

Do not rely only on tutorial screenshots or node defaults. Start with the current kohya-ss/sd-scripts documentation:

  • Training guides describe options for different model families, including SD1.5, SDXL, and FLUX.1.
  • GitHub issues and discussions contain narrower experience reports, such as the network-alpha discussion.

Learning rates, dim/alpha, and step counts change with the base model and dataset. There is no single configuration that fits every LoRA.


Initial parameter recipes: what to set for each target

These recipes are reproducible starting points, not guaranteed optimal settings. Adjust them against saved epochs and fit symptoms.

The relationship between network dim and alpha

Network dim, or rank, controls the capacity of the LoRA weight matrices. A higher dim can represent more detail, but also increases memory and training cost.

Network alpha scales the learned LoRA weights. When alpha is below dim, the effective update is damped relative to the configured learning rate.

Simplified scale: alpha / dim

Examples:

  • alpha=16, dim=32 → scale 16/32=0.5
  • alpha=32, dim=32 → scale 1
  • alpha=1, dim=32 → scale 1/32≈0.03

Copying dim=32 and alpha=1 without considering the learning rate and steps can therefore produce a weak result.

Starting guidance:

  • Try alpha=dim for no scaling or alpha=dim/2 for moderate damping.
  • When alpha is below dim, evaluate it together with a higher learning rate or more steps rather than changing one number in isolation.

Starting learning rates, steps, and epochs

ParameterCharacter LoRA startStyle LoRA startNotes
Learning rate (U-Net LR)4e-41e-4Starting value; tune against fit symptoms and account for alpha scaling
Learning rate (text encoder LR)5e-5 or 1e-55e-5 or lowerTrigger learning is usually below the U-Net rate
Steps1000–20002000–3000Derive from epochs and stop early if overfitting appears
Epochs10–2020–30A small 15–30-image character dataset may need fewer epochs

Steps are optimizer updates; an epoch is one pass through the dataset. The actual relationship also depends on repeats, batch size, gradient accumulation, and distributed settings, so read the trainer’s reported step count rather than relying on a shortcut formula.

Choosing the base model

The base model determines LoRA compatibility:

Base modelTraining resolutionCompatible generation modelsApproximate starting VRAM
SD1.5512×512SD1.5 and compatible derivativesAbout 8 GB with fp16 and gradient checkpointing
SDXL1024×1024SDXL and compatible derivativesAbout 12 GB with fp16 and gradient checkpointing
FLUX.11024×1024 or higherThe corresponding FLUX.1 familyOften much higher without memory-saving options

FLUX.1 support and memory-saving flags continue to change. Use the current trainer documentation rather than treating a fixed VRAM number as a promise.

Starting recipe table

Training targetdimalphaU-Net LRText encoder LRInitial steps/epochsBase model
Character LoRA (SD1.5)32 or 12832 or 1; compensate when alpha is low4e-45e-51000–2000 steps / 10–20 epochsSD1.5
Character LoRA (SDXL)1281 or 1284e-45e-51500–2500 steps / 10–20 epochsSDXL
Style LoRA (SD1.5)128 or 256128 or 11e-45e-5 or lower2000–3000 steps / 20–30 epochsSD1.5

Treat every value as a starting point and adjust it using the fit checks in the next section.


Overfitting and underfitting: how to identify and fix them

Poor settings can overfit the LoRA until details collapse, or underfit it until the intended concept barely appears.

Symptoms of overfitting

Appearance:

  • Details blur, merge, or distort.
  • The LoRA only recognizes poses and scenes from the training set and fails on a new background or angle.
  • Defects such as noise or watermarks from the dataset reappear.

Trigger response:

  • The response is too strong to control; even a weight of 0.3 resembles the training data.
  • Features appear without the trigger, suggesting the concept has become overly entangled.

Symptoms of underfitting

Appearance:

  • The result does not resemble the target, and defining details are weak or missing.
  • The trigger produces little or no response.

Background-change test:

  • The target features remain weak regardless of the background, indicating that the main concept was not learned.

Overfitting versus underfitting

SymptomOverfittingUnderfittingFix direction
Visual detailsCollapsed details; copies the training setWeak resemblance and detailsOverfit: lower LR or steps; underfit: raise LR or improve the data
Background testBreaks when the scene changesTarget remains weak everywhereOverfit: inspect background terms; underfit: check trigger coverage
Trigger responseToo strong and hard to controlWeak or absentOverfit: lower LR or a very high dim; underfit: raise LR, improve data, or reconsider dim
Weight rangeStill copies at 0.3Barely appears at 1.0Overfit: choose an earlier epoch; underfit: continue carefully or improve the dataset

Priority order for fixes

For overfitting:

  1. Lower the learning rate, initially by a meaningful test step such as 50%.
  2. Reduce the total steps or select an earlier saved epoch.
  3. Inspect captions for repeated backgrounds and secondary traits.
  4. Lower dim if it is unnecessarily high.

For underfitting:

  1. Raise the learning rate in a controlled comparison.
  2. Add or improve data when coverage is weak.
  3. Confirm that the trigger appears in every caption.
  4. Raise dim if capacity is clearly too low.

VRAM requirements and low-memory paths: can an RTX 3060 train?

Limited VRAM does not always prevent training, but it forces tradeoffs in resolution, model family, speed, and optimization settings.

Approximate minimum VRAM

Base modelApproximate baseline with fp16 and checkpointingWith additional savingsRelevant options
SD1.5About 8 GBAbout 6 GB in constrained configurationsLower dim, gradient checkpointing, optimizer and precision choices
SDXLAbout 12 GBAround 10 GB in some configurationsLower dim, gradient checkpointing, block or optimizer savings
FLUX.1Often around 24 GB without savingsCan approach 10 GB in heavily optimized setupsBlock swapping, checkpointing, lower dim, and quantization where supported

The roughly 24 GB to 10 GB example comes from a 2025 third-party training guide. Actual use depends on the trainer, model, optimizer, cache settings, dataset, and GPU.

Memory-saving techniques

Fused or memory-efficient backward options: reduce peak memory in supported trainers, but the result varies by implementation.

Gradient checkpointing: trades compute time for memory by recomputing activations during backward passes.

Lower dim: a smaller rank reduces the number of LoRA parameters and usually lowers the memory footprint.

Mixed precision and quantization: fp16 or bf16 is common; some trainers also support FP8 or quantized components, with compatibility and quality tradeoffs.

Low-VRAM tradeoff table

VRAMPractical targetTradeoffSuggested path
6 GBSD1.5 character LoRALow dim, checkpointing, and slower runsStart with SD1.5 and small batches
8 GBSD1.5 character or style LoRALower dim and checkpointingUse mature SD1.5 memory-saving options
10 GBSome SDXL character setupsAggressive savings and slower trainingTest SDXL only with a documented low-memory recipe
12 GB+More SDXL setups; experimental FLUX.1 recipesSavings may still be requiredPrefer SDXL first; treat FLUX.1 as configuration-sensitive

When VRAM is tight, start with SD1.5 rather than assuming an SDXL or FLUX.1 recipe will fit. Its training stack has lower requirements and more mature low-memory practices.


ComfyUI validation: how to test the finished LoRA

One generated image is not enough. Validate the trigger response, detail retention, background transfer, and controllable weight range systematically.

Loading the LoRA

Use ComfyUI’s Load LoRA node to load the trained .safetensors file:

  • Node: Load LoRA, included with ComfyUI
  • Parameters: LoRA file plus model and clip strengths; start near 0.5 and adjust from evidence

Building a prompt template

The validation prompt should contain the trigger and core attributes:

  • Trigger word: place the trained token near the start, such as sks charname.
  • Attribute terms: use important high-frequency features such as hair, palette, and clothing.
  • Scene terms: replace the scene for the background test, for example “in a forest” or “at night.”

Example:

sks charname, blonde hair, blue eyes, white dress, simple background

Background-change test:

sks charname, blonde hair, blue eyes, white dress, in a forest, at sunset

Sweeping the weight range

Test several LoRA weights under identical conditions:

  • weight=0.3: check whether the effect is subtle and controllable.
  • weight=0.5: check whether the target is recognizable at a practical starting strength.
  • weight=1.0: check full strength for distortion or loss of prompt control.

If 0.3 still looks locked to the training data, suspect overfitting. If 1.0 barely resembles the target, suspect underfitting or a trigger and compatibility problem.

Acceptance checklist

CheckPassing resultIf it fails
Trigger responseClear traits at 0.5 and controllable influence at 0.3No response: inspect captions and trigger; excessive response: lower LR or choose an earlier epoch
Detail retentionDefining hair, palette, and clothing remain clearDistorted details: overfit; faint details: underfit
Background transferThe subject remains recognizable while only the scene changesFailure on a new scene: inspect repeated background captions and dataset variety
Weight controlTraits change gradually from 0.3 to 1.0No useful range: revisit the training strength and saved epochs

For loading, weights, stacking, and trigger control, continue with Using LoRA in ComfyUI: Loading, Weights, Stacking, and Character Consistency.

Because the base model controls compatibility and shape mismatches, see Choosing Stable Diffusion Models: Base Model Compatibility for LoRA.

For repeatable validation prompts, use Stable Diffusion Prompt Templates for Testing LoRA Results.

Alternatives that do not require retraining:

  • FLUX.1 Kontext can preserve a character without LoRA training when the dataset is too small or training is not worth the cost.
  • InstantID and IPAdapter FaceID use reference images for face consistency instead of training a LoRA.

How to train and validate your own LoRA

Choose the target, prepare and caption the dataset, set initial training parameters, then test trigger response, detail retention, and background generalization in ComfyUI.

⏱️ Estimated time: 4 hr

  1. 1

    Step 1: Choose the training target and base model

    Decide whether you are training a character, style, or object, then select SD1.5, SDXL, or FLUX.1; the training base controls generation compatibility.
  2. 2

    Step 2: Select and normalize the dataset

    Keep clear images with an obvious subject and varied angles and backgrounds, then crop them to a consistent resolution for the chosen base model.
  3. 3

    Step 3: Generate captions and review them

    Use an appropriate captioning tool, then inspect frequent background terms, essential attributes, and the trigger word in every caption.
  4. 4

    Step 4: Set initial parameters

    Choose dim, alpha, learning rates, and steps or epochs for the target, treating the tables as reproducible starting points rather than universal answers.
  5. 5

    Step 5: Save intermediate epochs

    Save weights at fixed intervals so you can select the version that generalizes well without overfitting.
  6. 6

    Step 6: Validate under fixed conditions in ComfyUI

    Keep the prompt, seed, sampler, and image size fixed while testing weights such as 0.3, 0.5, and 1.0 across different backgrounds.
  7. 7

    Step 7: Adjust from the symptoms

    For overfitting, lower the learning rate or steps and inspect background tags; for underfitting, check the trigger, data volume, learning rate, and dim.

FAQ

How many images do I need to train a LoRA?
Start a character LoRA with 15–30 images; about 10 excellent images can sometimes work. A style often needs 50–100, and an object LoRA commonly starts with 15–30. Prioritize clarity and varied backgrounds and angles.
How should I set network dim and alpha?
Dim controls LoRA capacity, while alpha scales its weights. Common starting points set alpha equal to dim or half of dim. When alpha is lower, tune it together with the learning rate, step count, and validation results.
What learning rate should I use for LoRA training?
A character LoRA can start near a 4e-4 U-Net learning rate, while a style can start near 1e-4; the text encoder is usually lower. These are only starting points to refine against saved epochs and fit symptoms.
How can I train a LoRA with limited VRAM?
Prefer SD1.5, a lower dim, mixed precision, and gradient checkpointing. For SDXL or FLUX.1, use supported options such as block swapping or quantization, accepting slower training or possible quality tradeoffs.
Can I train a LoRA directly in ComfyUI?
Yes, through ComfyUI-FluxTrainer or another training node. These nodes wrap training scripts and some remain experimental, so follow the current node documentation and kohya-ss/sd-scripts guidance for parameters and compatibility.
How do SDXL and FLUX.1 LoRA training differ?
They use different architectures, text encoders, and training scripts, with different VRAM demands and parameters. Use the resulting LoRA with its matching model family rather than assuming file-format compatibility.

13 min read · Published on: Aug 28, 2026 · Modified on: Aug 28, 2026

Comments

Sign in with GitHub to leave a comment

Easton BlogEaston Blog