# khyeongkyun/zeroflood architecture

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

- Interactive diagram: https://gitdiagram.com/khyeongkyun/zeroflood
- Repository: https://github.com/khyeongkyun/zeroflood

## Overview

ZeroFlood supports flood-segmentation dataset preparation and a Pangaea-based fine-tuning, evaluation, and inference workflow using geospatial foundation encoders and task decoders. Dataset creation downloads TerraMesh/LISFLOOD inputs and preprocesses them; fine-tuning consumes the resulting data through dataset/preprocessing abstractions, then trains and evaluates a configured model. The README documents prediction-saving inference and multiple encoder families. Some subsystem links reflect README workflows or SOURCE INDEX references; unsampled implementations and their internal wiring are not inferred.

Main entry points: [`pangaea/run.py`](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/run.py) (Run Entry), [`data/download.py`](https://github.com/khyeongkyun/zeroflood/blob/main/data/download.py) (Source Downloader), [`pangaea/encoders`](https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/encoders) (Foundation Encoders), [`data/preprocess.py`](https://github.com/khyeongkyun/zeroflood/blob/main/data/preprocess.py) (Dataset Preprocessor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Flood Data"]
  node_download["Source Downloader<br/>[download.py]"]
  node_prepare["Dataset Preprocessor<br/>[preprocess.py]"]
  node_terramesh["TerraMesh Utilities<br/>[terramesh.py]"]
end

subgraph group_runtime["Benchmark Runtime"]
  node_rawdataset["Raw Dataset Adapters"]
  node_dataset["Dataset Wrapper<br/>[base.py]"]
  node_preprocess["Input Preprocessing"]
  node_entry["Run Entry<br/>[run.py]"]
  node_trainer["Training Loop<br/>[trainer.py]"]
  node_evaluator["Evaluation<br/>[evaluator.py]"]
  node_predictions["Saved Predictions<br/>[evaluator.py]"]
end

subgraph group_models["Model Components"]
  node_encoder["Foundation Encoders"]
  node_decoder["Task Decoders"]
  node_terra_model["TerraMind Model<br/>[tm_utils.py]"]
  node_tokenizer["TerraMind Tokenizers<br/>[vqvae.py]"]
  node_diffusion["Diffusion Pipeline"]
end

subgraph group_operations["Training Support"]
  node_logger["Experiment Logging<br/>[logger.py]"]
  node_sampler["Label Subsampling<br/>[subset_sampler.py]"]
end

node_user(("Researcher"))
node_source[("Source Datasets")]
node_hfdata[("ZeroFlood HF Dataset")]

node_user -->|"requests download"| node_download
node_source -->|"provides inputs"| node_download
node_download -->|"downloads data for"| node_prepare
node_prepare -->|"reproduces dataset"| node_hfdata
node_user -->|"runs benchmark"| node_entry
node_hfdata -.->|"supplies fine-tuning data"| node_rawdataset
node_entry -->|"constructs datasets"| node_dataset
node_dataset -->|"uses preprocessing"| node_preprocess
node_entry -->|"instantiates encoder"| node_encoder
node_entry -->|"instantiates decoder"| node_decoder
node_decoder -->|"holds encoder"| node_encoder
node_entry -->|"runs fine-tuning"| node_trainer
node_entry -->|"runs evaluation"| node_evaluator
node_entry -->|"selects label subsets"| node_sampler
node_trainer -->|"uses logging"| node_logger
node_evaluator -->|"saves predictions"| node_predictions
node_user -->|"runs inference"| node_entry
node_encoder -.->|"includes TerraMind"| node_terra_model
node_terra_model -.->|"uses tokenizer components"| node_tokenizer
node_tokenizer -.->|"supports generation"| node_diffusion

click node_download "https://github.com/khyeongkyun/zeroflood/blob/main/data/download.py"
click node_prepare "https://github.com/khyeongkyun/zeroflood/blob/main/data/preprocess.py"
click node_terramesh "https://github.com/khyeongkyun/zeroflood/blob/main/data/terramesh.py"
click node_rawdataset "https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/datasets"
click node_dataset "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/datasets/base.py"
click node_preprocess "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/data_preprocessor.py"
click node_entry "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/run.py"
click node_encoder "https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/encoders"
click node_decoder "https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/decoders"
click node_trainer "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/trainer.py"
click node_evaluator "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/evaluator.py"
click node_predictions "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/evaluator.py"
click node_logger "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/utils/logger.py"
click node_sampler "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/utils/subset_sampler.py"
click node_terra_model "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/model/tm_utils.py"
click node_tokenizer "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/tokenizer/vqvae.py"
click node_diffusion "https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/tokenizer/scheduling/diffusion_pipeline.py"

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_download,node_prepare,node_terramesh toneBlue
class node_rawdataset,node_dataset,node_preprocess,node_entry,node_trainer,node_evaluator,node_predictions,node_source,node_hfdata toneAmber
class node_encoder,node_decoder,node_terra_model,node_tokenizer,node_diffusion toneMint
class node_logger,node_sampler toneRose
class node_user toneIndigo
```

## Components

### Flood Data

- [Source Downloader](https://github.com/khyeongkyun/zeroflood/blob/main/data/download.py): `data/download.py`
- [Dataset Preprocessor](https://github.com/khyeongkyun/zeroflood/blob/main/data/preprocess.py): `data/preprocess.py`
- [TerraMesh Utilities](https://github.com/khyeongkyun/zeroflood/blob/main/data/terramesh.py): `data/terramesh.py`

### Benchmark Runtime

- [Raw Dataset Adapters](https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/datasets): `pangaea/datasets`
- [Dataset Wrapper](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/datasets/base.py): `pangaea/datasets/base.py`
- [Input Preprocessing](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/data_preprocessor.py): `pangaea/engine/data_preprocessor.py`
- [Run Entry](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/run.py): `pangaea/run.py`
- [Training Loop](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/trainer.py): `pangaea/engine/trainer.py`
- [Evaluation](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/evaluator.py): `pangaea/engine/evaluator.py`
- [Saved Predictions](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/engine/evaluator.py): `pangaea/engine/evaluator.py`

### Model Components

- [Foundation Encoders](https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/encoders): `pangaea/encoders`
- [Task Decoders](https://github.com/khyeongkyun/zeroflood/tree/main/pangaea/decoders): `pangaea/decoders`
- [TerraMind Model](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/model/tm_utils.py): `pangaea/encoders/terramind/model/tm_utils.py`
- [TerraMind Tokenizers](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/tokenizer/vqvae.py): `pangaea/encoders/terramind/tokenizer/vqvae.py`
- [Diffusion Pipeline](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/encoders/terramind/tokenizer/scheduling/diffusion_pipeline.py): `pangaea/encoders/terramind/tokenizer/scheduling/diffusion_pipeline.py`

### Training Support

- [Experiment Logging](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/utils/logger.py): `pangaea/utils/logger.py`
- [Label Subsampling](https://github.com/khyeongkyun/zeroflood/blob/main/pangaea/utils/subset_sampler.py): `pangaea/utils/subset_sampler.py`

### Other components

- **Researcher**
- **Source Datasets**
- **ZeroFlood HF Dataset**

## Connections

- Researcher → Source Downloader: requests download (evidence: `README.md`)
- Source Datasets → Source Downloader: provides inputs (evidence: `README.md`)
- Source Downloader → Dataset Preprocessor: downloads data for (evidence: `README.md`)
- Dataset Preprocessor → ZeroFlood HF Dataset: reproduces dataset (evidence: `README.md`)
- Researcher → Run Entry: runs benchmark (evidence: `README.md`)
- ZeroFlood HF Dataset → Raw Dataset Adapters: supplies fine-tuning data
- Run Entry → Dataset Wrapper: constructs datasets (evidence: `pangaea/run.py`)
- Dataset Wrapper → Input Preprocessing: uses preprocessing (evidence: `pangaea/datasets/base.py`)
- Run Entry → Foundation Encoders: instantiates encoder (evidence: `pangaea/run.py`)
- Run Entry → Task Decoders: instantiates decoder (evidence: `pangaea/run.py`)
- Task Decoders → Foundation Encoders: holds encoder (evidence: `pangaea/decoders/base.py`)
- Run Entry → Training Loop: runs fine-tuning (evidence: `pangaea/run.py`)
- Run Entry → Evaluation: runs evaluation (evidence: `pangaea/run.py`)
- Run Entry → Label Subsampling: selects label subsets (evidence: `pangaea/run.py`)
- Training Loop → Experiment Logging: uses logging (evidence: `pangaea/engine/trainer.py`)
- Evaluation → Saved Predictions: saves predictions (evidence: `README.md`)
- Researcher → Run Entry: runs inference (evidence: `README.md`)
- Foundation Encoders → TerraMind Model: includes TerraMind (evidence: `pangaea/encoders/terramind/model/encoder_embeddings.py`)
- TerraMind Model → TerraMind Tokenizers: uses tokenizer components
- TerraMind Tokenizers → Diffusion Pipeline: supports generation
