Swimming Pool Detector (OAM, ONNX 512)
YOLO11m object detector for outdoor swimming pools in satellite and aerial imagery, exported to ONNX with a fixed 512 x 512 input for use with the HOT fAIr platform and OpenAerialMap (OAM) chips.
The weights are those of mozilla-ai/swimming-pool-detector,
unchanged; no further training was done. This repository provides the ONNX export at the size the model was trained at.
Model details
| Architecture | YOLO11m (Ultralytics), single-stage detector, 1 class: swimming_pool |
| Task | Object detection, axis-aligned boxes |
| Source model | mozilla-ai/swimming-pool-detector (model.pt, Ultralytics 8.3.85, checkpoint dated 2025-03-07) |
| Initial weights | yolo11m.pt (Ultralytics), fine-tuned by Mozilla AI |
| Format | ONNX, opset 18, static shapes, exported with Ultralytics 8.4.191 and simplified with onnxslim |
| File | swimming_pool_yolo11m_512.onnx, 80.4 MB |
| SHA-256 | ec20f36a4acc9c49ae50bbf3efb96ea7b146325a7c1826e38732d8073604d5db |
| Input | images: (1, 3, 512, 512) float32, RGB, NCHW, values in [0, 1] |
| Output | output0: (1, 5, 5376) float32 |
| License | AGPL-3.0 |
Training data
| Dataset | mozilla-ai/osm-swimming-pools |
| Imagery | Mapbox satellite imagery (satellite-v9 style), one tile per image |
| Image size | 512 x 512 px |
| Zoom level | 18 |
| Ground resolution | about 0.2986 x cos(latitude) m per pixel (0.30 m at the equator, 0.23 m at 40 degrees latitude); one image spans about 153 x cos(latitude) m |
| Labels | OpenStreetMap leisure=swimming_pool polygons converted to bounding boxes; indoor pools were discarded |
| Size | about 7,400 images |
| Coverage | The dataset is organised in two groups, "Galicia" and "Viana do Castelo" (north-west Iberia) |
| Created with | mozilla-ai/osm-ai-helper |
Training procedure
Fine-tuned by Mozilla AI from yolo11m.pt with Ultralytics (demo/finetune_model.ipynb of osm-ai-helper). Values below
are the ones stored in the checkpoint.
| Hyperparameter | Value |
|---|---|
Image size (imgsz) |
512 |
| Epochs | 10 |
| Early stopping patience | 3 |
| Batch size | 16 |
| Optimizer | AdamW |
Initial learning rate (lr0) |
0.01 |
| Learning-rate schedule | cosine |
| Warmup epochs | 3 |
| Pretrained | yes (yolo11m.pt) |
| Classes | 1 |
| Augmentation | Value |
|---|---|
Vertical flip (flipud) |
0.5 |
Horizontal flip (fliplr) |
0.5 |
| Mosaic | 1.0 (close_mosaic=10) |
| HSV hue / saturation / value | 0.015 / 0.7 / 0.4 |
| Scale | 0.0 |
| Translate | 0.0 |
| Rotation, shear, perspective | 0.0 |
All other settings are Ultralytics defaults of that version.
Intended use
Detecting outdoor swimming pools in very-high-resolution satellite or aerial imagery to support mapping, for example
adding or checking leisure=swimming_pool features in OpenStreetMap through fAIr. Imagery at zoom 18 (about 0.3 m
per pixel at the equator) matches the training data.
Out of scope: indoor pools, other object classes, and imagery whose ground resolution is far from the training scale unless it is resampled first (see below).
Input and output
| Colour | RGB, three bands |
| Size | 512 x 512 (fixed) |
| Range | float32 in [0, 1], that is pixel value divided by 255 |
| Normalisation | None inside the graph (the first node is a convolution) and no mean or std |
| Output rows | cx, cy, w, h in input pixels, then the pool score (sigmoid) |
| Anchors | 5376 (64 x 64 + 32 x 32 + 16 x 16) |
| Post-processing | The confidence filter and non-maximum suppression are not in the graph and must be applied by the caller |
Matching the training scale
A standard 256 px XYZ tile of zoom 18 covers the same ground as one training image; resizing it to 512 x 512 gives the training scale. For imagery at another zoom, build the 512 px input from the ground extent that a zoom-18 tile would cover (for example stitch neighbouring tiles and downsample) instead of only resizing the chip. Resizing a zoom-20 chip alone shows pools about four times larger than in training.
Usage
import sys
import numpy as np
import onnxruntime as ort
from PIL import Image
SIZE = 512
def iou_of(a, b):
w = max(0.0, min(a[2], b[2]) - max(a[0], b[0]))
h = max(0.0, min(a[3], b[3]) - max(a[1], b[1]))
inter = w * h
return inter / ((a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - inter + 1e-9)
def detect(session, image_path, confidence=0.25, iou=0.45):
"""Boxes `x1, y1, x2, y2, score` in the pixels of the image passed in."""
image = Image.open(image_path).convert("RGB")
width, height = image.size
resized = image.resize((SIZE, SIZE), Image.Resampling.BILINEAR)
x = np.asarray(resized, dtype=np.float32).transpose(2, 0, 1)[None] / 255.0 # RGB, NCHW, [0, 1]
cx, cy, w, h, score = session.run(None, {"images": x})[0][0]
keep = score > confidence
cx, cy, w, h, score = cx[keep], cy[keep], w[keep], h[keep], score[keep]
boxes = np.stack([cx - w / 2, cy - h / 2, cx + w / 2, cy + h / 2], axis=1)
kept = []
for i in score.argsort()[::-1]: # greedy non-maximum suppression
if all(iou_of(boxes[i], boxes[j]) <= iou for j in kept):
kept.append(i)
boxes = boxes[kept] * [width / SIZE, height / SIZE, width / SIZE, height / SIZE]
return np.column_stack([boxes, score[kept]])
session = ort.InferenceSession("swimming_pool_yolo11m_512.onnx", providers=["CPUExecutionProvider"])
print(detect(session, sys.argv[1]))
The confidence threshold of 0.25 and NMS IoU of 0.45 are starting values; the best confidence depends on the imagery and should be chosen on labelled chips of the target area.
Evaluation
Precision, recall and mAP for this export on OAM imagery have not been published. The ONNX output was compared with
the source model.pt on a seeded random 512 x 512 input: the largest difference was 0.0006 px on the box rows and
1.2e-7 on the scores, so the export reproduces the checkpoint.
Limitations and bias
- Trained on Mapbox satellite imagery from one region; pools in other regions, roof types, construction styles, seasons or sensors (for example very-high-resolution drone imagery) may be detected less reliably.
- Labels come from OpenStreetMap, which is incomplete and uneven: unmapped pools appear as background in the training data.
- Detects outdoor pools only and returns boxes, not pool outlines.
- Results depend on the ground resolution of the input; see "Matching the training scale".
License and attribution
Released under AGPL-3.0, like the source model and Ultralytics YOLO.
- Model and training: Mozilla AI,
mozilla-ai/swimming-pool-detector - Training labels: © OpenStreetMap contributors, ODbL
- Training imagery: Mapbox satellite imagery, subject to Mapbox terms
- Framework: Ultralytics YOLO11