temperwork Blog Documentation

Fine-Tuning Qwen on Coco

In Base vs Fine-Tuned: Coco, a model fine-tuned on Coco, a mini bernedoodle, beat the base model on every photo. Here's how we made it: 29 photos, one pipeline to prepare them, and one training run.

Teaching an edit with before and after

An image-editing model learns from pairs: a before image, an instruction, and the after image the instruction should produce. Fine-tuning a LoRA on a few dozen pairs teaches the model one new edit without retraining it.

We wanted the edit "add Coco to this photo". The afters were easy: our own photos of her. The befores had to be the same photos with Coco taken out.

Making the befores

Rather than editing 29 photos by hand, we let a model do it. A one-step pipeline runs Qwen Image Edit 2511 over the whole dataset with one prompt:

Removal prompt
"Remove the dog from this photo completely, including its leash, harness and shadow. Fill in where it was with the background that would be behind it, matching the light, perspective and texture of the rest of the scene. Change nothing else."

We also tried a search-and-replace model built on Stable Diffusion 3.5. Because both run as a pipeline over the same photos, comparing them took one look:

OriginalStable Diffusion 3.5Qwen Image Edit 2511
SD 3.5 leaves a hazy smudge and blurs the pine cone; Qwen fills in clean gravel and keeps it.
SD 3.5 leaves a bare patch in the flowers; Qwen continues them and removes the leash.
SD 3.5 replaces Coco with a pillow; Qwen leaves the sofa empty.
SD 3.5 keeps her shadow on the floor; Qwen removes it with the leash.

Qwen's befores were cleaner across the set, so we trained on those. Leftover smudges matter here: the model would learn that "add Coco" also means "fix a smudge".

The training pairs

Every pair gets the same instruction, which becomes the prompt the fine-tuned model answers to: "Add cocodoodle dog to this photo." Twenty-nine pairs like these:

Training it in temperwork

Creating a LoRA takes a name, a base model, the instruction, and the two datasets. temperwork matches befores to afters by file name and counts the pairs.

Create a LoRA: before and after datasets, one instruction, 29 pairs.

We kept the defaults for Qwen Image Edit 2511:

Training steps2,000
LoRA rank16
Learning rate1e-4, AdamW (8-bit)
Resolutions512, 768 and 1,024 px buckets
Checkpointsone every 250 steps

The training page follows the run step by step. Each checkpoint lands in the LoRA library as soon as it's saved, ready to use in a pipeline while training continues.

The training, done.
The final LoRA and its seven checkpoints in the library.

Picking the best checkpoint

A training run produces a family of candidates, not one model. Instead of guessing, we ran every checkpoint over photos Coco has never been in and let a panel of LLM judges grade the results. That's the second half of the story: Base vs Fine-Tuned: Coco.

What we'd change next time

The model learns everything the afters have in common, not only Coco. Most of her photos have a collar, harness or leash, so it adds one. Each fix is another pass through the same loop: prepare, train, judge.

  • More photos. Well past 29, in more places, poses and light.
  • Cleaner afters. Remove collars, harnesses and leashes from the training photos with the same removal pipeline, or name them in per-image instructions.
  • A trigger word that isn't a word. When the LoRA is weak, the base model reads "cocodoodle" as a request for a doodle.