Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
42edce0
feat(yolo): add YOLOv8-v1 and YOLOv8-v2 models with pipelines, Docker…
AbdelrahmanKatkat Mar 1, 2026
d353104
feat(pipeline): enhance YOLOv8 pipelines with hyperparameter loading …
AbdelrahmanKatkat Mar 2, 2026
6e107e7
feat(yolo): remove YOLOv8-v1 model and associated files
AbdelrahmanKatkat Apr 8, 2026
c395a79
Merge branch 'master' into feature/yolo
AbdelrahmanKatkat Apr 8, 2026
db47d07
Merge pull request #22 from hotosm/feature/yolo
AbdelrahmanKatkat Apr 8, 2026
92800f5
feat(pipeline): update preprocessing to return data loader for ZenML …
AbdelrahmanKatkat Apr 8, 2026
57d432f
Merge branch 'feature/yolo' of https://github.com/hotosm/fAIr-models …
AbdelrahmanKatkat Apr 8, 2026
95b566b
refactor(pipeline): streamline code formatting and improve readability
AbdelrahmanKatkat Apr 9, 2026
8397616
Merge pull request #24 from hotosm/yolo_ci_fix
kshitijrajsharma Apr 9, 2026
9c5e676
feat(pipeline): add dataset splitting functionality for YOLO model
AbdelrahmanKatkat Apr 9, 2026
261a00c
feat(pipeline): enhance preprocessing function to return data loader
AbdelrahmanKatkat Apr 9, 2026
c76c07a
Merge branch 'yolo_ci_fix' into feat/abdul/yolo
AbdelrahmanKatkat Apr 9, 2026
d3c0e64
feat(pipeline): enhance YOLO preprocessing and dataset splitting
AbdelrahmanKatkat Apr 9, 2026
79735a8
fix(pipeline): correct dataset_yaml formatting in split_dataset function
AbdelrahmanKatkat Apr 9, 2026
b695f5c
Merge pull request #32 from hotosm/master
kshitijrajsharma Apr 12, 2026
114797c
Merge branch 'master' into feat/abdul/yolo
AbdelrahmanKatkat Apr 12, 2026
35239ca
Merge branch 'feat/abdul/yolo' of https://github.com/hotosm/fAIr-mode…
AbdelrahmanKatkat Apr 12, 2026
42c35a1
feat(yolo): implement affine transformation patch for YOLO label writ…
AbdelrahmanKatkat Apr 13, 2026
27470f1
chore(tests): update default epochs to 10 for smoke tests and adjust …
AbdelrahmanKatkat Apr 13, 2026
2ec7153
feat(yolo): add YOLOv8 segmentation model with Docker support, pipeli…
AbdelrahmanKatkat Apr 16, 2026
c093cd1
Merge branch 'master' into feat/abdul/yolo
AbdelrahmanKatkat Apr 16, 2026
5d9df3f
refactor(yolo): update type hints and improve code readability; add p…
AbdelrahmanKatkat Apr 20, 2026
9957984
Merge branch 'master' into feat/abdul/yolo
AbdelrahmanKatkat Apr 20, 2026
50bff4a
refactor(yolo): update hyperparameter keys in stac-item.json and adju…
AbdelrahmanKatkat Apr 20, 2026
bc006e5
feat(tests): add provider information to dataset STAC item in test co…
AbdelrahmanKatkat Apr 20, 2026
1f43bfe
feat(yolo): add validation split handling and update Dockerfile for i…
AbdelrahmanKatkat Apr 20, 2026
f5950a9
fix(export_onnx): change return type to bytes and add file existence …
AbdelrahmanKatkat Apr 20, 2026
248d514
feat(pipeline): enhance inference_pipeline to accept inference parame…
AbdelrahmanKatkat Apr 20, 2026
1e79337
fix(pipeline): handle empty data stream in postprocess function and r…
AbdelrahmanKatkat Apr 20, 2026
707bd70
refactor(pipeline): update return type hint for run_inference functio…
AbdelrahmanKatkat Apr 20, 2026
f0b4257
feat(pipeline): implement ONNX image preprocessing, NMS, and YOLO out…
AbdelrahmanKatkat Apr 20, 2026
f47d160
refactor(pipeline): reorganize and optimize image preprocessing, feat…
AbdelrahmanKatkat Apr 20, 2026
9deb037
Revert branch to state at 707bd709
AbdelrahmanKatkat Apr 21, 2026
72eda29
feat(pipeline): add prediction functionality and enhance dataset hand…
AbdelrahmanKatkat Apr 21, 2026
3f9c84e
refactor(tests): clean up test_split_dataset by removing unused impor…
AbdelrahmanKatkat Apr 21, 2026
f12c9be
fix(tests): add missing newline in test_split_dataset for improved re…
AbdelrahmanKatkat Apr 21, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,16 @@ implementation.md

# data
data/sample/predict/predictions
data/sample/ramp_work
data/sample/yolo_work
stac_catalog

# runs
runs/

# weights
yolov8s_v2-seg.pt

# hatch-vcs generated version file
fair/_version.py

Expand Down
84 changes: 84 additions & 0 deletions models/yolo_v8_segmentation/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# syntax=docker/dockerfile:1.7

ARG BASE_IMAGE=ghcr.io/hotosm/fair-utilities-yolo:cpu-latest
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpu


# ---------------------------------------------------------------------------
# Builder stage: install model-pack deps into the base image venv
# ---------------------------------------------------------------------------
FROM ${BASE_IMAGE} AS builder

ENV UV_LINK_MODE=copy

COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /usr/local/bin/
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uvx is not needed


WORKDIR /workspace

COPY pyproject.toml README.md fair_zenml_patch.pth /tmp/fair-src/
COPY fair /tmp/fair-src/fair

# The fair-utilities-yolo image already provides `hot_fair_utilities` under
# `/app/.venv`. Install torch, fAIr client libs, etc. into that same venv so
# runtime and tests share one interpreter (do not use `--system` / /usr/local).
RUN --mount=type=cache,target=/root/.cache/uv \
SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 \
uv pip install --python /app/.venv/bin/python \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gpu and i think they are already avvailable in the base image !

--extra-index-url https://download.pytorch.org/whl/cpu \
--index-strategy unsafe-best-match \
torch==2.10.0 \
"ultralytics>=8.4.0" \
rasterio \
pyproj \
onnx \
onnxscript \
"pystac[validation]>=1.14.3" \
"universal-pathlib" \
"fairpredictor>=0.5.1" \
/tmp/fair-src[k8s]

# ---------------------------------------------------------------------------
# Runtime stage: production image (no test deps)
# ---------------------------------------------------------------------------
FROM ${BASE_IMAGE} AS runtime

WORKDIR /workspace

ENV PATH="/app/.venv/bin:$PATH" \
MPLBACKEND=Agg \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1

COPY --from=builder /app/.venv /app/.venv

COPY models/yolo_v8_segmentation models/yolo_v8_segmentation
COPY models/conftest.py models/conftest.py
COPY models/test_integration.py models/test_integration.py

ENTRYPOINT ["/app/.venv/bin/python"]

# ---------------------------------------------------------------------------
# Test stage: add pytest + ZenML server deps
# ---------------------------------------------------------------------------
FROM runtime AS test

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
COPY --from=builder /tmp/fair-src /tmp/fair-src

RUN --mount=type=cache,target=/root/.cache/uv \
SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 \
uv pip install --python /app/.venv/bin/python /tmp/fair-src[test]

# ---------------------------------------------------------------------------
# Inference stage: runtime + serving deps for smoke/live API
# ---------------------------------------------------------------------------
FROM runtime AS inference
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use distroless images and only install the minimal inference , example here :

FROM gcr.io/distroless/python3-debian12:nonroot AS inference


COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
COPY --from=builder /tmp/fair-src /tmp/fair-src

RUN --mount=type=cache,target=/root/.cache/uv \
SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 \
uv pip install --python /app/.venv/bin/python /tmp/fair-src[serve]

ENV PYTHONPATH=/workspace
EXPOSE 8080
CMD ["/app/.venv/bin/uvicorn", "fair.serve.base:create_app", "--factory", "--host", "0.0.0.0", "--port", "8080"]
9 changes: 9 additions & 0 deletions models/yolo_v8_segmentation/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# BuildKit uses <Dockerfile>.dockerignore automatically (no repo-level side effects)
*
!models/yolo_v8_segmentation/
!models/conftest.py
!models/test_integration.py
!fair/
!pyproject.toml
!README.md
!fair_zenml_patch.pth
29 changes: 29 additions & 0 deletions models/yolo_v8_segmentation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# YOLOv8 Building Footprint Segmentation

## Overview

YOLOv8 Building Footprint Segmentation is a base model for extracting building footprints from very high resolution RGB aerial imagery. The model is intended for fAIr finetuning workflows where users provide OpenAerialMap chips and matching vector labels, and the system produces polygon-ready outputs through the model's preprocessing and postprocessing entrypoints.

## Architecture

This model uses a YOLOv8 segmentation backbone with a single foreground class for buildings. Training and inference are orchestrated through the fAIr ZenML pipeline contract, while geospatial preprocessing and polygonization are delegated to the shared `hot_fair_utilities` stack. The model expects RGB chip tensors and returns building mask predictions that are postprocessed into GeoJSON building polygons.

## Pretrained Source

The pretrained initialization checkpoint is the YOLOv8 segmentation weight published through the HOT fAIr utilities repository. It is used as the base checkpoint for finetuning on user-provided datasets in the fAIr platform.

## Limitations and Bias

Performance is sensitive to image resolution, acquisition quality, and domain shift between training and inference regions. Dense urban settlements, informal settlements, heavy shadows, cloud cover, and occlusions may reduce recall and boundary quality. Geographic and annotation bias in source training data can propagate to outputs, especially in underrepresented building styles and roof materials. Predictions should therefore be reviewed before operational use in humanitarian mapping workflows.

## Usage

This model is designed to be used through fAIr training and inference pipelines rather than standalone scripts. During training, users provide dataset chip and label assets plus hyperparameter overrides, and the pipeline performs deterministic train/validation splitting, model training, evaluation, and ONNX export. During inference, users provide model URI and input imagery; the pipeline runs segmentation and postprocesses outputs into geospatial building polygons.

## Citation

If you use this model in downstream work, cite the Ultralytics YOLO family and the HOT fAIr model packaging workflow. The STAC item includes a `cite-as` link for model lineage reference.

## License

This model is distributed under the Apache-2.0 license, consistent with the STAC metadata for the model package and source code.
Loading
Loading