# vaishnavikanu/tilescope architecture

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

- Interactive diagram: https://gitdiagram.com/vaishnavikanu/tilescope
- Repository: https://github.com/vaishnavikanu/tilescope

## Overview

TileScope turns an uploaded satellite image into a full-resolution, seven-class land-cover segmentation, class percentages, visualizations, and downloadable outputs. The principal runtime begins in the Streamlit app, which loads the trained model and calls tiled prediction; prediction stitches overlapping tile probabilities, then derives the mask, overlay, and class breakdown for display/export. A separate training/evaluation branch prepares labeled patches, trains the U-Net, and evaluates held-out imagery. README documents these capabilities; unsampled modules are represented only where their roles are evident from the tree.

Main entry points: [`app.py`](https://github.com/vaishnavikanu/tilescope/blob/main/app.py) (Streamlit app), [`training/predict.py`](https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py) (Tile prediction), [`training/train.py`](https://github.com/vaishnavikanu/tilescope/blob/main/training/train.py) (Model training), [`training/model.py`](https://github.com/vaishnavikanu/tilescope/blob/main/training/model.py) (U-Net model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web interface"]
  node_app["Streamlit app<br/>[app.py]"]
  node_visuals["Overlay and display<br/>[app.py]"]
  node_exports["Download outputs<br/>[app.py]"]
end

subgraph group_segmentation["Segmentation runtime"]
  node_predict["Tile prediction<br/>[predict.py]"]
  node_unet["U-Net model<br/>[model.py]"]
  node_mask["Class mask<br/>[predict.py]"]
  node_quantification["Class percentages<br/>[predict.py]"]
end

subgraph group_learning["Training and evaluation"]
  node_dataset["Patch dataset<br/>[dataset.py]"]
  node_trainer["Model training<br/>[train.py]"]
  node_evaluation["Held-out evaluation<br/>[train_eval.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_checkpoint["Trained weights"]
end

node_user(("Image user"))
node_labeled_data[("Labeled imagery")]

node_user -->|"uploads image"| node_app
node_app -->|"loads weights"| node_checkpoint
node_app -->|"calls prediction"| node_predict
node_predict -->|"runs tiles"| node_unet
node_predict -->|"stitches probabilities"| node_mask
node_predict -->|"counts classes"| node_quantification
node_predict -->|"returns results"| node_app
node_app -->|"presents image and mask"| node_visuals
node_app -->|"offers downloads"| node_exports
node_labeled_data -->|"reads image-mask pairs"| node_dataset
node_dataset -->|"supplies patches"| node_trainer
node_trainer -->|"optimizes model"| node_unet
node_trainer -->|"saves weights"| node_checkpoint
node_labeled_data -->|"reads held-out pairs"| node_evaluation
node_evaluation -->|"runs evaluation"| node_unet

click node_app "https://github.com/vaishnavikanu/tilescope/blob/main/app.py"
click node_predict "https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py"
click node_unet "https://github.com/vaishnavikanu/tilescope/blob/main/training/model.py"
click node_mask "https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py"
click node_quantification "https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py"
click node_visuals "https://github.com/vaishnavikanu/tilescope/blob/main/app.py"
click node_exports "https://github.com/vaishnavikanu/tilescope/blob/main/app.py"
click node_dataset "https://github.com/vaishnavikanu/tilescope/blob/main/training/dataset.py"
click node_trainer "https://github.com/vaishnavikanu/tilescope/blob/main/training/train.py"
click node_evaluation "https://github.com/vaishnavikanu/tilescope/blob/main/training/train_eval.py"
click node_checkpoint "https://github.com/vaishnavikanu/tilescope/blob/main/models/tilescope_unet_evaluated.pth"

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_app,node_visuals,node_exports,node_user toneBlue
class node_predict,node_unet,node_mask,node_quantification,node_labeled_data toneAmber
class node_dataset,node_trainer,node_evaluation toneMint
class node_checkpoint toneRose
```

## Components

### Web interface

- [Streamlit app](https://github.com/vaishnavikanu/tilescope/blob/main/app.py): `app.py`
- [Overlay and display](https://github.com/vaishnavikanu/tilescope/blob/main/app.py): `app.py`
- [Download outputs](https://github.com/vaishnavikanu/tilescope/blob/main/app.py): `app.py`

### Segmentation runtime

- [Tile prediction](https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py): `training/predict.py`
- [U-Net model](https://github.com/vaishnavikanu/tilescope/blob/main/training/model.py): `training/model.py`
- [Class mask](https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py): `training/predict.py`
- [Class percentages](https://github.com/vaishnavikanu/tilescope/blob/main/training/predict.py): `training/predict.py`

### Training and evaluation

- [Patch dataset](https://github.com/vaishnavikanu/tilescope/blob/main/training/dataset.py): `training/dataset.py`
- [Model training](https://github.com/vaishnavikanu/tilescope/blob/main/training/train.py): `training/train.py`
- [Held-out evaluation](https://github.com/vaishnavikanu/tilescope/blob/main/training/train_eval.py): `training/train_eval.py`

### Model artifacts

- [Trained weights](https://github.com/vaishnavikanu/tilescope/blob/main/models/tilescope_unet_evaluated.pth): `models/tilescope_unet_evaluated.pth`

### Other components

- **Image user**
- **Labeled imagery**

## Connections

- Image user → Streamlit app: uploads image
- Streamlit app → Trained weights: loads weights
- Streamlit app → Tile prediction: calls prediction
- Tile prediction → U-Net model: runs tiles
- Tile prediction → Class mask: stitches probabilities
- Tile prediction → Class percentages: counts classes
- Tile prediction → Streamlit app: returns results
- Streamlit app → Overlay and display: presents image and mask
- Streamlit app → Download outputs: offers downloads
- Labeled imagery → Patch dataset: reads image-mask pairs
- Patch dataset → Model training: supplies patches
- Model training → U-Net model: optimizes model
- Model training → Trained weights: saves weights
- Labeled imagery → Held-out evaluation: reads held-out pairs
- Held-out evaluation → U-Net model: runs evaluation
