Skip to content

Commit 24642a4

Browse files
Merge pull request #90 from WUR-AI/develop
Inference model, encoder wrapper and more
2 parents f5d2d71 + b815d43 commit 24642a4

56 files changed

Lines changed: 8502 additions & 347 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

configs/data/yield_africa_KEN.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
_target_: src.data.base_datamodule.BaseDataModule
2+
3+
dataset:
4+
_target_: src.data.yield_africa_dataset.YieldAfricaDataset
5+
data_dir: ${paths.data_dir}
6+
modalities:
7+
coords: {}
8+
use_target_data: true
9+
use_features: true
10+
use_aux_data: none
11+
csv_name: null
12+
seed: ${seed}
13+
cache_dir: ${paths.cache_dir}
14+
# Country/year filters — set to a list to restrict, null to include all.
15+
# countries and years select only the listed values;
16+
# exclude_countries and exclude_years drop the listed values.
17+
countries: ["KEN"]
18+
years: [2017, 2018, 2019, 2020]
19+
exclude_countries: null
20+
exclude_years: null
21+
22+
batch_size: 64
23+
num_workers: 0
24+
pin_memory: false
25+
26+
split_mode: "random"
27+
train_val_test_split: [0.7, 0.15, 0.15]
28+
save_split: false
29+
seed: ${seed}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
_target_: src.data.base_datamodule.BaseDataModule
2+
3+
dataset:
4+
_target_: src.data.yield_africa_dataset.YieldAfricaDataset
5+
data_dir: ${paths.data_dir}
6+
modalities:
7+
tessera:
8+
# size must match the tile_size used when running the preprocessing script.
9+
# Default: 9 pixels (set by yield_africa_tessera_preprocess.py --tile_size).
10+
size: 9
11+
format: npy
12+
# year is intentionally omitted: yield_africa fetches per-record year tiles
13+
# via the preprocessing script rather than a single bulk-year download.
14+
use_target_data: true
15+
use_features: true
16+
use_aux_data: none
17+
csv_name: null
18+
seed: ${seed}
19+
cache_dir: ${paths.cache_dir}
20+
countries: ["KEN"]
21+
years: [2017, 2018, 2019, 2020]
22+
exclude_countries: null
23+
exclude_years: null
24+
25+
batch_size: 64
26+
num_workers: 0
27+
pin_memory: false
28+
29+
split_mode: "random"
30+
train_val_test_split: [0.7, 0.15, 0.15]
31+
save_split: false
32+
seed: ${seed}

configs/eval.yaml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
11
# @package _global_
22

3+
# specify here default configuration
4+
# order of defaults determines the order in which configs override each other
35
defaults:
46
- _self_
5-
- data: mnist # choose datamodule with `test_dataloader()` for evaluation
6-
- model: mnist
7-
- logger: null
8-
- trainer: default
9-
- paths: default
7+
- data: butterfly_coords
8+
- model: predictive_geoclip
9+
- callbacks: default
10+
- logger: ${oc.env:LOGGER,wandb}
11+
- trainer: ${oc.env:TRAINER_PROFILE,default}
12+
- paths: ${oc.env:STORAGE_MODE,local}
1013
- extras: default
1114
- hydra: default
15+
- metrics: butterfly_predictive
1216

17+
# experiment configs allow for version control of specific hyperparameters
18+
# e.g. best hyperparameters for given model and datamodule
19+
- experiment: null
20+
21+
# config for hyperparameter optimization
22+
- hparams_search: null
23+
24+
# optional local config for machine/user specific settings
25+
# it's optional since it doesn't need to exist and is excluded from version control
26+
- optional local: default
27+
28+
# debugging config (enable through command line, e.g. `python train.py debug=default)
29+
- debug: null
30+
31+
# task name, determines output directory path
1332
task_name: "eval"
1433

34+
# tags to help you identify your experiments
35+
# you can overwrite this in experiment configs
36+
# overwrite from command line with `python train.py tags="[first_tag, second_tag]"`
1537
tags: ["dev"]
1638

39+
# seed for random number generators in pytorch, numpy and python.random
40+
seed: 12345
41+
1742
# passing checkpoint path is necessary for evaluation
18-
ckpt_path: ???
43+
ckpt_path: aether/logs/train/runs/2026-03-15_13-15-08/checkpoints/epoch_098.ckpt
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# @package _global_
2+
3+
defaults:
4+
- override /model: yield_tabular_reg
5+
- override /data: yield_africa_KEN
6+
- override /metrics: yield_africa_regression
7+
8+
tags: ["yield_africa", "tabular_only", "regression", "Kenya"]
9+
seed: 12345
10+
11+
trainer:
12+
min_epochs: 1
13+
max_epochs: 150
14+
15+
data:
16+
batch_size: 64
17+
18+
logger:
19+
wandb:
20+
tags: ${tags}
21+
group: "yield_africa"
22+
aim:
23+
experiment: "yield_africa"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# @package _global_
2+
# configs/experiment/yield_africa_tessera_fusion_loco.yaml
3+
# TESSERA + tabular fusion model evaluated with leave-one-country-out split.
4+
# Default held-out country: KEN (largest, most representative test set).
5+
#
6+
# Requires:
7+
# 1. TESSERA tiles pre-fetched:
8+
# python src/data_preprocessing/yield_africa_tessera_preprocess.py --data_dir <data_dir>
9+
# 2. LOCO split files pre-generated:
10+
# python src/data_preprocessing/yield_africa_loco_splits.py --data_dir <data_dir>
11+
#
12+
# To evaluate on a different held-out country:
13+
# python src/train.py experiment=yield_africa_tessera_fusion_loco \
14+
# data.saved_split_file_name=split_loco_RWA.pth
15+
16+
defaults:
17+
- override /model: yield_tessera_fusion_reg
18+
- override /data: yield_africa_tessera_KEN
19+
- override /metrics: yield_africa_regression
20+
21+
tags: ["yield_africa", "tessera_fusion", "regression", "Kenya"]
22+
seed: 12345
23+
24+
trainer:
25+
min_epochs: 1
26+
max_epochs: 150
27+
28+
data:
29+
batch_size: 64
30+
dataset:
31+
use_features: true
32+
33+
logger:
34+
wandb:
35+
tags: ${tags}
36+
group: "yield_africa"
37+
aim:
38+
experiment: "yield_africa"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# @package _global_
2+
# configs/experiment/yield_africa_tessera_reg.yaml
3+
# Variant: TESSERA spatial encoder only (no tabular features).
4+
# Requires tiles pre-fetched by:
5+
# python src/data_preprocessing/yield_africa_tessera_preprocess.py --data_dir <data_dir>
6+
7+
defaults:
8+
- override /model: yield_tessera_reg
9+
- override /data: yield_africa_tessera_KEN
10+
- override /metrics: yield_africa_regression
11+
12+
tags: ["yield_africa", "tessera_only", "regression", "Kenya"]
13+
seed: 12345
14+
15+
trainer:
16+
min_epochs: 1
17+
max_epochs: 150
18+
19+
data:
20+
batch_size: 64
21+
22+
logger:
23+
wandb:
24+
tags: ${tags}
25+
group: "yield_africa"
26+
aim:
27+
experiment: "yield_africa"

configs/inference.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
defaults:
2+
- _self_
3+
- paths: ${oc.env:STORAGE_MODE,local}
4+
- extras: default
5+
- hydra: default
6+
7+
# task name, determines output directory path
8+
task_name: "inference"
9+
tags: ["dev"]
10+
11+
# If set, inference.py will load this merged checkpoint directly.
12+
#inference_ckpt_path: ${paths.log_dir}${task_name}/2026-04-07_12-56-16/inference_model.ckpt
13+
14+
# If `inference_ckpt_path` is not set, stitch the inference model from:
15+
# - predictive ckpt (provides prediction_head weights)
16+
# - alignment ckpt (provides text_encoder weights + geo_encoder)
17+
predictive_ckpt_path: ${paths.log_dir}train/runs/2026-04-02_15-54-53/checkpoints/epoch_000.ckpt
18+
alignment_ckpt_path: ${paths.log_dir}train/runs/2026-04-02_15-40-03/checkpoints/epoch_000.ckpt
19+
20+
# If set, inference.py will save a merged inference checkpoint you can reload with
21+
# `inference_ckpt_path`.
22+
save_inference_ckpt_path: ${paths.log_dir}${task_name}/${now:%Y-%m-%d}_${now:%H-%M-%S}/inference_model.ckpt
23+
#save_inference_ckpt_path: null
24+
25+
training_order: ["alignment_model", "prediction_model"]

configs/paths/shared.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ data_dir: ${oc.env:DATA_DIR,${oc.env:SHARED_ROOT,${paths.root_dir}}/data}
99
cache_dir: ${oc.env:SHARED_CACHE,${paths.data_dir}/cache}
1010

1111
# path to logging directory
12-
log_dir: ${oc.env:SHARED_ROOT}/logs/
12+
log_dir: ${oc.env:SHARED_ROOT,${paths.root_dir}}/logs/
1313

1414
# path to output directory, created dynamically by hydra
1515
# path generation pattern is specified in `configs/hydra/local.yaml`
@@ -21,4 +21,4 @@ work_dir: ${hydra:runtime.cwd}
2121

2222
# huggingface cache directory
2323
# can be overridden via HF_HOME environment variable
24-
huggingface_cache: ${oc.env:HF_HOME,oc.env:SHARED_CACHE/huggingface}
24+
huggingface_cache: ${oc.env:HF_HOME,${oc.env:SHARED_CACHE}/huggingface}

0 commit comments

Comments
 (0)