Skip to content

Commit db68141

Browse files
committed
Initial commit
0 parents  commit db68141

34 files changed

Lines changed: 8416 additions & 0 deletions

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
__pycache__
2+
.idea
3+
4+
utils/__pycache__
5+
utils/settings/__pycache__
6+
models/__pycache__
7+
8+
.ipynb_checkpoints
9+
10+
/venv/
11+
/dataset/
12+
13+
*.pkl

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
## S4A Models Main Repository
2+
### Institute of Astronomy, Astrophysics, Space Applications and Remote Sensing (IAASARS)
3+
#### National Observatory of Athens (NOA)
4+
5+
Contributors: [Sykas D.](https://github.com/dimsyk), [Zografakis D.](https://github.com/dimzog), [Sdraka M.](https://github.com/paren8esis)
6+
7+
8+
This repository contains the models and training scripts for reproducing the experiments presented in [add publication] .
9+
10+
#### Requirements
11+
12+
This repository was tested on:
13+
* Python 3.8
14+
* CUDA 11.2
15+
* PyTorch 1.8.1
16+
* PyTorch Lightning 1.2.1
17+
18+
Check `requirements.txt` for other essential modules.
19+
20+
#### Changing Defaults
21+
22+
* Configuration file `utils/settings/config.py`.
23+
* Custom Taxonomy Mapping at `utils/settings/mappings/mappings_{cat, fr}.py`.
24+
25+
Every script inherits settings from the aforementioned files.
26+
27+
#### Essential scripts
28+
29+
- `coco_data_split.py`: Uses the nectCDF4 data and the annotations to produce three COCO files for training, validation and testing.
30+
- `export_medians_multi.py`: Uses the netCDF4 data and the COCO files to compute the median image per month.
31+
- `compute_class_weights.py`: Computes the class weights based on the exported medians, to account for class imbalance.
32+
- `object-based-csv.py`: Uses the netCDF4 data to compute the statistics required for OAD.
33+
- `pad_experiments.py`: The main script for training/testing the PAD models.
34+
- `oad_experiments.py`: The main script for training/testing the OAD models.
35+
- `visualize_predictions.py`: Produces a visualization of the ground truth and the prediction of a given model for a given image.
36+
37+
#### Available models
38+
39+
For PAD:
40+
1. [ConvLSTM](https://papers.nips.cc/paper/2015/file/07563a3fe3bbe7e3ba84431ad9d055af-Paper.pdf)
41+
2. [ConvSTAR](https://www.sciencedirect.com/science/article/pii/S0034425721003230)
42+
3. [U-Net](https://link.springer.com/chapter/10.1007/978-3-319-24574-4_28)
43+
4. [TempCNN](https://www.mdpi.com/2072-4292/11/5/523)
44+
45+
For OAD:
46+
1. [TempCNN](https://www.mdpi.com/2072-4292/11/5/523)
47+
2. [LSTM](https://direct.mit.edu/neco/article-abstract/9/8/1735/6109/Long-Short-Term-Memory?redirectedFrom=fulltext)
48+
3. [Transformer](https://proceedings.neurips.cc/paper/2017/hash/3f5ee243547dee91fbd053c1c4a845aa-Abstract.html)
49+
50+
#### Instructions
51+
52+
For PAD:
53+
1. Run `export_medians_multi.py` to precompute the medians needed for training, validation and testing.
54+
2. Run `pad_experiments.py` with the appropriate arguments. Example:
55+
```
56+
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 --window_len 12
57+
```
58+
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**. The **window length is 12**, including all months. Please use the `--help` argument to find information on all available parameters.
59+
3. Optionally, run `visualize_predictions.py` to visualize the image, ground truth and prediction for a specific model and image.
60+
61+
For OAD:
62+
1. Run `object-based-csv.py` to export the statistics needed for OAD.
63+
2. Run `oad_experiments.py` with the appropriate arguments. Example:
64+
```
65+
python oad_experiments.py --train --model transformer --prefix <run_prefix> --file <oad_file_name> --num_epochs 10 --batch_size 32 --num_workers 16 --num_gpus 1 --hidden_size 1024 --num_layers 3
66+
```
67+
The above command is for training the **Transformer** model. Training will continue for **10 epochs** with **batch size 32**, using given **file containing the OAD statistics**. The **hidden size is 1024** and **three layers** are used for the model. Please use the `--help` argument to find information on all available parameters.

check_dataset.ipynb

Lines changed: 252 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)