Skip to content

Commit 53cbdbd

Browse files
clean up
1 parent 125f37d commit 53cbdbd

18 files changed

Lines changed: 1539 additions & 446 deletions

.DS_Store

0 Bytes
Binary file not shown.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ repos:
5959
#Automatic linting fixes
6060
types_or: [ python, pyi, jupyter ]
6161
args: [ --fix ]
62-
stages: [manual]
62+
#stages: [manual]
6363
- id: ruff-format
6464
types_or: [ python, pyi, jupyter ]
65-
stages: [manual]
65+
#stages: [manual]

data/generate_pv_masks.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
from pathlib import Path
2+
13
import numpy as np
24
from PIL import Image
3-
from pathlib import Path
45

5-
def extract_pv_masks(
6-
src_dir: Path,
7-
dst_dir: Path,
8-
pv_class: int = 0,
9-
background_value: int = 255
10-
):
6+
7+
def extract_pv_masks(src_dir: Path, dst_dir: Path, pv_class: int = 0, background_value: int = 255):
118
"""
129
Extract masks that contain PV modules (class 0) and save a cleaned PV-only mask.
1310
@@ -21,6 +18,7 @@ def extract_pv_masks(
2118
Class index representing PV modules (default: 0).
2219
background_value : int, optional
2320
Value used for non-PV pixels in the output mask (default: 255 for easy visualization).
21+
2422
"""
2523
dst_dir.mkdir(parents=True, exist_ok=True)
2624

@@ -46,6 +44,7 @@ def extract_pv_masks(
4644

4745
print(f"Saved {count_saved} PV-only masks to: {dst_dir}")
4846

47+
4948
if __name__ == "__main__":
5049
BASE_DIR = Path(__file__).resolve().parent
5150
SRC_MASK_DIR = BASE_DIR / "masks_superstructures_reviewed"
@@ -55,5 +54,5 @@ def extract_pv_masks(
5554
src_dir=SRC_MASK_DIR,
5655
dst_dir=DST_PV_MASK_DIR,
5756
pv_class=0,
58-
background_value=255, # white background for visualization
59-
)
57+
background_value=255, # white background for visualization
58+
)

data/load_rid_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pathlib import Path
2020

2121
SERVER = "rsync://m1655470@dataserv.ub.tum.de/m1655470"
22-
BASE_DIR = Path(__file__).resolve().parent # data/
22+
BASE_DIR = Path(__file__).resolve().parent # data/
2323
DATA_DIR = BASE_DIR
2424

2525
FOLDERS = [
@@ -51,7 +51,7 @@ def rsync_folder(remote_name: str):
5151
"-av",
5252
"--progress",
5353
src,
54-
str(dst) + "/", # ensure trailing slash
54+
str(dst) + "/", # ensure trailing slash
5555
]
5656

5757
print(f">>> Downloading '{remote_name}' from server...")

docs/index.md

Lines changed: 0 additions & 54 deletions
This file was deleted.

docs/installation.md

Lines changed: 0 additions & 111 deletions
This file was deleted.

docs/memo.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
Few-shot learning for satellite image segmentation is crucial for urban planning and disaster response. Traditional deep learning requires thousands of labeled samples, but few-shot learning enables rapid adaptation to new geographic regions with minimal labeled data.
1+
## Memo
22

3-
**Policy Applications:**
4-
- Urban development monitoring
5-
- Disaster damage assessment
6-
- Property tax assessment
7-
- Solar panel installation planning
3+
This notebook offers an in-depth look at few-shot learning (FSL), an advanced deep learning technique that enables models to generalize effectively from only a small number of training examples. FSL becomes particularly valuable when traditional supervised learning is impractical. For instance, when annotation is expensive, requires specialized expertise, or when data is scarce.
4+
5+
Few-shot learning is especially relevant in the context of public policy, where we often face limited access to comprehensive, well-curated datasets or lack the resources to collect large amounts of training data. Applications span a wide range of policy areas, including disaster classification (Lee et al., 2025), urban planning (Hu et al., 2022) and health policy, where FSL has supported COVID-19 detection (Jadon, 2021) and the diagnosis of rare genetic diseases (Alsentzer et al., 2025).
6+
7+
Beyond classification tasks, FSL also performs well in <b>segmentation problems</b>, helping identify different types of buildings, vegetation such as forest cover (Puthumanaillam & Verma, 2023) and performing well in remote sensing imagery segmentation (Chen et al., 2022). All of these examples share a common challenge: <b>limited data</b>.
8+
9+
Few-shot learning helps address this constraint, and we encounter similar situations within our own institution. A clear illustration is our Wildlife Trade Monitoring Project (WTMP), where labeled examples of rare, endangered species are extremely scarce and often inconsistent. This emphasizes just how valuable few-shot learning approaches can be.
10+
Today, a wide range of few-shot learning frameworks and architectures are available. Some of the most widely used include model-agnostic meta-learning (Finn, Abbeel & Levine, 2017), prototypical networks (Snell, Swersky & Zemel, 2017), and relation networks (Sung et al., 2018). Over the past few years, the field has continued to evolve, giving rise to more specialized and state-of-the-art techniques, such as SegPPD-FS for semantic segmentation (Ge et al., 2025) and CDCNet for classification tasks (Li et al., 2025).
11+
12+
Because of its importance to public policy and its potential value for our organization, this notebook takes a deep dive into prototypical networks semantic segmentation of building rooftops. This is an essential step for many downstream tasks, such as assessing rooftop suitability for solar panel installation. By walking through this method, the notebook aims to help our team to better understand and apply this powerful technique in our day-to-day work.
-31.1 MB
Binary file not shown.

notebooks/meta_training_loss.png

-2.34 KB
Binary file not shown.

notebooks/predicted_masks.png

-2.34 KB
Binary file not shown.

0 commit comments

Comments
 (0)