Skip to content

Commit

Permalink
Add command line script (#1559)
Browse files Browse the repository at this point in the history
* Add command line script

* Label PRs correctly

* Flake8 fix

* Add callbacks

* Update all conf files

* Enforce class of model/data

* Update BYOL tests

* Update all tests

* Use default num workers: 0

* Variable interpolation only supported by omegaconf backend

* Fix regression tests

* Ensure that jsonargparse is installed during testing

* Bump minimimum lightning version

* Workaround for lightning/jsonargparse bugs

* Ignore Python 3.9 warning message

* Add test coverage for __main__.py

* Increase coverage of PixelwiseRegressionTask

* jsonargparse bug fixed in latest release

* Revert "jsonargparse bug fixed in latest release"

This reverts commit 4f38cdf.

* Use default logging frequency

* Ensure that metrics are actually logged

* Fix ObjectDetectionTask logging

* Ignore type errors

* Not all need to be ignored
  • Loading branch information
adamjstewart authored Sep 27, 2023
1 parent 7f00c4d commit 984e222
Show file tree
Hide file tree
Showing 124 changed files with 2,129 additions and 2,290 deletions.
3 changes: 2 additions & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ dependencies:
documentation:
- "docs/**"
scripts:
- "*.py"
- "torchgeo/__main__.py"
- "torchgeo/main.py"
- "experiments/**"
testing:
- "tests/**"
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ jobs:
- name: List pip dependencies
run: pip list
- name: Run pytest checks
run: pytest --cov=torchgeo --cov-report=xml --durations=10
run: |
pytest --cov=torchgeo --cov-report=xml --durations=10
python -m torchgeo --help
torchgeo --help
integration:
name: integration
runs-on: ubuntu-latest
Expand All @@ -52,7 +55,10 @@ jobs:
- name: List pip dependencies
run: pip list
- name: Run integration checks
run: pytest -m slow --durations=10
run: |
pytest -m slow --durations=10
python -m torchgeo --help
torchgeo --help
notebooks:
name: notebooks
runs-on: ubuntu-latest
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ jobs:
- name: List pip dependencies
run: pip list
- name: Run pytest checks
run: pytest --cov=torchgeo --cov-report=xml --durations=10
run: |
pytest --cov=torchgeo --cov-report=xml --durations=10
python3 -m torchgeo --help
- name: Report coverage
uses: codecov/[email protected]
with:
Expand Down Expand Up @@ -109,7 +111,9 @@ jobs:
- name: List pip dependencies
run: pip list
- name: Run pytest checks
run: pytest --cov=torchgeo --cov-report=xml --durations=10
run: |
pytest --cov=torchgeo --cov-report=xml --durations=10
python3 -m torchgeo --help
- name: Report coverage
uses: codecov/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ repos:
hooks:
- id: mypy
args: [--strict, --ignore-missing-imports, --show-error-codes]
additional_dependencies: [torch>=2, torchmetrics>=0.10, lightning>=2.0.9, pytest>=6.1.2, pyvista>=0.34.2, omegaconf>=2.0.1, hydra-core>=1, kornia>=0.6.5, numpy>=1.22]
additional_dependencies: [torch>=2, torchmetrics>=0.10, lightning>=2.0.9, pytest>=6.1.2, pyvista>=0.34.2, kornia>=0.6.5, numpy>=1.22]
exclude: (build|data|dist|logo|logs|output)/
40 changes: 19 additions & 21 deletions conf/bigearthnet.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
module:
_target_: torchgeo.trainers.MultiLabelClassificationTask
loss: "bce"
model: "resnet18"
lr: 1e-3
patience: 6
weights: null
in_channels: 14
num_classes: 19

datamodule:
_target_: torchgeo.datamodules.BigEarthNetDataModule
root: "data/bigearthnet"
bands: "all"
num_classes: ${module.num_classes}
batch_size: 128
num_workers: 4

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: MultiLabelClassificationTask
init_args:
loss: "bce"
model: "resnet18"
lr: 1e-3
patience: 6
weights: null
in_channels: 14
num_classes: 19
data:
class_path: BigEarthNetDataModule
init_args:
batch_size: 128
num_workers: 4
dict_kwargs:
root: "data/bigearthnet"
bands: "all"
num_classes: ${model.init_args.num_classes}
60 changes: 29 additions & 31 deletions conf/chesapeake_cvpr.yaml
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
module:
_target_: torchgeo.trainers.SemanticSegmentationTask
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: null
lr: 1e-3
patience: 6
in_channels: 4
num_classes: 7
num_filters: 256
ignore_index: null

datamodule:
_target_: torchgeo.datamodules.ChesapeakeCVPRDataModule
root: "data/chesapeake/cvpr"
train_splits:
- "de-train"
val_splits:
- "de-val"
test_splits:
- "de-test"
batch_size: 200
patch_size: 256
num_workers: 4
class_set: ${module.num_classes}
use_prior_labels: False

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: SemanticSegmentationTask
init_args:
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: null
lr: 1e-3
patience: 6
in_channels: 4
num_classes: 7
num_filters: 256
ignore_index: null
data:
class_path: ChesapeakeCVPRDataModule
init_args:
train_splits:
- "de-train"
val_splits:
- "de-val"
test_splits:
- "de-test"
batch_size: 200
patch_size: 256
num_workers: 4
class_set: ${model.init_args.num_classes}
use_prior_labels: False
dict_kwargs:
root: "data/chesapeake/cvpr"
34 changes: 16 additions & 18 deletions conf/cowc_counting.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
module:
_target_: torchgeo.trainers.RegressionTask
model: resnet18
weights: null
num_outputs: 1
in_channels: 3
lr: 1e-3
patience: 2

datamodule:
_target_: torchgeo.datamodules.COWCCountingDataModule
root: "data/cowc_counting"
batch_size: 64
num_workers: 4

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: RegressionTask
init_args:
model: resnet18
weights: null
num_outputs: 1
in_channels: 3
lr: 1e-3
patience: 2
data:
class_path: COWCCountingDataModule
init_args:
batch_size: 64
num_workers: 4
dict_kwargs:
root: "data/cowc_counting"
34 changes: 16 additions & 18 deletions conf/cyclone.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
module:
_target_: torchgeo.trainers.RegressionTask
model: "resnet18"
weights: null
num_outputs: 1
in_channels: 3
lr: 1e-3
patience: 2

datamodule:
_target_: torchgeo.datamodules.TropicalCycloneDataModule
root: "data/cyclone"
batch_size: 32
num_workers: 4

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: RegressionTask
init_args:
model: "resnet18"
weights: null
num_outputs: 1
in_channels: 3
lr: 1e-3
patience: 2
data:
class_path: TropicalCycloneDataModule
init_args:
batch_size: 32
num_workers: 4
dict_kwargs:
root: "data/cyclone"
46 changes: 22 additions & 24 deletions conf/deepglobelandcover.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
module:
_target_: torchgeo.trainers.SemanticSegmentationTask
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: null
lr: 1e-3
patience: 6
in_channels: 3
num_classes: 7
num_filters: 1
ignore_index: null

datamodule:
_target_: torchgeo.datamodules.DeepGlobeLandCoverDataModule
root: "data/deepglobelandcover"
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: SemanticSegmentationTask
init_args:
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: null
lr: 1e-3
patience: 6
in_channels: 3
num_classes: 7
num_filters: 1
ignore_index: null
data:
class_path: DeepGlobeLandCoverDataModule
init_args:
batch_size: 1
patch_size: 64
val_split_pct: 0.5
num_workers: 0
dict_kwargs:
root: "data/deepglobelandcover"
8 changes: 0 additions & 8 deletions conf/defaults.yaml

This file was deleted.

40 changes: 19 additions & 21 deletions conf/etci2021.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
module:
_target_: torchgeo.trainers.SemanticSegmentationTask
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: true
lr: 1e-3
patience: 6
in_channels: 6
num_classes: 2
ignore_index: 0

datamodule:
_target_: torchgeo.datamodules.ETCI2021DataModule
root: "data/etci2021"
batch_size: 32
num_workers: 4

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: SemanticSegmentationTask
init_args:
loss: "ce"
model: "unet"
backbone: "resnet18"
weights: true
lr: 1e-3
patience: 6
in_channels: 6
num_classes: 2
ignore_index: 0
data:
class_path: ETCI2021DataModule
init_args:
batch_size: 32
num_workers: 4
dict_kwargs:
root: "data/etci2021"
36 changes: 17 additions & 19 deletions conf/eurosat.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
module:
_target_: torchgeo.trainers.ClassificationTask
loss: "ce"
model: "resnet18"
lr: 1e-3
patience: 6
weights: null
in_channels: 13
num_classes: 10

datamodule:
_target_: torchgeo.datamodules.EuroSATDataModule
root: "data/eurosat"
batch_size: 128
num_workers: 4

trainer:
_target_: lightning.pytorch.Trainer
accelerator: gpu
devices: 1
min_epochs: 15
max_epochs: 40
model:
class_path: ClassificationTask
init_args:
loss: "ce"
model: "resnet18"
lr: 1e-3
patience: 6
weights: null
in_channels: 13
num_classes: 10
data:
class_path: EuroSATDataModule
init_args:
batch_size: 128
num_workers: 4
dict_kwargs:
root: "data/eurosat"
Loading

0 comments on commit 984e222

Please sign in to comment.