pool-segmentation / README.md
nlateralus's picture
Model 20261119-231345, validation water IoU 0.996
b484048 verified
|
Raw History Blame Contribute Delete
2 kB
metadata
license: mit
pipeline_tag: image-segmentation
tags:
  - pytorch
  - u-net
  - swimming-pool
  - semantic-segmentation

pool-segmentation: a swimming pool's water

A small U-Net (resnet18 encoder) that finds a swimming pool's water in video frames: a class for every pixel, 0 other, 1 water (swimmers in the water, splashes and lane ropes count as water). About 25 ms per frame on a MacBook. Made for swimming video analysis (dropping people outside the pool; later, finding the lanes).

Code, training and labeling tools: github.com/Neptune-Trojans/pool-segmentation (pip install pool-segmentation).

Use

from pool_segmentation import PoolModel, find_model

model = PoolModel.load(find_model())   # your newest training run in data/models/pool/, else this model
classes = model.predict(frame)         # BGR frame -> class per pixel: 0 other, 1 water
water = model.water(frame)             # the water's outline: one polygon [(x, y), ...] per piece of water

The package downloads this model the first time it is needed and keeps it in ~/.cache/huggingface; when online, it gets a newer one when there is one. A given version: find_model("hub:20261119-231345") (every version is tagged with its training run).

This version

Training run 20261119-231345
Classes 0 other, 1 water
Input frames scaled to 1024×576 (the long side; shape kept)
Training 89 hand-checked frames from 9 videos, 40 epochs
Validation 19 frames (every 6th of each video): water IoU mean 0.996, worst 0.990

Limits

Trained on frames filmed at a few pools, from the deck. Pools that look very different (another camera angle, light, water color) may need some frames of their own: the package's labeling tools pick frames from your videos, let this model label them, and you check them in the browser before training again. The training frames are not published: they show real people.