Skip to content

Commit

Permalink
DataModules: run all data augmentation on the GPU (#992)
Browse files Browse the repository at this point in the history
* DataModules: run all data augmentation on the GPU

* Passing tests

* Update BigEarthNet

* Break ChesapeakeCVPR

* Update COWC

* Update Cyclone

* Update ETCI2021

* mypy fixes

* Update FAIR1M

* Update Inria

* Update LandCoverAI

* Update LoveDA

* Update NAIP

* Update NASA

* Update OSCD

* Update RESISC45

* Update SEN12MS

* Update So2Sat

* Update SpaceNet

* Update UCMerced

* Update USAVars

* Update xview

* Remove seed

* mypy fixes

* OSCD hacks

* Add NonGeoDataModule base class

* Fixes

* Add base class to docs

* mypy fixes

* Fix several tests

* Fix Normalize

* Syntax error

* Fix bigearthnet

* Fix dtype

* Consistent kornia import

* Get regression datasets working

* Fix detection tests

* Fix some chesapeake bugs

* Fix several segmentation issues

* isort fixes

* Undo breaking change

* Remove more code duplication, standardize docstrings

* mypy fixes

* Add default augmentation

* Augmentations can be any callable

* Fix datasets tests

* Fix datamodule tests

* Fix more datamodules

* Typo fix

* Set up val_dataset even when fit

* Fix classification tests

* Fix ETCI2021

* Fix SEN12MS

* Add GeoDataModule base class

* Fix several chesapeake bugs

* Fix dtype and shape

* Fix crs/bbox issue

* Fix test dtype

* Fix unequal size stacking error

* flake8 fix

* Better checks on sampler

* Fix bug introduced in NAIP dm

* Fix chesapeake dimensions

* Add one to mask

* Fix missing imports

* Fix batch size

* Simplify augmentations

* Don't run test or predict without datasets

* Fix tests

* Allow shared dataset

* One more try

* Fix typo

* Fix another typo

* Fix Chesapeake dimensions

* Apply augmentations during sanity check too

* Don't reuse fixtures

* Increase coverage

* Fix ETCI tests

* Test predict_step

* Test all loss methods

* Simplify validation plotting

* Document new classes

* Fix plotting

* Plotting should be robust in case dataset does not contain RGB bands

* Fix flake8

* 100% coverage of trainers

* Add lightning-lite dependency

* Revert "Add lightning-lite dependency"

This reverts commit 1df7291.

* Define our own MisconfigurationException

* Properly test new data module base classes

* Fix mistake in setup call

* ExtractTensorPatches runs into OOM errors

* Test both fast_dev_run True and False

* Fix plot methods

* Fix OSCD tests

* Fix bug with inconsistent train/val/test splits between stages

* Fix issues with images of different sizes

* Fix OSCD tests

* Fix OSCD tests

* Bad rebase

* No trainer for OSCD so no need for config

* Bad rebase

* plot: only works during validation

* Fix collation of NASA Marine Debris dataset

* flake8 fix

* Quick test

* Revert "Quick test"

This reverts commit f465efc.

* 56 workers is a bit excessive

Co-authored-by: Caleb Robinson <calebrob6@gmail.com>
  • Loading branch information
adamjstewart and calebrob6 authored Jan 23, 2023
1 parent a34c11b commit 55f74da
Show file tree
Hide file tree
Showing 98 changed files with 2,002 additions and 3,565 deletions.
3 changes: 1 addition & 2 deletions conf/chesapeake_cvpr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ experiment:
- "de-val"
test_splits:
- "de-test"
patches_per_tile: 200
batch_size: 200
patch_size: 256
batch_size: 64
num_workers: 4
class_set: ${experiment.module.num_classes}
use_prior_labels: False
1 change: 0 additions & 1 deletion conf/cowc_counting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ experiment:
learning_rate_schedule_patience: 2
datamodule:
root: "data/cowc_counting"
seed: 0
batch_size: 64
num_workers: 4
1 change: 0 additions & 1 deletion conf/cyclone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ experiment:
learning_rate_schedule_patience: 2
datamodule:
root: "data/cyclone"
seed: 0
batch_size: 32
num_workers: 4
3 changes: 1 addition & 2 deletions conf/deepglobelandcover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "data/deepglobelandcover"
num_tiles_per_batch: 16
num_patches_per_tile: 16
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0
3 changes: 1 addition & 2 deletions conf/gid15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "data/gid15"
num_tiles_per_batch: 16
num_patches_per_tile: 16
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0
11 changes: 5 additions & 6 deletions conf/inria.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
program:
overwrite: True


trainer:
gpus: 1
min_epochs: 5
Expand All @@ -23,8 +23,7 @@ experiment:
num_classes: 2
ignore_index: null
datamodule:
root: "data/inria"
batch_size: 2
num_workers: 32
patch_size: 512
num_patches_per_tile: 4
root: "data/inria"
batch_size: 1
patch_size: 512
num_workers: 32
3 changes: 1 addition & 2 deletions conf/nasa_marine_debris.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
program:
seed: 0
overwrite: True

trainer:
Expand All @@ -22,5 +21,5 @@ experiment:
datamodule:
root: "data/nasamr/nasa_marine_debris"
batch_size: 4
num_workers: 56
num_workers: 6
val_split_pct: 0.2
29 changes: 0 additions & 29 deletions conf/oscd.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions conf/potsdam2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "data/potsdam"
num_tiles_per_batch: 16
num_patches_per_tile: 16
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0
1 change: 0 additions & 1 deletion conf/sen12ms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ experiment:
band_set: "all"
batch_size: 32
num_workers: 4
seed: 0
5 changes: 2 additions & 3 deletions conf/so2sat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ experiment:
learning_rate: 1e-3
learning_rate_schedule_patience: 6
weights: null
in_channels: 3
in_channels: 18
num_classes: 17
datamodule:
root: "data/so2sat"
batch_size: 128
num_workers: 4
band_set: "rgb"
unsupervised_mode: False
band_set: "all"
3 changes: 1 addition & 2 deletions conf/spacenet1.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
program:
overwrite: False
seed: 0
trainer:
gpus: [3]
min_epochs: 50
Expand All @@ -22,4 +21,4 @@ experiment:
datamodule:
root: "data/spacenet"
batch_size: 32
num_workers: 4
num_workers: 4
3 changes: 1 addition & 2 deletions conf/vaihingen2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "data/vaihingen"
num_tiles_per_batch: 16
num_patches_per_tile: 16
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0
18 changes: 18 additions & 0 deletions docs/api/datamodules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,21 @@ xView2
^^^^^^

.. autoclass:: XView2DataModule

Base Classes
------------

GeoDataModule
^^^^^^^^^^^^^

.. autoclass:: GeoDataModule

NonGeoDataModule
^^^^^^^^^^^^^^^^

.. autoclass:: NonGeoDataModule

Utilities
---------

.. autoclass:: MisconfigurationException
3 changes: 1 addition & 2 deletions tests/conf/chesapeake_cvpr_5.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ experiment:
- "de-test"
test_splits:
- "de-test"
patches_per_tile: 2
patch_size: 64
batch_size: 2
patch_size: 64
num_workers: 0
class_set: ${experiment.module.num_classes}
use_prior_labels: False
3 changes: 1 addition & 2 deletions tests/conf/chesapeake_cvpr_7.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ experiment:
- "de-test"
test_splits:
- "de-test"
patches_per_tile: 2
patch_size: 64
batch_size: 2
patch_size: 64
num_workers: 0
class_set: ${experiment.module.num_classes}
use_prior_labels: False
3 changes: 1 addition & 2 deletions tests/conf/chesapeake_cvpr_prior.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ experiment:
- "de-test"
test_splits:
- "de-test"
patches_per_tile: 2
patch_size: 64
batch_size: 2
patch_size: 64
num_workers: 0
class_set: ${experiment.module.num_classes}
use_prior_labels: True
1 change: 0 additions & 1 deletion tests/conf/cowc_counting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ experiment:
datamodule:
root: "tests/data/cowc_counting"
download: true
seed: 0
batch_size: 1
num_workers: 0
1 change: 0 additions & 1 deletion tests/conf/cyclone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ experiment:
datamodule:
root: "tests/data/cyclone"
download: true
seed: 0
batch_size: 1
num_workers: 0
3 changes: 1 addition & 2 deletions tests/conf/deepglobelandcover.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "tests/data/deepglobelandcover"
num_tiles_per_batch: 1
num_patches_per_tile: 1
batch_size: 1
patch_size: 2
val_split_pct: 0.5
num_workers: 0
3 changes: 1 addition & 2 deletions tests/conf/gid15.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ experiment:
datamodule:
root: "tests/data/gid15"
download: true
num_tiles_per_batch: 1
num_patches_per_tile: 1
batch_size: 1
patch_size: 2
val_split_pct: 0.5
num_workers: 0
13 changes: 6 additions & 7 deletions tests/conf/inria_test.yaml → tests/conf/inria.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ experiment:
num_classes: 2
ignore_index: null
datamodule:
root: "tests/data/inria"
batch_size: 1
num_workers: 0
val_split_pct: 0.2
test_split_pct: 0.2
patch_size: 2
num_patches_per_tile: 2
root: "tests/data/inria"
batch_size: 1
patch_size: 2
num_workers: 0
val_split_pct: 0.2
test_split_pct: 0.2
20 changes: 0 additions & 20 deletions tests/conf/inria_train.yaml

This file was deleted.

20 changes: 0 additions & 20 deletions tests/conf/inria_val.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions tests/conf/potsdam2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "tests/data/potsdam"
num_tiles_per_batch: 1
num_patches_per_tile: 1
batch_size: 1
patch_size: 2
val_split_pct: 0.5
num_workers: 0
1 change: 0 additions & 1 deletion tests/conf/sen12ms_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ experiment:
band_set: "all"
batch_size: 1
num_workers: 0
seed: 0
1 change: 0 additions & 1 deletion tests/conf/sen12ms_s1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ experiment:
band_set: "s1"
batch_size: 1
num_workers: 0
seed: 0
1 change: 0 additions & 1 deletion tests/conf/sen12ms_s2_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ experiment:
band_set: "s2-all"
batch_size: 1
num_workers: 0
seed: 0
1 change: 0 additions & 1 deletion tests/conf/sen12ms_s2_reduced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ experiment:
band_set: "s2-reduced"
batch_size: 1
num_workers: 0
seed: 0
15 changes: 15 additions & 0 deletions tests/conf/so2sat_all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
experiment:
task: "so2sat"
module:
loss: "ce"
model: "resnet18"
learning_rate: 1e-3
learning_rate_schedule_patience: 6
weights: null
in_channels: 18
num_classes: 17
datamodule:
root: "tests/data/so2sat"
batch_size: 1
num_workers: 0
band_set: "all"
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ experiment:
learning_rate: 1e-3
learning_rate_schedule_patience: 6
weights: null
in_channels: 3
in_channels: 8
num_classes: 17
datamodule:
root: "tests/data/so2sat"
batch_size: 1
num_workers: 0
band_set: "rgb"
unsupervised_mode: False
band_set: "s1"
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ experiment:
learning_rate: 1e-3
learning_rate_schedule_patience: 6
weights: null
in_channels: 3
in_channels: 10
num_classes: 17
datamodule:
root: "tests/data/so2sat"
batch_size: 1
num_workers: 0
band_set: "rgb"
unsupervised_mode: True
band_set: "s2"
3 changes: 1 addition & 2 deletions tests/conf/vaihingen2d.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ experiment:
ignore_index: null
datamodule:
root: "tests/data/vaihingen"
num_tiles_per_batch: 1
num_patches_per_tile: 1
batch_size: 1
patch_size: 2
val_split_pct: 0.5
num_workers: 0
Loading

0 comments on commit 55f74da

Please sign in to comment.