-
Notifications
You must be signed in to change notification settings - Fork 7
/
constants.py
180 lines (165 loc) · 5.39 KB
/
constants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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
"""
Project: 🍿POPCORN: High-resolution Population Maps Derived from Sentinel-1 and Sentinel-2 🌍🛰️
Nando Metzger, 2024
"""
import os
import numpy as np
from os.path import dirname
from utils.utils import Namespace
inference_patch_size = 2048
overlap = 128
# data folder
large_file_paths = [
"/scratch2/metzgern/HAC/data",
"/scratch/metzgern/HAC/data",
"/cluster/work/igp_psr/metzgern/HAC/data",
"/cluster/scratch/metzgern"
]
for name in large_file_paths:
if os.path.isdir(name):
large_file_path = name
if large_file_path is None:
raise Exception("No data folder found")
pop_map_root = os.path.join(large_file_path, os.path.join("PopMapData", "processed"))
pop_map_root_large = os.path.join("/scratch2/metzgern/HAC/data", os.path.join("PopMapData", "processed"))
pop_map_covariates = os.path.join(large_file_path, os.path.join("PopMapData", os.path.join("merged", "EE")))
print("pop_map_root", pop_map_root)
# raw data folder
raw_file_paths = [
"/scratch2/metzgern/HAC/data",
"/scratch/metzgern/HAC/data",
"/cluster/work/igp_psr/metzgern/HAC/data",
"/cluster/scratch/metzgern"
]
for name in raw_file_paths:
if os.path.isdir(name):
raw_file_path = name
if raw_file_path is None:
raise Exception("No data folder found")
raw_map_root = os.path.join(raw_file_path, os.path.join("PopMapData", "raw"))
rawEE_map_root = os.path.join(raw_map_root, "EE")
print("rawEE_map_root", rawEE_map_root)
# google buildings data folder
data_paths_aux = [
"/scratch/metzgern/HAC/data",
"/scratch2/metzgern/HAC/data",
"/cluster/work/igp_psr/metzgern/HAC/data",
]
for name in data_paths_aux:
if os.path.isdir(name):
data_path_aux = name
if large_file_path is None:
raise Exception("No data folder found")
pop_gbuildings_path = os.path.join(data_path_aux, os.path.join("PopMapData", os.path.join("raw", "GoogleBuildings")))
print("pop_gbuildings_path", pop_gbuildings_path)
src_path = os.path.dirname(os.path.dirname(__file__))
config_path = os.path.join(os.path.join(src_path, 'data'), 'config')
# Definitions of where to find the census data and the boundaries of the target areas
datalocations = {
'pricp2': {
'fine': {
'boundary': "boundaries4.tif",
'census': "census4.csv",
},
'fineBLOCKCE': {
'boundary': "boundaries_BLOCKCE20.tif",
'census': "census_BLOCKCE20.csv",
},
'fineCOUNTYFP': {
'boundary': "boundaries_COUNTYFP20.tif",
'census': "census_COUNTYFP20.csv",
},
'fineTRACTCE': {
'boundary': "boundaries_TRACTCE20.tif",
'census': "census_TRACTCE20.csv",
},
'coarseTRACTCE': {
'boundary': "boundaries_coarseTRACTCE20.tif",
'census': "census_coarseTRACTCE20.csv",
},
'coarse': {
'boundary': "boundaries_TRACTCE20.tif",
'census': "census_TRACTCE20.csv",
}
},
'rwa': {
'fine100': {
'boundary': "boundaries_kigali100.tif",
'census': "census_kigali100.csv",
},
'coarse': {
'boundary': "boundaries_coarse.tif",
'census': "census_coarse.csv",
}
},
"uga": {
'coarse': {
'boundary': "boundaries.tif",
'census': "census.csv",
},
'fine': {
'boundary': "boundaries.tif",
'census': "census.csv",
},
},
"che": {
'coarse4': {
'boundary': "boundaries_coarse4.tif",
'census': "census_coarse4.csv",
},
'coarse3': {
'boundary': "boundaries_coarse3.tif",
'census': "census_coarse3.csv",
},
'coarse1': {
'boundary': "boundaries_coarse1.tif",
'census': "census_coarse1.csv",
},
'finezurich': {
'boundary': "boundaries_finezurich.tif",
'census': "census_finezurich.csv",
},
'finezurich2': {
'boundary': "boundaries_finezurich2.tif",
'census': "census_finezurich2.csv",
},
'fine': {
'boundary': "boundaries_fine.tif",
'census': "census_fine.csv",
},
'coarse': {
'boundary': "boundaries_coarse4.tif",
'census': "census_coarse4.csv",
},
}
}
testlevels = {
'pricp2': ["fine", "fineTRACTCE"],
'rwa': ["fine100", "coarse"],
'uga': ["coarse"],
'che': ["finezurich2", "coarse4"],
}
testlevels_eval = {
'pricp2': ["fine", "fineTRACTCE"],
'rwa': ["fine100", "coarse"],
'uga': ["coarse"],
'che': ["fine", "finezurich2", "coarse4"],
}
# inicies to skip while training
skip_indices = {
"pricp2": [],
"rwa": [],
"uga": [1323],
"che": [],
}
# DDA model definitions
stage1feats = 8
stage2feats = 16
dda_dir="model/DDA_model/checkpoints/"
MODEL = Namespace(TYPE='dualstreamunet', OUT_CHANNELS=1, IN_CHANNELS=6, TOPOLOGY=[stage1feats, stage2feats,] )
CONSISTENCY_TRAINER = Namespace(LOSS_FACTOR=0.5)
PATHS = Namespace(OUTPUT=dda_dir)
DATALOADER = Namespace(SENTINEL1_BANDS=['VV', 'VH'], SENTINEL2_BANDS=['B02', 'B03', 'B04', 'B08'])
TRAINER = Namespace(LR=1e5)
dda_cfg = Namespace(MODEL=MODEL, CONSISTENCY_TRAINER=CONSISTENCY_TRAINER, PATHS=PATHS,
DATALOADER=DATALOADER, TRAINER=TRAINER, NAME=f"fusionda_newAug{stage1feats}_{stage2feats}")