Skip to content

Commit 3895a5f

Browse files
committed
Merge remote-tracking branch 'origin-orion/rename_paths'
2 parents f285965 + bbba751 commit 3895a5f

5 files changed

Lines changed: 21 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Every script inherits settings from the aforementioned files.
104104
**For PAD:**
105105
1. Run `pad_experiments.py` with the appropriate arguments. Example:
106106
```
107-
python pad_experiments.py --train --model convlstm --parcel_loss --weighted_loss --root_path_coco <coco_folder_path> --prefix_coco <coco_file_prefix> --prefix <run_prefix> --num_epochs 10 --batch_size 32 --bands B02 B03 B04 B08 --saved_medians --img_size 61 61 --requires_norm --num_workers 16 --num_gpus 1 --fixed_window
107+
python pad_experiments.py --train --model convlstm --parcel_loss --weighted_loss --root_path_coco <coco_folder_path> --prefix_coco <coco_file_prefix> --netcdf_path <netcdf_folder_path> --prefix <run_prefix> --num_epochs 10 --batch_size 32 --bands B02 B03 B04 B08 --saved_medians --img_size 61 61 --requires_norm --num_workers 16 --num_gpus 1 --fixed_window
108108
```
109109
The above command is for training the **ConvLSTM** model using the **weighted parcel loss** described in the associated publication. Training will continue for **10 epochs** with **batch size 32**, using the Sentinel-2 **bands Blue (B02), Green (B03), Red (B04) and NIR (B08)**. The **input image size is 61x61**, the **precomputed medians are used** to speed up training and all input data are **normalized**. Finally, a **fixed window** is used containing months 4 (April) through 9 (September). Please use the `--help` argument to find information on all available parameters.
110110
2. Optionally, after training run `visualize_predictions.py` to visualize the image, ground truth and prediction for a specific model and image.

compute_class_weights.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
help='Prefix of the COCO file. Default "exp1_patches2000_strat".')
1919
parser.add_argument('--medians_prefix', type=str, default='exp1_patches2000_strat_61x61', required=False,
2020
help='Prefix of the medians directory. Default "exp1_patches2000_strat_61x61".')
21+
parser.add_argument('--netcdf_path', type=str, default='dataset/netcdf',
22+
help='The path containing the netcdf files. Default "dataset/netcdf".')
2123
parser.add_argument('--out_prefix', type=str, required=False,
2224
help='The prefix to use for the class weights file. Default none.')
2325
parser.add_argument('--ignore_zero', default=False, action='store_true', required=False,
@@ -30,6 +32,7 @@
3032
root_path_coco = Path(args.coco_path)
3133
coco_train = root_path_coco / f'{args.coco_prefix}_coco_train.json'
3234
coco_val = root_path_coco / f'{args.coco_prefix}_coco_val.json'
35+
netcdf_path = Path(args.netcdf_path)
3336

3437
if args.out_prefix is not None:
3538
out_name = f'{args.out_prefix}_class_weights.pkl'
@@ -46,7 +49,7 @@
4649
else:
4750
# Create Data Module
4851
dm = PADDataModule(
49-
root_path_coco=root_path_coco,
52+
netcdf_path=netcdf_path,
5053
path_train=coco_train,
5154
path_val=coco_val,
5255
group_freq='1MS',

pad_experiments.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ def main():
131131
parser.add_argument('--prefix_coco', type=str, default=None, required=False,
132132
help='The prefix to use for the COCO file. Default none.')
133133

134+
parser.add_argument('--netcdf_path', type=str, default='dataset/netcdf',
135+
help='The path containing the netcdf files. Default "dataset/netcdf".')
136+
134137
parser.add_argument('--prefix', type=str, default=None, required=False,
135138
help='The prefix to use for dumping data files. If none, the current timestamp is used')
136139

@@ -196,6 +199,8 @@ def main():
196199
# Normalize paths for different OSes
197200
root_path_coco = Path(args.root_path_coco)
198201

202+
netcdf_path = Path(args.netcdf_path)
203+
199204
# Check existence of data folder
200205
if not root_path_coco.is_dir():
201206
print(f'{font_colors.RED}Coco path doesn\'t exist!{font_colors.ENDC}')
@@ -387,7 +392,7 @@ def main():
387392
if args.train:
388393
# Create Data Modules
389394
dm = PADDataModule(
390-
root_path_coco=root_path_coco,
395+
netcdf_path=netcdf_path,
391396
path_train=path_train,
392397
path_val=path_val,
393398
group_freq=args.group_freq,
@@ -453,7 +458,7 @@ def main():
453458
else:
454459
# Create Data Module
455460
dm = PADDataModule(
456-
root_path_coco=root_path_coco,
461+
netcdf_path=netcdf_path,
457462
path_test=path_test,
458463
group_freq=args.group_freq,
459464
prefix=prefix,

utils/PAD_datamodule.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ def __init__(
5050
'''
5151
Parameters
5252
----------
53-
root_path_coco: Path or str
54-
The path containing the COCO files.
5553
netcdf_path: Path or str
5654
The path containing the training data (netCDF files).
55+
path_train: Path or str
56+
The COCO file path containing the training data.
5757
path_val: Path or str
58-
The file path containing the validation data.
58+
The COCO file path containing the validation data.
5959
path_test: Path or str
60-
The file path containing the testing data.
60+
The COCO file path containing the testing data.
6161
bands: list of str, default None
6262
A list of the bands to use. If None, then all available bands are
6363
taken into consideration. Note that the bands are given in a two-digit

visualize_predictions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ def get_window(idx, window_len, image_size, coco_file):
6060
parser.add_argument('--prefix_coco', type=str, default=None, required=False,
6161
help='The prefix to use for the COCO file. Default none.')
6262

63+
parser.add_argument('--netcdf_path', type=str, default='dataset/netcdf',
64+
help='The path containing the netcdf files. Default "dataset/netcdf".')
65+
6366
parser.add_argument('--prefix', type=str, default=None, required=False,
6467
help='The prefix to use for dumping data files. If none, the current timestamp is used')
6568

@@ -117,6 +120,7 @@ def get_window(idx, window_len, image_size, coco_file):
117120

118121
# Normalize paths for different OSes
119122
root_path_coco = Path(args.root_path_coco)
123+
netcdf_path = Path(netcdf_path)
120124

121125
# Check existence of data folder
122126
if not root_path_coco.is_dir():
@@ -175,7 +179,7 @@ def get_window(idx, window_len, image_size, coco_file):
175179

176180
# Create Data Module for testing images
177181
dm = PADDataModule(
178-
root_path_coco=root_path_coco,
182+
netcdf_path=netcdf_path,
179183
path_test=path_test,
180184
group_freq=args.group_freq,
181185
prefix=args.prefix,

0 commit comments

Comments
 (0)