Overview

13 Training a Flux LoRA

This chapter explains how to train a custom Flux LoRA using the AI-Toolkit, with Keats the dog serving as the example subject. It emphasizes that training requires substantial VRAM, so a 24GB GPU is recommended, though hosted training services can be used instead. The setup begins by installing and launching the AI-Toolkit, which provides a browser-based interface for managing datasets, configuring jobs, and monitoring training progress.

The heart of the process is building a strong dataset. The chapter stresses that image quality, diversity, and careful labeling matter more than fancy model choices, even when only 10 to 30 images are needed. Captions should include a consistent trigger phrase while also describing relevant details in the scene, especially distinguishing the subject from recurring accessories or background elements. Good captions help the model learn the intended concept without confusing unrelated features as part of the subject.

After the dataset is prepared, the training job is configured with mostly default settings, but with attention to the correct model architecture, save frequency, total steps, and sample prompts. The sample images generated during training are used to judge progress, detect overfitting, and choose the best checkpoint, since different step counts can produce different tradeoffs between fidelity and flexibility. By examining prompts that mirror the dataset, place the subject in new environments, test different styles, and compare similar-but-different subjects, the chapter shows how to select an effective LoRA checkpoint and use it to generate convincing customized images.

Keats staring at the window waiting for family to return
The AI-Toolkit as it appears in the browser.
A few photos of Keats that we’ll be using.
With our data ready, it’s time to create a new dataset
Naming our new dataset.
Our new dataset with images of Keats waiting to be captioned!
An image of Keats we need a good caption for.
Creating a new training job.
Naming our job and specifying our trigger word.
Make sure you choose FLUX.1 as your Model Architecture.
Modifying the Save Configuration.
The Training Configuration can be largely left alone, but it’s good to bump up the initial steps.
It’s very important to make sure you’re using the correct dataset!
Sample prompts are very helpful when debugging a training job.
Hit “Create Job” and we’ll be good to go.
This screen will update us about the progress of our job once we hit the ‘play’ button.
None of our initial prompts look like Keats.
Running under full load for hours, your GPU is functionally a space-heater
After training is done, we can see the transformation of the generated images.
Training did alter these images a bit, but not enough to be concerned.
In these images we’re trying to figure out when Keats starts to look like “Keats”.
Exploring how well the stylized Keat looks.
The other dogs start to look more and more like Keats.
Even changing the trigger word to “Keatsie” does not remedy this problem.
We can now use any of the LoRA we saved.
AI Keats is very proud of your work!

Summary

  • The AI-Toolkit is useful open source software that makes it easy to train Flux LoRAs.
  • First, we need to collect and label training data.
  • Images used should be high quality and present the subject in a variety of environments and poses.
  • Labeling out data involves adding captions that describe the images.
  • You should choose a trigger word that is reflective of the subject, but not confusing with things the model may have been trained on.
  • Although labeling data can be very tedious and time consuming, it is often the most important step. Make sure you take your time and provide descriptive captions.
  • Training ultimately requires just a few tweaks to get going.
  • It’s very important to establish prompts that will generate images for a range of scenarios to help you debug your training.
  • When choosing a final LoRA look for the earliest stage where the model correctly represents your subject, but be cautious about other subjects that might end up being distorted.

FAQ

What tool is used to train a Flux LoRA in this chapter?The chapter uses the AI-Toolkit to train a Flux LoRA. It provides a browser-based UI for managing datasets, configuring training jobs, and monitoring progress.
How much VRAM is needed to train a Flux LoRA locally?Training a Flux LoRA is extremely VRAM intensive and requires 24GB of VRAM. If you do not have that hardware, the chapter suggests using a commercial service such as fal.ai.
How many images do I need to create a custom LoRA?You typically only need about 10 to 30 images for a custom LoRA, which is far fewer than the millions or billions used to train a foundation model.
What makes good training images for a LoRA?Good training images should be reasonably high quality, not overly compressed, and close to the kind of output you want to generate. They should also show the subject from a variety of angles, distances, and poses.
Why is image diversity important in LoRA training data?Diversity helps the model learn what is truly part of the subject versus what is just background or a repeated accessory. Showing different poses, viewpoints, and contexts reduces the chance of the model overfitting to one scene or object.
What are trigger words, and why do they matter?Trigger words are the phrase you use in captions to teach the model the concept you want it to learn. They should be descriptive, memorable, and not too common in the model’s original training data.
Why should captions include more than just the trigger word?If captions only contain the trigger word, the model may not learn what is and is not part of the subject. Adding details about pose, background, and accessories helps the model separate the subject from other elements in the image.
What training settings are most important to adjust?The chapter recommends setting the model architecture to FLUX.1, increasing the training steps to around 6000, setting Save Every to 250, and keeping several checkpoints. It also recommends setting Caption Dropout Rate to 0.0.
Why are sample prompts useful during training?Sample prompts let you see how the LoRA is changing over time. They help you judge whether the model is learning the subject, overfitting, or changing unrelated prompts too much.
How do you choose the best checkpoint for the final LoRA?You compare sample images across training checkpoints and look for the point where the subject looks correct without overtraining. In the chapter’s example, step 5500 was chosen because it best balanced subject accuracy and generalization.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Local Image Generation ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Local Image Generation ebook for free