Commit ·
b46762c
1
Parent(s): 2248546
pdate configs: remove density splits, add region shift, 90:10 train/val, shared test sets
Browse files- README.md +81 -121
- tools/build_master_parquet.py +1 -0
- tools/make_configs_from_metadata.py +8 -8
- tools/make_named_configs.py +115 -107
- tools/update_readme_yaml.py +1 -3
- tools/write_readme.py +6 -6
README.md
CHANGED
|
@@ -1,125 +1,69 @@
|
|
| 1 |
---
|
| 2 |
configs:
|
| 3 |
-
- config_name:
|
| 4 |
-
data_files:
|
| 5 |
-
- split: train
|
| 6 |
-
path: "data/configs/biome_India_Karnataka_train_DRY__ood_WET/train-*.parquet"
|
| 7 |
-
- split: id_test
|
| 8 |
-
path: "data/configs/biome_India_Karnataka_train_DRY__ood_WET/id_test-*.parquet"
|
| 9 |
-
- split: ood_test
|
| 10 |
-
path: "data/configs/biome_India_Karnataka_train_DRY__ood_WET/ood_test-*.parquet"
|
| 11 |
-
- split: ood_same_density
|
| 12 |
-
path: "data/configs/biome_India_Karnataka_train_DRY__ood_WET/ood_same_density-*.parquet"
|
| 13 |
-
- split: ood_diff_density
|
| 14 |
-
path: "data/configs/biome_India_Karnataka_train_DRY__ood_WET/ood_diff_density-*.parquet"
|
| 15 |
-
- config_name: biome_India_Karnataka_train_WET__ood_DRY
|
| 16 |
data_files:
|
| 17 |
- split: train
|
| 18 |
-
path: "data/configs/
|
| 19 |
-
- split:
|
| 20 |
-
path: "data/configs/
|
| 21 |
- split: ood_test
|
| 22 |
-
path: "data/configs/
|
| 23 |
-
|
| 24 |
-
path: "data/configs/biome_India_Karnataka_train_WET__ood_DRY/ood_same_density-*.parquet"
|
| 25 |
-
- split: ood_diff_density
|
| 26 |
-
path: "data/configs/biome_India_Karnataka_train_WET__ood_DRY/ood_diff_density-*.parquet"
|
| 27 |
-
- config_name: biome_India_Rajasthan_train_DRY__ood_WET
|
| 28 |
data_files:
|
| 29 |
- split: train
|
| 30 |
-
path: "data/configs/
|
| 31 |
-
- split:
|
| 32 |
-
path: "data/configs/
|
| 33 |
- split: ood_test
|
| 34 |
-
path: "data/configs/
|
| 35 |
-
|
| 36 |
-
path: "data/configs/biome_India_Rajasthan_train_DRY__ood_WET/ood_same_density-*.parquet"
|
| 37 |
-
- split: ood_diff_density
|
| 38 |
-
path: "data/configs/biome_India_Rajasthan_train_DRY__ood_WET/ood_diff_density-*.parquet"
|
| 39 |
-
- config_name: biome_India_Rajasthan_train_WET__ood_DRY
|
| 40 |
data_files:
|
| 41 |
- split: train
|
| 42 |
-
path: "data/configs/
|
| 43 |
-
- split:
|
| 44 |
-
path: "data/configs/
|
| 45 |
- split: ood_test
|
| 46 |
-
path: "data/configs/
|
| 47 |
-
|
| 48 |
-
path: "data/configs/biome_India_Rajasthan_train_WET__ood_DRY/ood_same_density-*.parquet"
|
| 49 |
-
- split: ood_diff_density
|
| 50 |
-
path: "data/configs/biome_India_Rajasthan_train_WET__ood_DRY/ood_diff_density-*.parquet"
|
| 51 |
-
- config_name: biome_US_California_train_DRY__ood_WET
|
| 52 |
data_files:
|
| 53 |
- split: train
|
| 54 |
-
path: "data/configs/
|
| 55 |
-
- split:
|
| 56 |
-
path: "data/configs/
|
| 57 |
- split: ood_test
|
| 58 |
-
path: "data/configs/
|
| 59 |
-
|
| 60 |
-
path: "data/configs/biome_US_California_train_DRY__ood_WET/ood_same_density-*.parquet"
|
| 61 |
-
- split: ood_diff_density
|
| 62 |
-
path: "data/configs/biome_US_California_train_DRY__ood_WET/ood_diff_density-*.parquet"
|
| 63 |
-
- config_name: biome_US_California_train_WET__ood_DRY
|
| 64 |
data_files:
|
| 65 |
- split: train
|
| 66 |
-
path: "data/configs/
|
| 67 |
-
- split:
|
| 68 |
-
path: "data/configs/
|
| 69 |
- split: ood_test
|
| 70 |
-
path: "data/configs/
|
| 71 |
-
|
| 72 |
-
path: "data/configs/biome_US_California_train_WET__ood_DRY/ood_same_density-*.parquet"
|
| 73 |
-
- split: ood_diff_density
|
| 74 |
-
path: "data/configs/biome_US_California_train_WET__ood_DRY/ood_diff_density-*.parquet"
|
| 75 |
-
- config_name: in_state_train_Karnataka__ood_Rajasthan
|
| 76 |
data_files:
|
| 77 |
- split: train
|
| 78 |
-
path: "data/configs/
|
| 79 |
-
- split:
|
| 80 |
-
path: "data/configs/
|
| 81 |
- split: ood_test
|
| 82 |
-
path: "data/configs/
|
| 83 |
-
|
| 84 |
-
path: "data/configs/in_state_train_Karnataka__ood_Rajasthan/ood_same_density-*.parquet"
|
| 85 |
-
- split: ood_diff_density
|
| 86 |
-
path: "data/configs/in_state_train_Karnataka__ood_Rajasthan/ood_diff_density-*.parquet"
|
| 87 |
-
- config_name: in_state_train_Rajasthan__ood_Karnataka
|
| 88 |
data_files:
|
| 89 |
- split: train
|
| 90 |
-
path: "data/configs/
|
| 91 |
-
- split:
|
| 92 |
-
path: "data/configs/
|
| 93 |
- split: ood_test
|
| 94 |
-
path: "data/configs/
|
| 95 |
-
|
| 96 |
-
path: "data/configs/in_state_train_Rajasthan__ood_Karnataka/ood_same_density-*.parquet"
|
| 97 |
-
- split: ood_diff_density
|
| 98 |
-
path: "data/configs/in_state_train_Rajasthan__ood_Karnataka/ood_diff_density-*.parquet"
|
| 99 |
-
- config_name: intl_train_IN__ood_US
|
| 100 |
data_files:
|
| 101 |
- split: train
|
| 102 |
-
path: "data/configs/
|
| 103 |
-
- split:
|
| 104 |
-
path: "data/configs/
|
| 105 |
- split: ood_test
|
| 106 |
-
path: "data/configs/
|
| 107 |
-
- split: ood_same_density
|
| 108 |
-
path: "data/configs/intl_train_IN__ood_US/ood_same_density-*.parquet"
|
| 109 |
-
- split: ood_diff_density
|
| 110 |
-
path: "data/configs/intl_train_IN__ood_US/ood_diff_density-*.parquet"
|
| 111 |
-
- config_name: intl_train_US__ood_IN
|
| 112 |
-
data_files:
|
| 113 |
-
- split: train
|
| 114 |
-
path: "data/configs/intl_train_US__ood_IN/train-*.parquet"
|
| 115 |
-
- split: id_test
|
| 116 |
-
path: "data/configs/intl_train_US__ood_IN/id_test-*.parquet"
|
| 117 |
-
- split: ood_test
|
| 118 |
-
path: "data/configs/intl_train_US__ood_IN/ood_test-*.parquet"
|
| 119 |
-
- split: ood_same_density
|
| 120 |
-
path: "data/configs/intl_train_US__ood_IN/ood_same_density-*.parquet"
|
| 121 |
-
- split: ood_diff_density
|
| 122 |
-
path: "data/configs/intl_train_US__ood_IN/ood_diff_density-*.parquet"
|
| 123 |
---
|
| 124 |
|
| 125 |
# Tree Distribution Shift — Satellite Tree Detection (COCO + HF Datasets)
|
|
@@ -127,21 +71,45 @@ configs:
|
|
| 127 |
This is a dataset containing ~30K COCO tree crown annotated satellite image tiles of 400x400 px dimensions. These annotations come from all states in India and California in the United States.
|
| 128 |
This dataset is organized as **configs** (distribution shift benchmarks). Each config provides **three splits**:
|
| 129 |
|
| 130 |
-
- `train`
|
| 131 |
-
- `
|
| 132 |
-
- `ood_test`
|
| 133 |
|
| 134 |
## What is a config?
|
| 135 |
|
| 136 |
-
A **config** fully defines a benchmark setting (e.g., country shift,
|
| 137 |
When you select a config, you automatically get:
|
| 138 |
|
| 139 |
- `train` split
|
| 140 |
-
- `
|
| 141 |
- `ood_test` split
|
| 142 |
|
| 143 |
No filtering or custom split logic is required.
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
---
|
| 146 |
|
| 147 |
# Export to COCO (recommended for training)
|
|
@@ -167,30 +135,30 @@ https://huggingface.co/datasets/aadityabuilds/tree-distribution-shift
|
|
| 167 |
|
| 168 |
Example config:
|
| 169 |
```
|
| 170 |
-
|
| 171 |
```
|
| 172 |
|
| 173 |
## Step 4 — Export to COCO (one command)
|
| 174 |
```bash
|
| 175 |
python tools/export_coco.py \
|
| 176 |
--repo aadityabuilds/tree-distribution-shift \
|
| 177 |
-
--config
|
| 178 |
--out ./coco_out
|
| 179 |
```
|
| 180 |
|
| 181 |
## Output structure
|
| 182 |
```
|
| 183 |
coco_out/
|
| 184 |
-
└──
|
| 185 |
├── train/
|
| 186 |
│ ├── images/
|
| 187 |
│ │ └── *.tiff
|
| 188 |
│ └── annotations/
|
| 189 |
│ └── instances_train.json
|
| 190 |
-
├──
|
| 191 |
│ ├── images/
|
| 192 |
│ └── annotations/
|
| 193 |
-
│ └──
|
| 194 |
└── ood_test/
|
| 195 |
├── images/
|
| 196 |
└── annotations/
|
|
@@ -208,21 +176,21 @@ Use this when you want programmatic access (e.g., notebooks, statistics, custom
|
|
| 208 |
pip install datasets
|
| 209 |
```
|
| 210 |
|
| 211 |
-
## Load a config (gets train /
|
| 212 |
```python
|
| 213 |
from datasets import load_dataset
|
| 214 |
|
| 215 |
ds = load_dataset(
|
| 216 |
"aadityabuilds/tree-distribution-shift",
|
| 217 |
-
"
|
| 218 |
)
|
| 219 |
|
| 220 |
-
train
|
| 221 |
-
|
| 222 |
-
ood_test= ds["ood_test"]
|
| 223 |
|
| 224 |
print(ds)
|
| 225 |
-
print(len(train), len(
|
| 226 |
print(train[0].keys())
|
| 227 |
```
|
| 228 |
|
|
@@ -233,12 +201,4 @@ Each row includes:
|
|
| 233 |
- `image_bytes` (raw image bytes)
|
| 234 |
- `coco_annotations` (COCO annotations for that image)
|
| 235 |
- `coco_categories` (COCO categories)
|
| 236 |
-
- metadata fields (country, state, zone, biome, etc.)
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
## Density-aware OOD splits
|
| 240 |
-
Some configs also include:
|
| 241 |
-
- ood_same_density
|
| 242 |
-
- ood_diff_density
|
| 243 |
-
|
| 244 |
-
These partition the OOD split by whether matches the IID train distribution.
|
|
|
|
| 1 |
---
|
| 2 |
configs:
|
| 3 |
+
- config_name: intl_train_IN__ood_US
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
data_files:
|
| 5 |
- split: train
|
| 6 |
+
path: "data/configs/intl_train_IN__ood_US/train-*.parquet"
|
| 7 |
+
- split: val
|
| 8 |
+
path: "data/configs/intl_train_IN__ood_US/val-*.parquet"
|
| 9 |
- split: ood_test
|
| 10 |
+
path: "data/configs/intl_train_IN__ood_US/ood_test-*.parquet"
|
| 11 |
+
- config_name: intl_train_US__ood_IN
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
data_files:
|
| 13 |
- split: train
|
| 14 |
+
path: "data/configs/intl_train_US__ood_IN/train-*.parquet"
|
| 15 |
+
- split: val
|
| 16 |
+
path: "data/configs/intl_train_US__ood_IN/val-*.parquet"
|
| 17 |
- split: ood_test
|
| 18 |
+
path: "data/configs/intl_train_US__ood_IN/ood_test-*.parquet"
|
| 19 |
+
- config_name: biome_Rajasthan_train_WET__ood_DRY
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
data_files:
|
| 21 |
- split: train
|
| 22 |
+
path: "data/configs/biome_Rajasthan_train_WET__ood_DRY/train-*.parquet"
|
| 23 |
+
- split: val
|
| 24 |
+
path: "data/configs/biome_Rajasthan_train_WET__ood_DRY/val-*.parquet"
|
| 25 |
- split: ood_test
|
| 26 |
+
path: "data/configs/biome_Rajasthan_train_WET__ood_DRY/ood_test-*.parquet"
|
| 27 |
+
- config_name: biome_Rajasthan_train_DRY__ood_WET
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
data_files:
|
| 29 |
- split: train
|
| 30 |
+
path: "data/configs/biome_Rajasthan_train_DRY__ood_WET/train-*.parquet"
|
| 31 |
+
- split: val
|
| 32 |
+
path: "data/configs/biome_Rajasthan_train_DRY__ood_WET/val-*.parquet"
|
| 33 |
- split: ood_test
|
| 34 |
+
path: "data/configs/biome_Rajasthan_train_DRY__ood_WET/ood_test-*.parquet"
|
| 35 |
+
- config_name: biome_Karnataka_train_WET__ood_DRY
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
data_files:
|
| 37 |
- split: train
|
| 38 |
+
path: "data/configs/biome_Karnataka_train_WET__ood_DRY/train-*.parquet"
|
| 39 |
+
- split: val
|
| 40 |
+
path: "data/configs/biome_Karnataka_train_WET__ood_DRY/val-*.parquet"
|
| 41 |
- split: ood_test
|
| 42 |
+
path: "data/configs/biome_Karnataka_train_WET__ood_DRY/ood_test-*.parquet"
|
| 43 |
+
- config_name: biome_Karnataka_train_DRY__ood_WET
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
data_files:
|
| 45 |
- split: train
|
| 46 |
+
path: "data/configs/biome_Karnataka_train_DRY__ood_WET/train-*.parquet"
|
| 47 |
+
- split: val
|
| 48 |
+
path: "data/configs/biome_Karnataka_train_DRY__ood_WET/val-*.parquet"
|
| 49 |
- split: ood_test
|
| 50 |
+
path: "data/configs/biome_Karnataka_train_DRY__ood_WET/ood_test-*.parquet"
|
| 51 |
+
- config_name: region_train_North__ood_South
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
data_files:
|
| 53 |
- split: train
|
| 54 |
+
path: "data/configs/region_train_North__ood_South/train-*.parquet"
|
| 55 |
+
- split: val
|
| 56 |
+
path: "data/configs/region_train_North__ood_South/val-*.parquet"
|
| 57 |
- split: ood_test
|
| 58 |
+
path: "data/configs/region_train_North__ood_South/ood_test-*.parquet"
|
| 59 |
+
- config_name: region_train_South__ood_North
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
data_files:
|
| 61 |
- split: train
|
| 62 |
+
path: "data/configs/region_train_South__ood_North/train-*.parquet"
|
| 63 |
+
- split: val
|
| 64 |
+
path: "data/configs/region_train_South__ood_North/val-*.parquet"
|
| 65 |
- split: ood_test
|
| 66 |
+
path: "data/configs/region_train_South__ood_North/ood_test-*.parquet"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
---
|
| 68 |
|
| 69 |
# Tree Distribution Shift — Satellite Tree Detection (COCO + HF Datasets)
|
|
|
|
| 71 |
This is a dataset containing ~30K COCO tree crown annotated satellite image tiles of 400x400 px dimensions. These annotations come from all states in India and California in the United States.
|
| 72 |
This dataset is organized as **configs** (distribution shift benchmarks). Each config provides **three splits**:
|
| 73 |
|
| 74 |
+
- `train` — 90% of the in-distribution pool
|
| 75 |
+
- `val` — 10% held-out from the in-distribution pool (same images appear as `ood_test` in the paired config)
|
| 76 |
+
- `ood_test` — held-out portion from the out-of-distribution pool
|
| 77 |
|
| 78 |
## What is a config?
|
| 79 |
|
| 80 |
+
A **config** fully defines a benchmark setting (e.g., country shift, biome shift, region shift).
|
| 81 |
When you select a config, you automatically get:
|
| 82 |
|
| 83 |
- `train` split
|
| 84 |
+
- `val` split
|
| 85 |
- `ood_test` split
|
| 86 |
|
| 87 |
No filtering or custom split logic is required.
|
| 88 |
|
| 89 |
+
## Shared test sets
|
| 90 |
+
|
| 91 |
+
Configs come in pairs. For every pair, the test portion of each pool is **constant** regardless of whether it is used as `val` (in-distribution) or `ood_test` (out-of-distribution). For example:
|
| 92 |
+
|
| 93 |
+
| Config | train | val | ood_test |
|
| 94 |
+
|--------|-------|-----|----------|
|
| 95 |
+
| `intl_train_IN__ood_US` | 90% of India | 10% of India | 10% of US |
|
| 96 |
+
| `intl_train_US__ood_IN` | 90% of US | 10% of US | 10% of India |
|
| 97 |
+
|
| 98 |
+
The "10% of India" set is identical in both rows, and so is the "10% of US" set.
|
| 99 |
+
|
| 100 |
+
## Available configs
|
| 101 |
+
|
| 102 |
+
| # | Config name | Shift type | Train on | OOD from |
|
| 103 |
+
|---|-------------|-----------|----------|----------|
|
| 104 |
+
| 1 | `intl_train_IN__ood_US` | Country | India | US |
|
| 105 |
+
| 2 | `intl_train_US__ood_IN` | Country | US | India |
|
| 106 |
+
| 3 | `biome_Rajasthan_train_WET__ood_DRY` | Biome | Rajasthan WET | Rajasthan DRY |
|
| 107 |
+
| 4 | `biome_Rajasthan_train_DRY__ood_WET` | Biome | Rajasthan DRY | Rajasthan WET |
|
| 108 |
+
| 5 | `biome_Karnataka_train_WET__ood_DRY` | Biome | Karnataka WET | Karnataka DRY |
|
| 109 |
+
| 6 | `biome_Karnataka_train_DRY__ood_WET` | Biome | Karnataka DRY | Karnataka WET |
|
| 110 |
+
| 7 | `region_train_North__ood_South` | Region | North India | South India |
|
| 111 |
+
| 8 | `region_train_South__ood_North` | Region | South India | North India |
|
| 112 |
+
|
| 113 |
---
|
| 114 |
|
| 115 |
# Export to COCO (recommended for training)
|
|
|
|
| 135 |
|
| 136 |
Example config:
|
| 137 |
```
|
| 138 |
+
intl_train_IN__ood_US
|
| 139 |
```
|
| 140 |
|
| 141 |
## Step 4 — Export to COCO (one command)
|
| 142 |
```bash
|
| 143 |
python tools/export_coco.py \
|
| 144 |
--repo aadityabuilds/tree-distribution-shift \
|
| 145 |
+
--config intl_train_IN__ood_US \
|
| 146 |
--out ./coco_out
|
| 147 |
```
|
| 148 |
|
| 149 |
## Output structure
|
| 150 |
```
|
| 151 |
coco_out/
|
| 152 |
+
└── intl_train_IN__ood_US/
|
| 153 |
├── train/
|
| 154 |
│ ├── images/
|
| 155 |
│ │ └── *.tiff
|
| 156 |
│ └── annotations/
|
| 157 |
│ └── instances_train.json
|
| 158 |
+
├── val/
|
| 159 |
│ ├── images/
|
| 160 |
│ └── annotations/
|
| 161 |
+
│ └── instances_val.json
|
| 162 |
└── ood_test/
|
| 163 |
├── images/
|
| 164 |
└── annotations/
|
|
|
|
| 176 |
pip install datasets
|
| 177 |
```
|
| 178 |
|
| 179 |
+
## Load a config (gets train / val / ood_test)
|
| 180 |
```python
|
| 181 |
from datasets import load_dataset
|
| 182 |
|
| 183 |
ds = load_dataset(
|
| 184 |
"aadityabuilds/tree-distribution-shift",
|
| 185 |
+
"intl_train_IN__ood_US"
|
| 186 |
)
|
| 187 |
|
| 188 |
+
train = ds["train"]
|
| 189 |
+
val = ds["val"]
|
| 190 |
+
ood_test = ds["ood_test"]
|
| 191 |
|
| 192 |
print(ds)
|
| 193 |
+
print(len(train), len(val), len(ood_test))
|
| 194 |
print(train[0].keys())
|
| 195 |
```
|
| 196 |
|
|
|
|
| 201 |
- `image_bytes` (raw image bytes)
|
| 202 |
- `coco_annotations` (COCO annotations for that image)
|
| 203 |
- `coco_categories` (COCO categories)
|
| 204 |
+
- metadata fields (country, state, zone, region, biome, etc.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tools/build_master_parquet.py
CHANGED
|
@@ -69,6 +69,7 @@ def main():
|
|
| 69 |
"country": r.country,
|
| 70 |
"state": r.state,
|
| 71 |
"zone": str(r.zone),
|
|
|
|
| 72 |
"width": int(img_info.get("width", -1)),
|
| 73 |
"height": int(img_info.get("height", -1)),
|
| 74 |
"image_bytes": b,
|
|
|
|
| 69 |
"country": r.country,
|
| 70 |
"state": r.state,
|
| 71 |
"zone": str(r.zone),
|
| 72 |
+
"region": str(getattr(r, "region", "")),
|
| 73 |
"width": int(img_info.get("width", -1)),
|
| 74 |
"height": int(img_info.get("height", -1)),
|
| 75 |
"image_bytes": b,
|
tools/make_configs_from_metadata.py
CHANGED
|
@@ -36,7 +36,7 @@ def write_rows_to_parquet(rows_iter, out_dir: Path, split: str, rows_per_shard:
|
|
| 36 |
def fetch_rows_by_filenames(master: ds.Dataset, filenames: Set[str]):
|
| 37 |
# For 27K rows, scanning + filtering in Python is acceptable and robust.
|
| 38 |
scanner = master.scanner(columns=[
|
| 39 |
-
"image_id","filename","country","state","zone","width","height",
|
| 40 |
"image_bytes","coco_annotations","coco_categories"
|
| 41 |
])
|
| 42 |
for batch in scanner.to_batches():
|
|
@@ -53,7 +53,7 @@ def main():
|
|
| 53 |
ap.add_argument("--master_dir", required=True, help="hf_repo/data/master")
|
| 54 |
ap.add_argument("--out_configs_dir", required=True, help="hf_repo/data/configs")
|
| 55 |
ap.add_argument("--mode", choices=["state_shift", "zone_shift"], required=True)
|
| 56 |
-
ap.add_argument("--train_ratio", type=float, default=0.
|
| 57 |
ap.add_argument("--seed", type=int, default=42)
|
| 58 |
ap.add_argument("--rows_per_shard", type=int, default=256)
|
| 59 |
ap.add_argument("--country", default=None, help="optional: only generate configs for this country (e.g. US)")
|
|
@@ -84,7 +84,7 @@ def main():
|
|
| 84 |
if len(id_files) < args.min_images_per_region:
|
| 85 |
continue
|
| 86 |
|
| 87 |
-
train_files,
|
| 88 |
|
| 89 |
for (c_ood, s_ood) in keys:
|
| 90 |
if c_ood != c_id or s_ood == s_id:
|
|
@@ -94,7 +94,7 @@ def main():
|
|
| 94 |
continue
|
| 95 |
|
| 96 |
cfg = f"state_{c_id}_{s_id}__ood_state_{c_ood}_{s_ood}"
|
| 97 |
-
configs.append((cfg, train_files,
|
| 98 |
if len(configs) >= args.max_configs:
|
| 99 |
break
|
| 100 |
if len(configs) >= args.max_configs:
|
|
@@ -110,7 +110,7 @@ def main():
|
|
| 110 |
if len(id_files) < args.min_images_per_region:
|
| 111 |
continue
|
| 112 |
|
| 113 |
-
train_files,
|
| 114 |
|
| 115 |
for z_ood in zones:
|
| 116 |
if z_ood == z_id:
|
|
@@ -120,18 +120,18 @@ def main():
|
|
| 120 |
continue
|
| 121 |
|
| 122 |
cfg = f"zone_{z_id}__ood_zone_{z_ood}"
|
| 123 |
-
configs.append((cfg, train_files,
|
| 124 |
if len(configs) >= args.max_configs:
|
| 125 |
break
|
| 126 |
if len(configs) >= args.max_configs:
|
| 127 |
break
|
| 128 |
|
| 129 |
-
for cfg_name, train_files,
|
| 130 |
cfg_dir = out_configs / cfg_name
|
| 131 |
cfg_dir.mkdir(parents=True, exist_ok=True)
|
| 132 |
|
| 133 |
write_rows_to_parquet(fetch_rows_by_filenames(master, train_files), cfg_dir, "train", args.rows_per_shard)
|
| 134 |
-
write_rows_to_parquet(fetch_rows_by_filenames(master,
|
| 135 |
write_rows_to_parquet(fetch_rows_by_filenames(master, ood_files), cfg_dir, "ood_test", args.rows_per_shard)
|
| 136 |
|
| 137 |
print(f"Wrote config: {cfg_name}")
|
|
|
|
| 36 |
def fetch_rows_by_filenames(master: ds.Dataset, filenames: Set[str]):
|
| 37 |
# For 27K rows, scanning + filtering in Python is acceptable and robust.
|
| 38 |
scanner = master.scanner(columns=[
|
| 39 |
+
"image_id","filename","country","state","zone","region","width","height",
|
| 40 |
"image_bytes","coco_annotations","coco_categories"
|
| 41 |
])
|
| 42 |
for batch in scanner.to_batches():
|
|
|
|
| 53 |
ap.add_argument("--master_dir", required=True, help="hf_repo/data/master")
|
| 54 |
ap.add_argument("--out_configs_dir", required=True, help="hf_repo/data/configs")
|
| 55 |
ap.add_argument("--mode", choices=["state_shift", "zone_shift"], required=True)
|
| 56 |
+
ap.add_argument("--train_ratio", type=float, default=0.9)
|
| 57 |
ap.add_argument("--seed", type=int, default=42)
|
| 58 |
ap.add_argument("--rows_per_shard", type=int, default=256)
|
| 59 |
ap.add_argument("--country", default=None, help="optional: only generate configs for this country (e.g. US)")
|
|
|
|
| 84 |
if len(id_files) < args.min_images_per_region:
|
| 85 |
continue
|
| 86 |
|
| 87 |
+
train_files, val_files = split_list(id_files, args.train_ratio, args.seed)
|
| 88 |
|
| 89 |
for (c_ood, s_ood) in keys:
|
| 90 |
if c_ood != c_id or s_ood == s_id:
|
|
|
|
| 94 |
continue
|
| 95 |
|
| 96 |
cfg = f"state_{c_id}_{s_id}__ood_state_{c_ood}_{s_ood}"
|
| 97 |
+
configs.append((cfg, train_files, val_files, set(ood_files)))
|
| 98 |
if len(configs) >= args.max_configs:
|
| 99 |
break
|
| 100 |
if len(configs) >= args.max_configs:
|
|
|
|
| 110 |
if len(id_files) < args.min_images_per_region:
|
| 111 |
continue
|
| 112 |
|
| 113 |
+
train_files, val_files = split_list(id_files, args.train_ratio, args.seed)
|
| 114 |
|
| 115 |
for z_ood in zones:
|
| 116 |
if z_ood == z_id:
|
|
|
|
| 120 |
continue
|
| 121 |
|
| 122 |
cfg = f"zone_{z_id}__ood_zone_{z_ood}"
|
| 123 |
+
configs.append((cfg, train_files, val_files, set(ood_files)))
|
| 124 |
if len(configs) >= args.max_configs:
|
| 125 |
break
|
| 126 |
if len(configs) >= args.max_configs:
|
| 127 |
break
|
| 128 |
|
| 129 |
+
for cfg_name, train_files, val_files, ood_files in configs:
|
| 130 |
cfg_dir = out_configs / cfg_name
|
| 131 |
cfg_dir.mkdir(parents=True, exist_ok=True)
|
| 132 |
|
| 133 |
write_rows_to_parquet(fetch_rows_by_filenames(master, train_files), cfg_dir, "train", args.rows_per_shard)
|
| 134 |
+
write_rows_to_parquet(fetch_rows_by_filenames(master, val_files), cfg_dir, "val", args.rows_per_shard)
|
| 135 |
write_rows_to_parquet(fetch_rows_by_filenames(master, ood_files), cfg_dir, "ood_test", args.rows_per_shard)
|
| 136 |
|
| 137 |
print(f"Wrote config: {cfg_name}")
|
tools/make_named_configs.py
CHANGED
|
@@ -2,7 +2,6 @@ import argparse
|
|
| 2 |
from pathlib import Path
|
| 3 |
from typing import List, Set, Tuple, Dict
|
| 4 |
import random
|
| 5 |
-
from collections import Counter
|
| 6 |
|
| 7 |
import pandas as pd
|
| 8 |
import pyarrow.dataset as ds
|
|
@@ -10,29 +9,16 @@ import pyarrow as pa
|
|
| 10 |
import pyarrow.parquet as pq
|
| 11 |
|
| 12 |
|
| 13 |
-
def
|
|
|
|
| 14 |
rng = random.Random(seed)
|
| 15 |
items = list(items)
|
| 16 |
rng.shuffle(items)
|
| 17 |
n_train = int(round(train_ratio * len(items)))
|
| 18 |
-
return
|
| 19 |
|
| 20 |
|
| 21 |
-
def
|
| 22 |
-
sub = meta[meta["filename"].isin(filenames)]
|
| 23 |
-
counts = Counter(sub["density_category"].astype(str).str.upper().str.strip().tolist())
|
| 24 |
-
return "HIGH" if counts.get("HIGH", 0) >= counts.get("LOW", 0) else "LOW"
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
def partition_ood_by_density(meta: pd.DataFrame, ood_files: List[str], iid_dom_density: str) -> Tuple[Set[str], Set[str]]:
|
| 28 |
-
ood_df = meta[meta["filename"].isin(ood_files)].copy()
|
| 29 |
-
ood_df["density_category"] = ood_df["density_category"].astype(str).str.upper().str.strip()
|
| 30 |
-
same = set(ood_df[ood_df["density_category"] == iid_dom_density]["filename"].tolist())
|
| 31 |
-
diff = set(ood_df[ood_df["density_category"] != iid_dom_density]["filename"].tolist())
|
| 32 |
-
return same, diff
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
def ensure_min(name: str, files: Set[str], min_count: int):
|
| 36 |
if len(files) < min_count:
|
| 37 |
raise RuntimeError(f"{name}: only {len(files)} files (<{min_count}).")
|
| 38 |
|
|
@@ -44,8 +30,8 @@ def build_light_index(master_dir: str, scan_batch_size: int) -> Dict[str, Dict]:
|
|
| 44 |
"""
|
| 45 |
master = ds.dataset(master_dir, format="parquet")
|
| 46 |
cols = [
|
| 47 |
-
"image_id","filename","country","state","zone","
|
| 48 |
-
"coco_annotations","coco_categories"
|
| 49 |
]
|
| 50 |
scanner = master.scanner(columns=cols, batch_size=scan_batch_size)
|
| 51 |
|
|
@@ -75,38 +61,30 @@ def write_rows_to_parquet(rows_iter, out_dir: Path, split: str, rows_per_shard:
|
|
| 75 |
pq.write_table(table, out_dir / f"{split}-{shard:05d}.parquet", compression="zstd")
|
| 76 |
|
| 77 |
|
| 78 |
-
def rows_from_files(filenames
|
| 79 |
-
"""
|
| 80 |
-
Materialize full rows by reading image bytes directly from disk.
|
| 81 |
-
"""
|
| 82 |
for fn in filenames:
|
| 83 |
base = light_index.get(fn)
|
| 84 |
if base is None:
|
| 85 |
continue
|
| 86 |
img_path = images_root / fn
|
| 87 |
-
|
| 88 |
-
img_bytes = img_path.read_bytes()
|
| 89 |
-
|
| 90 |
-
yield {
|
| 91 |
-
**base,
|
| 92 |
-
"image_bytes": img_bytes,
|
| 93 |
-
}
|
| 94 |
|
| 95 |
|
| 96 |
def main():
|
| 97 |
ap = argparse.ArgumentParser()
|
| 98 |
-
ap.add_argument("--src_root", required=True,
|
| 99 |
-
|
| 100 |
-
ap.add_argument("--
|
| 101 |
-
|
| 102 |
-
ap.add_argument("--
|
|
|
|
|
|
|
| 103 |
ap.add_argument("--seed", type=int, default=42)
|
| 104 |
ap.add_argument("--rows_per_shard", type=int, default=16)
|
| 105 |
ap.add_argument("--scan_batch_size", type=int, default=32)
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
ap.add_argument("--min_ood_pool", type=int, default=200)
|
| 109 |
-
ap.add_argument("--min_ood_bucket", type=int, default=50)
|
| 110 |
args = ap.parse_args()
|
| 111 |
|
| 112 |
src_root = Path(args.src_root)
|
|
@@ -120,20 +98,14 @@ def main():
|
|
| 120 |
|
| 121 |
meta = pd.read_csv(meta_path)
|
| 122 |
|
| 123 |
-
required = {"filename", "country", "state", "zone", "biome", "
|
| 124 |
missing = required - set(meta.columns)
|
| 125 |
if missing:
|
| 126 |
raise RuntimeError(f"metadata.csv missing required columns: {sorted(missing)}")
|
| 127 |
|
| 128 |
meta["biome"] = meta["biome"].astype(str).str.upper().str.strip()
|
| 129 |
-
meta["
|
| 130 |
|
| 131 |
-
allowed = {"LOW", "HIGH"}
|
| 132 |
-
bad = set(meta["density_category"].unique()) - allowed
|
| 133 |
-
if bad:
|
| 134 |
-
raise RuntimeError(f"density_category contains unexpected values: {sorted(bad)} (expected only LOW/HIGH)")
|
| 135 |
-
|
| 136 |
-
# Build lightweight index (no image_bytes)
|
| 137 |
print("Building lightweight master index (no image_bytes)...")
|
| 138 |
light_index = build_light_index(args.master_dir, args.scan_batch_size)
|
| 139 |
print(f"Indexed {len(light_index)} rows from master.")
|
|
@@ -141,65 +113,101 @@ def main():
|
|
| 141 |
out_root = Path(args.out_configs_dir)
|
| 142 |
out_root.mkdir(parents=True, exist_ok=True)
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
)
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
|
| 204 |
|
| 205 |
if __name__ == "__main__":
|
|
|
|
| 2 |
from pathlib import Path
|
| 3 |
from typing import List, Set, Tuple, Dict
|
| 4 |
import random
|
|
|
|
| 5 |
|
| 6 |
import pandas as pd
|
| 7 |
import pyarrow.dataset as ds
|
|
|
|
| 9 |
import pyarrow.parquet as pq
|
| 10 |
|
| 11 |
|
| 12 |
+
def split_pool(items: List[str], train_ratio: float, seed: int) -> Tuple[List[str], List[str]]:
|
| 13 |
+
"""Deterministically split a pool into (train, test) portions."""
|
| 14 |
rng = random.Random(seed)
|
| 15 |
items = list(items)
|
| 16 |
rng.shuffle(items)
|
| 17 |
n_train = int(round(train_ratio * len(items)))
|
| 18 |
+
return items[:n_train], items[n_train:]
|
| 19 |
|
| 20 |
|
| 21 |
+
def ensure_min(name: str, files, min_count: int):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
if len(files) < min_count:
|
| 23 |
raise RuntimeError(f"{name}: only {len(files)} files (<{min_count}).")
|
| 24 |
|
|
|
|
| 30 |
"""
|
| 31 |
master = ds.dataset(master_dir, format="parquet")
|
| 32 |
cols = [
|
| 33 |
+
"image_id", "filename", "country", "state", "zone", "region",
|
| 34 |
+
"width", "height", "coco_annotations", "coco_categories",
|
| 35 |
]
|
| 36 |
scanner = master.scanner(columns=cols, batch_size=scan_batch_size)
|
| 37 |
|
|
|
|
| 61 |
pq.write_table(table, out_dir / f"{split}-{shard:05d}.parquet", compression="zstd")
|
| 62 |
|
| 63 |
|
| 64 |
+
def rows_from_files(filenames, light_index: Dict[str, Dict], images_root: Path):
|
| 65 |
+
"""Materialize full rows by reading image bytes directly from disk."""
|
|
|
|
|
|
|
| 66 |
for fn in filenames:
|
| 67 |
base = light_index.get(fn)
|
| 68 |
if base is None:
|
| 69 |
continue
|
| 70 |
img_path = images_root / fn
|
| 71 |
+
yield {**base, "image_bytes": img_path.read_bytes()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
|
| 74 |
def main():
|
| 75 |
ap = argparse.ArgumentParser()
|
| 76 |
+
ap.add_argument("--src_root", required=True,
|
| 77 |
+
help="root containing metadata.csv and world_images/")
|
| 78 |
+
ap.add_argument("--master_dir", required=True,
|
| 79 |
+
help="hf_repo/data/master (parquet shards)")
|
| 80 |
+
ap.add_argument("--out_configs_dir", required=True,
|
| 81 |
+
help="hf_repo/data/configs")
|
| 82 |
+
ap.add_argument("--train_ratio", type=float, default=0.9)
|
| 83 |
ap.add_argument("--seed", type=int, default=42)
|
| 84 |
ap.add_argument("--rows_per_shard", type=int, default=16)
|
| 85 |
ap.add_argument("--scan_batch_size", type=int, default=32)
|
| 86 |
+
ap.add_argument("--min_pool", type=int, default=200,
|
| 87 |
+
help="minimum images required in a pool to create a config")
|
|
|
|
|
|
|
| 88 |
args = ap.parse_args()
|
| 89 |
|
| 90 |
src_root = Path(args.src_root)
|
|
|
|
| 98 |
|
| 99 |
meta = pd.read_csv(meta_path)
|
| 100 |
|
| 101 |
+
required = {"filename", "country", "state", "zone", "biome", "region"}
|
| 102 |
missing = required - set(meta.columns)
|
| 103 |
if missing:
|
| 104 |
raise RuntimeError(f"metadata.csv missing required columns: {sorted(missing)}")
|
| 105 |
|
| 106 |
meta["biome"] = meta["biome"].astype(str).str.upper().str.strip()
|
| 107 |
+
meta["region"] = meta["region"].astype(str).str.strip()
|
| 108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
print("Building lightweight master index (no image_bytes)...")
|
| 110 |
light_index = build_light_index(args.master_dir, args.scan_batch_size)
|
| 111 |
print(f"Indexed {len(light_index)} rows from master.")
|
|
|
|
| 113 |
out_root = Path(args.out_configs_dir)
|
| 114 |
out_root.mkdir(parents=True, exist_ok=True)
|
| 115 |
|
| 116 |
+
# Pre-split every pool deterministically so that the test portion is
|
| 117 |
+
# identical regardless of whether the pool is used as ID or OOD.
|
| 118 |
+
pool_splits: Dict[str, Tuple[List[str], List[str]]] = {}
|
| 119 |
+
|
| 120 |
+
def get_pool_split(pool_key: str, filenames: List[str]) -> Tuple[List[str], List[str]]:
|
| 121 |
+
if pool_key not in pool_splits:
|
| 122 |
+
pool_splits[pool_key] = split_pool(filenames, args.train_ratio, args.seed)
|
| 123 |
+
return pool_splits[pool_key]
|
| 124 |
+
|
| 125 |
+
def materialize_pair(cfg_name_a: str, cfg_name_b: str,
|
| 126 |
+
pool_key_a: str, files_a: List[str],
|
| 127 |
+
pool_key_b: str, files_b: List[str]):
|
| 128 |
+
"""
|
| 129 |
+
Create two paired configs where the test portion of each pool is
|
| 130 |
+
constant across both configs.
|
| 131 |
+
|
| 132 |
+
Config A: train on pool A, OOD = pool B
|
| 133 |
+
train = A's 90%
|
| 134 |
+
val = A's 10% (same images as ood_test in config B)
|
| 135 |
+
ood_test = B's 10% (same images as val in config B)
|
| 136 |
+
|
| 137 |
+
Config B: symmetric.
|
| 138 |
+
"""
|
| 139 |
+
train_a, test_a = get_pool_split(pool_key_a, files_a)
|
| 140 |
+
train_b, test_b = get_pool_split(pool_key_b, files_b)
|
| 141 |
+
|
| 142 |
+
ensure_min(cfg_name_a + ":train", train_a, args.min_pool)
|
| 143 |
+
ensure_min(cfg_name_a + ":val", test_a, 10)
|
| 144 |
+
ensure_min(cfg_name_a + ":ood_test", test_b, 10)
|
| 145 |
+
ensure_min(cfg_name_b + ":train", train_b, args.min_pool)
|
| 146 |
+
ensure_min(cfg_name_b + ":val", test_b, 10)
|
| 147 |
+
ensure_min(cfg_name_b + ":ood_test", test_a, 10)
|
| 148 |
+
|
| 149 |
+
for cfg_name, train_files, val_files, ood_files in [
|
| 150 |
+
(cfg_name_a, train_a, test_a, test_b),
|
| 151 |
+
(cfg_name_b, train_b, test_b, test_a),
|
| 152 |
+
]:
|
| 153 |
+
cfg_dir = out_root / cfg_name
|
| 154 |
+
cfg_dir.mkdir(parents=True, exist_ok=True)
|
| 155 |
+
|
| 156 |
+
write_rows_to_parquet(
|
| 157 |
+
rows_from_files(train_files, light_index, images_root),
|
| 158 |
+
cfg_dir, "train", args.rows_per_shard)
|
| 159 |
+
write_rows_to_parquet(
|
| 160 |
+
rows_from_files(val_files, light_index, images_root),
|
| 161 |
+
cfg_dir, "val", args.rows_per_shard)
|
| 162 |
+
write_rows_to_parquet(
|
| 163 |
+
rows_from_files(ood_files, light_index, images_root),
|
| 164 |
+
cfg_dir, "ood_test", args.rows_per_shard)
|
| 165 |
+
|
| 166 |
+
print(f" {cfg_name}: train={len(train_files)} val={len(val_files)} ood_test={len(ood_files)}")
|
| 167 |
+
|
| 168 |
+
# ---- 1) US vs India (country field) ----
|
| 169 |
+
print("\n=== Country shift: US vs India ===")
|
| 170 |
+
files_in = meta[meta["country"] == "India"]["filename"].tolist()
|
| 171 |
+
files_us = meta[meta["country"] == "US"]["filename"].tolist()
|
| 172 |
+
materialize_pair(
|
| 173 |
+
"intl_train_IN__ood_US", "intl_train_US__ood_IN",
|
| 174 |
+
"country:India", files_in,
|
| 175 |
+
"country:US", files_us,
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
# ---- 2) Wet vs Dry biome in Rajasthan ----
|
| 179 |
+
print("\n=== Biome shift: Rajasthan WET vs DRY ===")
|
| 180 |
+
raj = meta[(meta["country"] == "India") & (meta["state"] == "Rajasthan")]
|
| 181 |
+
raj_wet = raj[raj["biome"] == "WET"]["filename"].tolist()
|
| 182 |
+
raj_dry = raj[raj["biome"] == "DRY"]["filename"].tolist()
|
| 183 |
+
materialize_pair(
|
| 184 |
+
"biome_Rajasthan_train_WET__ood_DRY", "biome_Rajasthan_train_DRY__ood_WET",
|
| 185 |
+
"biome:Rajasthan:WET", raj_wet,
|
| 186 |
+
"biome:Rajasthan:DRY", raj_dry,
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
# ---- 3) Wet vs Dry biome in Karnataka ----
|
| 190 |
+
print("\n=== Biome shift: Karnataka WET vs DRY ===")
|
| 191 |
+
kar = meta[(meta["country"] == "India") & (meta["state"] == "Karnataka")]
|
| 192 |
+
kar_wet = kar[kar["biome"] == "WET"]["filename"].tolist()
|
| 193 |
+
kar_dry = kar[kar["biome"] == "DRY"]["filename"].tolist()
|
| 194 |
+
materialize_pair(
|
| 195 |
+
"biome_Karnataka_train_WET__ood_DRY", "biome_Karnataka_train_DRY__ood_WET",
|
| 196 |
+
"biome:Karnataka:WET", kar_wet,
|
| 197 |
+
"biome:Karnataka:DRY", kar_dry,
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
# ---- 4) North vs South India (region field) ----
|
| 201 |
+
print("\n=== Region shift: North vs South India ===")
|
| 202 |
+
files_north = meta[meta["region"] == "North"]["filename"].tolist()
|
| 203 |
+
files_south = meta[meta["region"] == "South"]["filename"].tolist()
|
| 204 |
+
materialize_pair(
|
| 205 |
+
"region_train_North__ood_South", "region_train_South__ood_North",
|
| 206 |
+
"region:North", files_north,
|
| 207 |
+
"region:South", files_south,
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
print(f"\nDone. All configs written under: {out_root}")
|
| 211 |
|
| 212 |
|
| 213 |
if __name__ == "__main__":
|
tools/update_readme_yaml.py
CHANGED
|
@@ -8,10 +8,8 @@ CONFIGS_DIR = REPO_ROOT / "data" / "configs"
|
|
| 8 |
|
| 9 |
SPLITS = [
|
| 10 |
"train",
|
| 11 |
-
"
|
| 12 |
"ood_test",
|
| 13 |
-
"ood_same_density",
|
| 14 |
-
"ood_diff_density",
|
| 15 |
]
|
| 16 |
|
| 17 |
def has_files(cfg_dir: Path, split: str) -> bool:
|
|
|
|
| 8 |
|
| 9 |
SPLITS = [
|
| 10 |
"train",
|
| 11 |
+
"val",
|
| 12 |
"ood_test",
|
|
|
|
|
|
|
| 13 |
]
|
| 14 |
|
| 15 |
def has_files(cfg_dir: Path, split: str) -> bool:
|
tools/write_readme.py
CHANGED
|
@@ -22,8 +22,8 @@ def main():
|
|
| 22 |
out_lines.append(" data_files:")
|
| 23 |
out_lines.append(" - split: train")
|
| 24 |
out_lines.append(f" path: \"data/configs/{cfg}/train-*.parquet\"")
|
| 25 |
-
out_lines.append(" - split:
|
| 26 |
-
out_lines.append(f" path: \"data/configs/{cfg}/
|
| 27 |
out_lines.append(" - split: ood_test")
|
| 28 |
out_lines.append(f" path: \"data/configs/{cfg}/ood_test-*.parquet\"")
|
| 29 |
out_lines.append("---")
|
|
@@ -37,9 +37,9 @@ def main():
|
|
| 37 |
out_lines.append("This dataset is organized as **configs** (distribution shift settings).")
|
| 38 |
out_lines.append("Each config provides 3 splits:")
|
| 39 |
out_lines.append("")
|
| 40 |
-
out_lines.append("- `train`")
|
| 41 |
-
out_lines.append("- `
|
| 42 |
-
out_lines.append("- `ood_test` (
|
| 43 |
out_lines.append("")
|
| 44 |
out_lines.append("## Super simple COCO UX")
|
| 45 |
out_lines.append("")
|
|
@@ -53,7 +53,7 @@ def main():
|
|
| 53 |
out_lines.append("")
|
| 54 |
out_lines.append(f"- `./coco_out/{example}/train/images/*.tiff`")
|
| 55 |
out_lines.append(f"- `./coco_out/{example}/train/annotations/instances_train.json`")
|
| 56 |
-
out_lines.append(f"- `./coco_out/{example}/
|
| 57 |
out_lines.append(f"- `./coco_out/{example}/ood_test/...`")
|
| 58 |
out_lines.append("")
|
| 59 |
out_lines.append("## Programmatic load (optional)")
|
|
|
|
| 22 |
out_lines.append(" data_files:")
|
| 23 |
out_lines.append(" - split: train")
|
| 24 |
out_lines.append(f" path: \"data/configs/{cfg}/train-*.parquet\"")
|
| 25 |
+
out_lines.append(" - split: val")
|
| 26 |
+
out_lines.append(f" path: \"data/configs/{cfg}/val-*.parquet\"")
|
| 27 |
out_lines.append(" - split: ood_test")
|
| 28 |
out_lines.append(f" path: \"data/configs/{cfg}/ood_test-*.parquet\"")
|
| 29 |
out_lines.append("---")
|
|
|
|
| 37 |
out_lines.append("This dataset is organized as **configs** (distribution shift settings).")
|
| 38 |
out_lines.append("Each config provides 3 splits:")
|
| 39 |
out_lines.append("")
|
| 40 |
+
out_lines.append("- `train` (90% of the in-distribution pool)")
|
| 41 |
+
out_lines.append("- `val` (10% held-out from the in-distribution pool)")
|
| 42 |
+
out_lines.append("- `ood_test` (held-out from the out-of-distribution pool)")
|
| 43 |
out_lines.append("")
|
| 44 |
out_lines.append("## Super simple COCO UX")
|
| 45 |
out_lines.append("")
|
|
|
|
| 53 |
out_lines.append("")
|
| 54 |
out_lines.append(f"- `./coco_out/{example}/train/images/*.tiff`")
|
| 55 |
out_lines.append(f"- `./coco_out/{example}/train/annotations/instances_train.json`")
|
| 56 |
+
out_lines.append(f"- `./coco_out/{example}/val/...`")
|
| 57 |
out_lines.append(f"- `./coco_out/{example}/ood_test/...`")
|
| 58 |
out_lines.append("")
|
| 59 |
out_lines.append("## Programmatic load (optional)")
|