Skip to content

Synthetic-to-Real Object Detection

An object detector trained only on synthetic images, built to work on real photos.

Result
mAP@50 0.9175 private, 0.9074 public
My role
Everything: training, tuning, submission
Team
Solo

Highlights

  • Scored mAP@50 0.9175 on real photos (private leaderboard) with a detector trained on 431 synthetic images only.
  • Lost 7.6 points of mAP@50 between synthetic validation (0.9935) and real photos, the gap the challenge measures.
Two photos of a Cheerios box side by side, labelled Real and Synthetic, each with a detection box and a 0.99 confidence score

The problem

The Synthetic to Real Object Detection Challenge on Kaggle, with a dataset from Duality AI, asks for a detector that finds a Cheerios box in real photos after training on synthetic images only. Models trained that way often fail in real-world conditions, and the competition calls this the Sim2Real gap.

Kaggle scores entries by mAP@50, mean average precision in which a predicted box counts as correct when it overlaps the true box by at least half (IoU 0.5). The public leaderboard scores half of the real test images; the private leaderboard scores the other half and sets the final ranking.

What I built

This was a solo entry. The organizers gave every entrant a starter kit: a YOLOv8 training script, a prediction script, a script that turns predictions into the submission file, and batch files that set up a Conda environment. The repository holds my versions of those files, the training run behind the submission, its predictions and the submitted CSV.

I fine-tuned YOLOv8s, the small YOLOv8 model, from its pretrained weights on the 431 synthetic training images, checking it after each epoch against 69 synthetic validation images.

How it works

The saved run trained for eight epochs on a CPU at 640 pixels, in batches of eight, with the Adam optimizer at a learning rate of 0.0001 and every object treated as one class. It took about 103 minutes. Augmentation is the Ultralytics set: mosaic at a probability of 0.3, mixup at 0.1, random shifts in hue, saturation and brightness, translation, scaling and horizontal flips. The rotation setting stayed at zero degrees.

Prediction runs the best checkpoint over each real test photo with a confidence threshold of 0.015 and writes every box as a class, a confidence, a centre, a width and a height, scaled to the image. The threshold is low on purpose: mAP ranks boxes by confidence, so a weak box that turns out right still counts.

The conversion script keeps only prediction files that match a test image, drops any line without six numbers, and writes "no box" for a photo with no detection. Five of the 164 test photos got none.

Results

Kaggle leaderboard scores, mAP@50 on real photos
LeaderboardmAP@50
Private (final ranking)0.9175
Public0.9074

On the 69 synthetic validation images, the last epoch reached mAP@50 0.9935 and mAP@50-95 0.9746, against 0.9175 and 0.9074 on real photos.

Limits and next steps

  • The validation images are synthetic, so the score during training says little about real photos. I had no labelled real images to check against before submitting.
  • I also tried YOLOv8n and YOLOv8m and stronger augmentation, but kept only the YOLOv8s run, so I cannot show what those experiments found.
  • Eight epochs on a CPU is a short run, and with one run there is no measure of how much the score moves between runs.

Stack

  • Python 3.10 in a Conda environment
  • PyTorch
  • Ultralytics YOLOv8 (YOLOv8s, pretrained weights)
  • pandas for the submission CSV

Published , updated