# fiftyq/center-pivot-irrigation-yolo architecture

> Architecture diagram of the GitHub repository fiftyq/center-pivot-irrigation-yolo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fiftyq/center-pivot-irrigation-yolo
- Repository: https://github.com/fiftyq/center-pivot-irrigation-yolo

## Overview

This repository is a collection of scripts for preparing Sentinel-style raster and farmland-vector data, training YOLO instance-segmentation models, and exporting predictions as GIS polygons. The main workflow prepares image tiles and labels, performs spatial dataset splitting and checks, trains a model, then runs tiled inference and vector export. Separate scripts provide label QA, demo prediction, threshold evaluation, and earlier GIS-prediction variants. Relationships are limited to those visible in excerpts; the README is empty, and some subsystem links are not shown.

Main entry points: [`data_prepare.py`](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/data_prepare.py) (Tile dataset), [`runs/segment/ordos_farmland_v2_clean_split/weights/best.pt`](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/runs/segment/ordos_farmland_v2_clean_split/weights/best.pt) (Model weights), [`04_train_seg.py`](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/04_train_seg.py) (YOLO training), [`06_predict_to_gis.py`](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis.py) (GIS prediction v1)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_preparation["Data Preparation"]
  node_prepared_dataset[("Tile dataset<br/>[data_prepare.py]")]
  node_random_split["Random split"]
  node_spatial_split["Spatial split"]
end

subgraph group_quality["Dataset Quality"]
  node_label_check["Label check<br/>[03_check_labels.py]"]
  node_label_qc["Label and leakage QC<br/>[08_label_qc.py]"]
end

subgraph group_training["Model Training"]
  node_trainer["YOLO training<br/>[04_train_seg.py]"]
  node_model_weights["Model weights<br/>[best.pt]"]
end

subgraph group_inference["Prediction and GIS"]
  node_demo_predict["Demo prediction<br/>[05_predict_demo.py]"]
  node_gis_v1["GIS prediction v1"]
  node_gis_v2["GIS prediction v2"]
  node_gis_v3["GIS prediction v3"]
  node_threshold_eval["Threshold evaluation"]
  node_gis_outputs["GIS polygon outputs"]
end

node_operator(("Operator"))
node_raster_input["Raster imagery"]
node_farmland_vectors["Farmland vectors"]

node_operator -->|"prepares data"| node_prepared_dataset
node_raster_input -->|"reads imagery"| node_prepared_dataset
node_farmland_vectors -->|"labels tiles"| node_prepared_dataset
node_prepared_dataset -->|"splits tiles"| node_random_split
node_prepared_dataset -->|"reads tile index"| node_spatial_split
node_operator -->|"checks labels"| node_label_check
node_prepared_dataset -->|"checks dataset"| node_label_qc
node_random_split -.->|"provides splits"| node_trainer
node_spatial_split -.->|"provides splits"| node_trainer
node_operator -->|"starts training"| node_trainer
node_trainer -.->|"saves weights"| node_model_weights
node_operator -->|"runs prediction"| node_demo_predict
node_operator -->|"runs inference"| node_gis_v1
node_operator -->|"runs inference"| node_gis_v2
node_operator -->|"runs inference"| node_gis_v3
node_model_weights -->|"loads weights"| node_demo_predict
node_raster_input -->|"reads imagery"| node_gis_v1
node_raster_input -->|"reads imagery"| node_gis_v2
node_raster_input -->|"reads imagery"| node_gis_v3
node_model_weights -.->|"loads weights"| node_gis_v1
node_model_weights -.->|"loads weights"| node_gis_v2
node_model_weights -.->|"loads weights"| node_gis_v3
node_gis_v1 -.->|"writes polygons"| node_gis_outputs
node_gis_v2 -->|"writes polygons"| node_gis_outputs
node_gis_v3 -.->|"writes polygons"| node_gis_outputs
node_operator -->|"evaluates thresholds"| node_threshold_eval

click node_prepared_dataset "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/data_prepare.py"
click node_random_split "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/02_split_dataset.py"
click node_spatial_split "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/02_split_dataset_by_source.py"
click node_label_check "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/03_check_labels.py"
click node_label_qc "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/08_label_qc.py"
click node_trainer "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/04_train_seg.py"
click node_model_weights "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/runs/segment/ordos_farmland_v2_clean_split/weights/best.pt"
click node_demo_predict "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/05_predict_demo.py"
click node_gis_v1 "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis.py"
click node_gis_v2 "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v2.py"
click node_gis_v3 "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v3.py"
click node_threshold_eval "https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v3.py"
click node_gis_outputs "https://github.com/fiftyq/center-pivot-irrigation-yolo/tree/main/predict_results"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_prepared_dataset,node_random_split,node_spatial_split toneBlue
class node_label_check,node_label_qc toneAmber
class node_trainer,node_model_weights toneMint
class node_demo_predict,node_gis_v1,node_gis_v2,node_gis_v3,node_threshold_eval,node_gis_outputs toneRose
class node_operator,node_raster_input,node_farmland_vectors toneIndigo
```

## Components

### Data Preparation

- [Tile dataset](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/data_prepare.py): `data_prepare.py`
- [Random split](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/02_split_dataset.py): `02_split_dataset.py`
- [Spatial split](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/02_split_dataset_by_source.py): `02_split_dataset_by_source.py`

### Dataset Quality

- [Label check](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/03_check_labels.py): `03_check_labels.py`
- [Label and leakage QC](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/08_label_qc.py): `08_label_qc.py`

### Model Training

- [YOLO training](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/04_train_seg.py): `04_train_seg.py`
- [Model weights](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/runs/segment/ordos_farmland_v2_clean_split/weights/best.pt): `runs/segment/ordos_farmland_v2_clean_split/weights/best.pt`

### Prediction and GIS

- [Demo prediction](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/05_predict_demo.py): `05_predict_demo.py`
- [GIS prediction v1](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis.py): `06_predict_to_gis.py`
- [GIS prediction v2](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v2.py): `06_predict_to_gis_v2.py`
- [GIS prediction v3](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v3.py): `06_predict_to_gis_v3.py`
- [Threshold evaluation](https://github.com/fiftyq/center-pivot-irrigation-yolo/blob/main/06_predict_to_gis_v3.py): `06_predict_to_gis_v3.py`
- [GIS polygon outputs](https://github.com/fiftyq/center-pivot-irrigation-yolo/tree/main/predict_results): `predict_results`

### Other components

- **Operator**
- **Raster imagery**
- **Farmland vectors**

## Connections

- Operator → Tile dataset: prepares data (evidence: `data_prepare.py`)
- Raster imagery → Tile dataset: reads imagery (evidence: `data_prepare.py`)
- Farmland vectors → Tile dataset: labels tiles (evidence: `data_prepare.py`)
- Tile dataset → Random split: splits tiles (evidence: `02_split_dataset.py`)
- Tile dataset → Spatial split: reads tile index (evidence: `02_split_dataset_by_source.py`)
- Operator → Label check: checks labels (evidence: `03_check_labels.py`)
- Tile dataset → Label and leakage QC: checks dataset (evidence: `08_label_qc.py`)
- Random split → YOLO training: provides splits
- Spatial split → YOLO training: provides splits
- Operator → YOLO training: starts training (evidence: `04_train_seg.py`)
- YOLO training → Model weights: saves weights
- Operator → Demo prediction: runs prediction (evidence: `05_predict_demo.py`)
- Operator → GIS prediction v1: runs inference (evidence: `06_predict_to_gis.py`)
- Operator → GIS prediction v2: runs inference (evidence: `06_predict_to_gis_v2.py`)
- Operator → GIS prediction v3: runs inference (evidence: `06_predict_to_gis_v3.py`)
- Model weights → Demo prediction: loads weights (evidence: `05_predict_demo.py`)
- Raster imagery → GIS prediction v1: reads imagery (evidence: `06_predict_to_gis.py`)
- Raster imagery → GIS prediction v2: reads imagery (evidence: `06_predict_to_gis_v2.py`)
- Raster imagery → GIS prediction v3: reads imagery (evidence: `06_predict_to_gis_v3.py`)
- Model weights → GIS prediction v1: loads weights
- Model weights → GIS prediction v2: loads weights
- Model weights → GIS prediction v3: loads weights
- GIS prediction v1 → GIS polygon outputs: writes polygons
- GIS prediction v2 → GIS polygon outputs: writes polygons (evidence: `06_predict_to_gis_v2.py`)
- GIS prediction v3 → GIS polygon outputs: writes polygons
- Operator → Threshold evaluation: evaluates thresholds (evidence: `06_predict_to_gis_v3.py`)
