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 » Build a LoRA Dataset

How to Build and Caption a LoRA Training Dataset on a Mac

A LoRA dataset is a folder of 15 to 40 images, each with a text file of the same name holding a 1 sentence caption. The images should show your subject clearly with as much variety in everything else as you can get, and every caption should include 1 made up trigger word plus a plain description of what is in the picture. On a Mac you can resize the images with the built in sips command and draft the captions with a local vision model, so the whole dataset can be made from the terminal without uploading anything.

Why the Dataset Matters More Than the Settings

So when a LoRA comes out bad, people reach for the settings first, the learning rate, the rank, the step count. Most of the time the problem is the images. The model learns whatever your images have in common, and it has no idea which common thing you meant. If all 20 photos of your dog are on the same couch, the couch is part of the dog as far as the LoRA knows, and it will put that couch in the desert, on the moon and underwater.

So the whole job comes down to 1 rule: keep the thing you want learned the same in every image, and change everything else. Same subject, different backgrounds, different lighting, different angles, different distances. A dataset basically means "here is the 1 thing that does not change", and the captions are how you tell the model what the changing parts are so it does not blame them on your subject.

How Many Images You Need

Fewer than people think. For 1 person, character, pet or product, 15 to 30 good images is the normal range, and 10 can work if they are varied. For an art style, 30 to 60 is better, because a style has to be learned across many different subjects before the model stops copying the subjects themselves. More than 100 rarely helps a simple LoRA and makes training take longer.

20 strong images beat 60 mixed ones every time. Every weak image you add, blurry, badly cropped, heavily filtered, teaches the LoRA that blur, bad crops and filters are part of the subject.

Step by Step

Step 1: Collect more than you need, then cut hard. Start with 2 or 3 times the final count and remove anything that is blurry, tiny, watermarked, has text over it, shows other people or objects covering the subject, or is nearly identical to another shot. For a person or character, aim for a mix of roughly half close ups of the face, a quarter from the waist up, and a quarter full body.
Step 2: Copy, rename and resize. Work on copies, never your originals, since the resize command below changes files in place. sips ships with macOS, and -Z 1024 scales each image so its longest side is 1024 pixels while keeping the shape.
mkdir -p ~/my-lora/images
cp ~/Pictures/lora-picks/* ~/my-lora/images/
cd ~/my-lora/images

# rename to 01.jpg, 02.jpg, ...
n=1
for f in *.jpg *.jpeg *.png; do
  [ -e "$f" ] || continue
  ext="${f##*.}"
  mv "$f" "$(printf '%02d' $n).$ext"
  n=$((n+1))
done

# cap the long side at 1024 pixels
sips -Z 1024 *.jpg *.jpeg *.png

If you have HEIC photos from an iPhone, convert them first, since trainers expect PNG, JPG or WEBP:

for f in *.HEIC; do sips -s format jpeg "$f" --out "${f%.HEIC}.jpg"; done

You do not need to crop everything to a square. Modern trainers handle mixed shapes, and keeping some wide and some tall images helps the LoRA work at different output sizes. What you should crop is anything where the subject is small in the frame, cut in closer so the subject fills a good part of the picture.

Step 3: Pick a trigger word. This is the word that will mean "my subject" in prompts. It should be short and made up, so the model has no existing idea attached to it. Something like zxq or ohwx works, a real word like "max" or "bella" does not, the model already has thousands of pictures in its head for those.

Put a class word right after it, the plain category the subject belongs to: zxq dog, zxq woman, zxq sneaker. The class word lets the LoRA borrow everything the model already knows about dogs or sneakers and only learn what makes yours different. For a style LoRA the trigger describes the look, like in zxq style.

Step 4: Write the captions. Each image gets a text file with the same name, 01.jpg gets 01.txt. Write 1 plain sentence: the trigger and class word, then what is going on in the picture.
echo "a photo of zxq dog sitting on a wooden porch, late afternoon sun, looking at the camera" > 01.txt
echo "a close up photo of zxq dog lying on green grass, tongue out, blurred trees behind" > 02.txt

The rule that surprises people is what to leave out. Describe everything you want to be able to change later, the background, the lighting, the pose, the clothes. Do not describe the features that define the subject. If your dog has 1 white ear and you write "with one white ear" in every caption, you have told the model the white ear is a separate optional thing, and it will only show up when you ask. Leave it out and it becomes part of what zxq dog means.

For a style LoRA it flips. Describe the content of each image in full, the people, objects and scene, and say nothing about the style except the trigger. Then the style is the 1 thing left over for the trigger to absorb.

Drafting Captions With a Local Vision Model

Writing 30 captions by hand takes maybe 20 minutes. If you would sooner have the Mac draft them, mlx-vlm runs vision models locally, the same family of tools mflux is built on. Install it and test it on 1 image:

pip install -U mlx-vlm

mlx_vlm.generate \
  --model mlx-community/Qwen2-VL-2B-Instruct-4bit \
  --max-tokens 100 \
  --temperature 0.0 \
  --image 01.jpg \
  --prompt "Describe this photo in one plain sentence. Mention the setting, lighting and pose."

That small 2B model is light enough for a 16 GB Mac. A bigger vision model writes better captions if you have the memory for it. The command prints its answer to the terminal along with some run details, so the simplest reliable workflow is to run it per image, read what it wrote, and paste the sentence into the matching text file with your trigger word added at the front. It is slower than a fully automated loop, and it forces the review that step 5 asks for anyway.

Step 5: Read every caption against its image. Vision models make things up, they will call a brown dog black or add a ball that is not there. A wrong caption teaches a wrong thing, so this pass is not optional. Check that the trigger and class word are in every file, the wording is consistent, and nothing describes the subject's own permanent features.
# list any image that has no caption file
for f in *.jpg *.png; do [ -e "${f%.*}.txt" ] || echo "missing caption: $f"; done

# confirm the trigger word is in every caption
grep -L "zxq" *.txt
Step 6: Add preview prompts. These are prompts the trainer turns into test images as it runs. Write 2 or 3, and make them put the subject somewhere the training images never did, since that is the real test of whether the LoRA learned the subject or just memorized the photos.
echo "a photo of zxq dog wearing a red scarf, standing in deep snow" > preview_1.txt
echo "a watercolor painting of zxq dog on a sailboat" > preview_2.txt

What the Finished Folder Looks Like

my-lora/
  images/
    01.jpg   01.txt
    02.jpg   02.txt
    ...
    24.png   24.txt
    preview_1.txt
    preview_2.txt

That folder is ready for training a LoRA on a Mac, the config file points at it with "data": "images/".

The Mistakes That Cost the Most

The same background or outfit in most images. It gets baked in. If you cannot get variety, at least describe the repeated thing in every caption so the model has a chance of separating it.

Other people or pets in the frame. The LoRA cannot tell which one is the subject. Crop them out or drop the image.

Heavy filters, beauty modes and upscaled images. The LoRA learns the filter. Use the plainest, sharpest originals you have.

Mixing ages or looks. Photos of a person across 15 years average into someone who does not exist. Keep to 1 period and 1 general look.

Images you do not have the rights to. Training a style on a living artist's work, or a LoRA of a real person without their permission, is a legal and ethical problem that the tool will not stop you from creating. Use your own photos, your own art, or images you are licensed to use.

Variety in everything except the subject. Before training, scroll through the folder fast and ask what repeats besides the subject. Whatever you spot, a wall, a shirt, a camera angle, either fix it with different images or name it in the captions. That 1 check does more for the result than any training setting.