Automate 3000+ Apps AI Support Chatbot Rent Cloud GPUs Smart Forms Free Rank In AI Search Track Your Rankings
Automate 3000+ Apps AI Support Chatbot
Free Email Marketing AI Data Analyst Funnels + Email Free AI Agent Workspace Build AI Apps No Code No-Code AI Agents
Home » Local AI Image Generation on Mac » Train a LoRA on a Mac

How to Train a LoRA on a Mac From the Command Line

To train a LoRA on a Mac, put your images in a folder with a caption text file beside each one, write a short JSON config that names the model and the LoRA layers, and run mflux-train --config train.json. The run saves a checkpoint zip every so many steps, and inside each zip is the LoRA as a .safetensors file you can load into any generate command. It works on Apple Silicon with no NVIDIA card, 32 GB of memory is the comfortable starting point, and 15 to 40 images is enough for most subjects and styles.

What You Are Actually Training

So a LoRA is not a new model, it is a small set of extra weights that sits on top of an existing one and nudges it. The base model stays frozen and untouched, and the only thing that learns is the add on, which ends up as a file of a few MB to a few hundred MB next to a base model of 10 GB or more. That is why it can be done on a laptop at all, you are training well under 1% of the numbers.

A LoRA basically means "this model, plus the thing I showed it". The thing can be a person, a character, a product, an art style or a type of object. It cannot teach the model something the base has no ability for, so if the base model is bad at hands, your LoRA will have bad hands too.

mflux trains LoRAs for Z-Image, FLUX.2 klein, Krea 2, Qwen Image 2.1, ERNIE-Image, Iris-3B, Anima and FIBO 2. The old FLUX.1 is not supported for training any more, so guides from 2024 and 2025 that train on FLUX.1 dev with mflux no longer match the tool.

Which Model to Train On

Z-Image Turbo is the easy first pick, it is small at 6B parameters, quick to preview because it generates in 9 steps, and mflux loads a special training adapter for it automatically. FLUX.2 klein is the other strong option, and it comes with a rule that looks optional and is not: you train on the base version, flux2-klein-base-4b or flux2-klein-base-9b, then use the result with the fast distilled version for generating. Training on a distilled model directly tends to break the thing that makes it fast. Qwen Image 2.1 follows the same rule, train on base, not Turbo.

Step by Step

Step 1: Install mflux. If it is not installed yet, the full walkthrough is in the mflux install guide. The short version is 2 commands.
brew install uv
uv tool install --upgrade mflux
Step 2: Build the data folder. mflux reads pairs, an image and a text file with the same name holding the caption. Files named preview are different, they are prompts the run uses to make test images as it goes, so you can see the LoRA taking shape.
my-lora/
  train.json
  images/
    01.png
    01.txt
    02.jpg
    02.txt
    03.jpg
    03.txt
    preview_1.txt
    preview_2.txt

Each .txt file is a plain sentence describing its image. A preview file is a prompt for an image you want to see during training, like "a photo of zxq dog sitting on a beach", and if there are no preview files the run falls back to the first training caption. How to pick, crop and caption the images is its own subject, covered in building a LoRA training dataset.

Step 3: Write the training config. Save this as train.json in the project folder. This follows the Z-Image Turbo example in the mflux docs, with the epoch count set for a small dataset, and it is a good starting point as it stands.
{
  "model": "z-image-turbo",
  "data": "images/",
  "seed": 4,
  "steps": 9,
  "guidance": 0.0,
  "quantize": 8,
  "training_loop": { "num_epochs": 50, "batch_size": 1, "timestep_low": 4, "timestep_high": 9 },
  "optimizer": { "name": "AdamW", "learning_rate": 1e-4 },
  "checkpoint": { "output_path": "training", "save_frequency": 30 },
  "monitoring": {
    "plot_frequency": 20,
    "generate_image_frequency": 30
  },
  "lora_layers": {
    "targets": [
      { "module_path": "layers.{block}.attention.to_q", "blocks": { "start": 15, "end": 30 }, "rank": 8 },
      { "module_path": "layers.{block}.attention.to_k", "blocks": { "start": 15, "end": 30 }, "rank": 8 },
      { "module_path": "layers.{block}.attention.to_v", "blocks": { "start": 15, "end": 30 }, "rank": 8 }
    ]
  }
}

Reading it top to bottom: model is what you are training on, data is the folder from step 2, and quantize 8 trains against an 8 bit copy to save memory. num_epochs is how many times the run goes through all your images, so 20 images at 50 epochs is 1000 training steps. learning_rate is how big each adjustment is. save_frequency is how many steps between checkpoints, and generate_image_frequency is how many steps between preview images. The lora_layers block says which parts of the model get the add on and how big it is (the rank). What to change and when is in LoRA training settings explained.

Step 4: Start the run. From inside the project folder, 1 command.
cd my-lora
mflux-train --config train.json

The first thing it does is load the model, and for training mflux uses the full weights and quantizes them as they load, so if you have only ever downloaded a small quantized copy, expect a larger download here. Then it starts stepping. Each step is slower than a generation step because the Mac is working out how to adjust the LoRA, not just running the model forward.

If you need the Mac back, stop the run with Control C and pick it up later from the last checkpoint. The original data folder has to still be there for the resume to work.

mflux-train --resume training/checkpoints/0000300_checkpoint.zip
Step 5: Watch the loss plot and the previews. The run writes 3 folders inside the output path, and 2 of them are for you to look at while it works.
training/
  checkpoints/
    0000030_checkpoint.zip
    0000060_checkpoint.zip
  loss/
    loss.html
  preview/
    0000000_preview_image_preview.png
    0000030_preview_image_preview.png
    0000060_preview_image_preview.png

Open loss/loss.html in a browser for the loss curve, which is a rough measure of how wrong the model's guesses are on your images. It should drift down and flatten, with a lot of noise on the way. The previews matter more than the curve. Flip through them in order and you can watch your subject appear, first vaguely, then clearly. The best checkpoint is usually not the last one, it is the one where the subject looks right and the preview still follows the rest of the prompt.

Step 6: Take the LoRA out of the checkpoint. Each checkpoint zip is a full snapshot of the run, and the LoRA itself is 1 file inside it, named with the step number and the word adapter.
cd training/checkpoints
unzip 0000600_checkpoint.zip -d step600
ls step600
# 0000600_adapter.safetensors is the LoRA
cp step600/0000600_adapter.safetensors ~/models/loras/my-subject.safetensors
Step 7: Generate with it. Load the file with --lora-paths and set the strength with --lora-scales. Use the trigger word from your captions in the prompt.
mflux-generate-z-image-turbo \
  --prompt "a photo of zxq dog wearing a red scarf in the snow" \
  --steps 9 \
  -q 8 \
  --lora-paths ~/models/loras/my-subject.safetensors \
  --lora-scales 1.0

If the subject is too weak, raise the scale to 1.1 or 1.2, or go back and try a later checkpoint. If every image looks like a copy of a training photo no matter what the prompt says, the LoRA is overtrained, so lower the scale to 0.7 or use an earlier checkpoint.

Memory Settings That Decide Whether It Runs

Training needs a lot more memory than generating, because the Mac has to keep the intermediate results from every layer to work backward through them. There are 3 settings in the config that trade speed for memory:

The mflux docs are specific about when to use them: turn on gradient checkpointing when a run is killed at the first training step, and it is what makes FLUX.2 klein training fit on 32 to 36 GB machines. On a 64 GB Mac you can usually leave it off and take the faster steps. There is also "max_resolution", which caps the image size used in training, and dropping it from 1024 to 768 saves memory and time with a small cost in fine detail.

How Long It Takes

It depends on the chip, the model and the step count, and the honest range is wide, from under an hour on a recent Max chip with a small model, to overnight on an older or base chip. The math is simple once you see your own speed, the run prints the time per step, so multiply that by images times epochs. 25 images at 40 epochs is 1000 steps, at 5 seconds a step that is about 85 minutes, at 20 seconds a step it is 5 and a half hours. Preview images add time too, each one is a full generation, so a high preview frequency on a long run adds up.

When Training on the Mac Is the Wrong Call

Now the case where it flips. If you have a 16 GB Mac, or you need the LoRA in an hour and the Mac says 8, or you want to train a video model, renting an NVIDIA card for a couple of dollars is the better move, and the options are in where to train a LoRA for free. Training locally makes the most sense when your images are private, when you want to run many experiments without watching a meter, or when you simply want to learn how the thing works by doing it.

Judge by the preview images, not the loss number. Save checkpoints often, write 2 or 3 preview prompts that put your subject in situations the training photos never showed, and pick the checkpoint where the subject is right and the prompt is still being followed. That 1 habit fixes most bad LoRAs.