From 916b3d8b92b0a2525f17266fad22704835d940f1 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 11:43:54 +0200 Subject: [PATCH 1/6] refactor directory structure to fit python best practice Signed-off-by: Carlos Gomes --- .github/workflows/test.yaml | 18 ++++++++--- src/terratorch/models/backbones/__init__.py | 3 -- {src/terratorch => terratorch}/__about__.py | 0 {src/terratorch => terratorch}/__init__.py | 2 ++ {src/terratorch => terratorch}/__main__.py | 2 ++ {src/terratorch => terratorch}/cli_tools.py | 2 ++ .../datamodules/__init__.py | 26 ++++++++------- .../datamodules/fire_scars.py | 2 ++ .../generic_pixel_wise_data_module.py | 2 ++ .../generic_scalar_label_data_module.py | 2 ++ .../datamodules/m_SA_crop_type.py | 0 .../datamodules/m_bigearthnet.py | 0 .../datamodules/m_brick_kiln.py | 0 .../datamodules/m_cashew_plantation.py | 0 .../datamodules/m_chesapeake_landcover.py | 0 .../datamodules/m_eurosat.py | 0 .../datamodules/m_forestnet.py | 0 .../datamodules/m_neontree.py | 0 .../datamodules/m_nz_cattle.py | 0 .../datamodules/m_pv4ger.py | 0 .../datamodules/m_pv4ger_seg.py | 0 .../datamodules/m_so2sat.py | 0 .../datamodules/sen1floods11.py | 2 ++ .../datamodules/torchgeo_data_module.py | 2 ++ .../datamodules/utils.py | 5 ++- .../datasets/__init__.py | 32 ++++++++++--------- .../datasets/fire_scars.py | 2 ++ .../datasets/generic_pixel_wise_dataset.py | 2 ++ .../datasets/generic_scalar_label_dataset.py | 2 ++ .../terratorch => terratorch}/datasets/hls.py | 7 ++-- .../datasets/m_SA_crop_type.py | 0 .../datasets/m_bigearthnet.py | 0 .../datasets/m_brick_kiln.py | 0 .../datasets/m_cashew_plantation.py | 0 .../datasets/m_chesapeake_landcover.py | 0 .../datasets/m_eurosat.py | 0 .../datasets/m_forestnet.py | 0 .../datasets/m_neontree.py | 0 .../datasets/m_nz_cattle.py | 0 .../datasets/m_pv4ger.py | 0 .../datasets/m_pv4ger_seg.py | 0 .../datasets/m_so2sat.py | 0 .../datasets/sen1floods11.py | 2 ++ .../datasets/transforms.py | 2 ++ .../datasets/utils.py | 2 ++ .../terratorch => terratorch}/datasets/wsf.py | 10 +++--- {src/terratorch => terratorch}/io/file.py | 0 .../models/__init__.py | 2 ++ terratorch/models/backbones/__init__.py | 5 +++ .../prithvi_select_patch_embed_weights.py | 2 ++ .../models/backbones/prithvi_swin.py | 2 ++ .../models/backbones/prithvi_vit.py | 4 +-- .../models/backbones/swin_encoder_decoder.py | 2 ++ .../models/backbones/vit_encoder_decoder.py | 3 ++ .../models/clay_model_factory.py | 0 .../models/decoders/__init__.py | 4 ++- .../models/decoders/fcn_decoder.py | 2 ++ .../models/decoders/identity_decoder.py | 2 ++ .../models/decoders/satmae_head.py | 8 +++-- .../models/decoders/upernet_decoder.py | 2 ++ .../models/heads/__init__.py | 2 ++ .../models/heads/classification_head.py | 2 ++ .../models/heads/regression_head.py | 2 ++ .../models/heads/segmentation_head.py | 2 ++ .../terratorch => terratorch}/models/model.py | 2 ++ .../models/pixel_wise_model.py | 2 ++ .../models/prithvi_model_factory.py | 2 ++ .../models/satmae_model_factory.py | 4 ++- .../models/scalar_output_model.py | 2 ++ .../models/scalemae_model_factory.py | 4 ++- .../models/smp_model_factory.py | 2 ++ .../models/timm_model_factory.py | 2 ++ .../samplers/__init__.py | 2 ++ .../samplers/single.py | 6 +++- .../tasks/__init__.py | 0 .../tasks/classification_tasks.py | 0 .../tasks/loss_handler.py | 0 .../tasks/multilabel_classification_tasks.py | 0 .../tasks/optimizer_factory.py | 0 .../tasks/regression_tasks.py | 0 .../tasks/segmentation_tasks.py | 0 .../tasks/tiled_inference.py | 0 tests/__init__.py | 2 ++ tests/test_backbones.py | 2 ++ tests/test_generic_dataset.py | 2 ++ tests/test_prithvi_model_factory.py | 2 ++ tests/test_prithvi_tasks.py | 2 ++ 87 files changed, 161 insertions(+), 52 deletions(-) delete mode 100644 src/terratorch/models/backbones/__init__.py rename {src/terratorch => terratorch}/__about__.py (100%) rename {src/terratorch => terratorch}/__init__.py (67%) rename {src/terratorch => terratorch}/__main__.py (77%) rename {src/terratorch => terratorch}/cli_tools.py (99%) rename {src/terratorch => terratorch}/datamodules/__init__.py (97%) rename {src/terratorch => terratorch}/datamodules/fire_scars.py (98%) rename {src/terratorch => terratorch}/datamodules/generic_pixel_wise_data_module.py (99%) rename {src/terratorch => terratorch}/datamodules/generic_scalar_label_data_module.py (99%) rename {src/terratorch => terratorch}/datamodules/m_SA_crop_type.py (100%) rename {src/terratorch => terratorch}/datamodules/m_bigearthnet.py (100%) rename {src/terratorch => terratorch}/datamodules/m_brick_kiln.py (100%) rename {src/terratorch => terratorch}/datamodules/m_cashew_plantation.py (100%) rename {src/terratorch => terratorch}/datamodules/m_chesapeake_landcover.py (100%) rename {src/terratorch => terratorch}/datamodules/m_eurosat.py (100%) rename {src/terratorch => terratorch}/datamodules/m_forestnet.py (100%) rename {src/terratorch => terratorch}/datamodules/m_neontree.py (100%) rename {src/terratorch => terratorch}/datamodules/m_nz_cattle.py (100%) rename {src/terratorch => terratorch}/datamodules/m_pv4ger.py (100%) rename {src/terratorch => terratorch}/datamodules/m_pv4ger_seg.py (100%) rename {src/terratorch => terratorch}/datamodules/m_so2sat.py (100%) rename {src/terratorch => terratorch}/datamodules/sen1floods11.py (94%) rename {src/terratorch => terratorch}/datamodules/torchgeo_data_module.py (99%) rename {src/terratorch => terratorch}/datamodules/utils.py (84%) rename {src/terratorch => terratorch}/datasets/__init__.py (97%) rename {src/terratorch => terratorch}/datasets/fire_scars.py (98%) rename {src/terratorch => terratorch}/datasets/generic_pixel_wise_dataset.py (99%) rename {src/terratorch => terratorch}/datasets/generic_scalar_label_dataset.py (99%) rename {src/terratorch => terratorch}/datasets/hls.py (97%) rename {src/terratorch => terratorch}/datasets/m_SA_crop_type.py (100%) rename {src/terratorch => terratorch}/datasets/m_bigearthnet.py (100%) rename {src/terratorch => terratorch}/datasets/m_brick_kiln.py (100%) rename {src/terratorch => terratorch}/datasets/m_cashew_plantation.py (100%) rename {src/terratorch => terratorch}/datasets/m_chesapeake_landcover.py (100%) rename {src/terratorch => terratorch}/datasets/m_eurosat.py (100%) rename {src/terratorch => terratorch}/datasets/m_forestnet.py (100%) rename {src/terratorch => terratorch}/datasets/m_neontree.py (100%) rename {src/terratorch => terratorch}/datasets/m_nz_cattle.py (100%) rename {src/terratorch => terratorch}/datasets/m_pv4ger.py (100%) rename {src/terratorch => terratorch}/datasets/m_pv4ger_seg.py (100%) rename {src/terratorch => terratorch}/datasets/m_so2sat.py (100%) rename {src/terratorch => terratorch}/datasets/sen1floods11.py (99%) rename {src/terratorch => terratorch}/datasets/transforms.py (98%) rename {src/terratorch => terratorch}/datasets/utils.py (97%) rename {src/terratorch => terratorch}/datasets/wsf.py (97%) rename {src/terratorch => terratorch}/io/file.py (100%) rename {src/terratorch => terratorch}/models/__init__.py (91%) create mode 100644 terratorch/models/backbones/__init__.py rename {src/terratorch => terratorch}/models/backbones/prithvi_select_patch_embed_weights.py (97%) rename {src/terratorch => terratorch}/models/backbones/prithvi_swin.py (99%) rename {src/terratorch => terratorch}/models/backbones/prithvi_vit.py (98%) rename {src/terratorch => terratorch}/models/backbones/swin_encoder_decoder.py (99%) rename {src/terratorch => terratorch}/models/backbones/vit_encoder_decoder.py (99%) rename {src/terratorch => terratorch}/models/clay_model_factory.py (100%) rename {src/terratorch => terratorch}/models/decoders/__init__.py (87%) rename {src/terratorch => terratorch}/models/decoders/fcn_decoder.py (97%) rename {src/terratorch => terratorch}/models/decoders/identity_decoder.py (92%) rename {src/terratorch => terratorch}/models/decoders/satmae_head.py (97%) rename {src/terratorch => terratorch}/models/decoders/upernet_decoder.py (99%) rename {src/terratorch => terratorch}/models/heads/__init__.py (84%) rename {src/terratorch => terratorch}/models/heads/classification_head.py (97%) rename {src/terratorch => terratorch}/models/heads/regression_head.py (98%) rename {src/terratorch => terratorch}/models/heads/segmentation_head.py (96%) rename {src/terratorch => terratorch}/models/model.py (97%) rename {src/terratorch => terratorch}/models/pixel_wise_model.py (99%) rename {src/terratorch => terratorch}/models/prithvi_model_factory.py (99%) rename {src/terratorch => terratorch}/models/satmae_model_factory.py (99%) rename {src/terratorch => terratorch}/models/scalar_output_model.py (98%) rename {src/terratorch => terratorch}/models/scalemae_model_factory.py (99%) rename {src/terratorch => terratorch}/models/smp_model_factory.py (98%) rename {src/terratorch => terratorch}/models/timm_model_factory.py (98%) rename {src/terratorch => terratorch}/samplers/__init__.py (59%) rename {src/terratorch => terratorch}/samplers/single.py (95%) rename {src/terratorch => terratorch}/tasks/__init__.py (100%) rename {src/terratorch => terratorch}/tasks/classification_tasks.py (100%) rename {src/terratorch => terratorch}/tasks/loss_handler.py (100%) rename {src/terratorch => terratorch}/tasks/multilabel_classification_tasks.py (100%) rename {src/terratorch => terratorch}/tasks/optimizer_factory.py (100%) rename {src/terratorch => terratorch}/tasks/regression_tasks.py (100%) rename {src/terratorch => terratorch}/tasks/segmentation_tasks.py (100%) rename {src/terratorch => terratorch}/tasks/tiled_inference.py (100%) create mode 100644 tests/__init__.py diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index aea5bf99..479c1e90 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,17 +1,24 @@ name: terratorch tuning toolkit -on: [pull_request] +on: + push: + branches: + - main + + pull_request: + branches: + - main jobs: build: - runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11"] + python-version: ["3.10", "3.11", "3.12"] steps: - - uses: actions/checkout@v3 + - name: Clone repo + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: @@ -21,7 +28,10 @@ jobs: run: | python -m pip install --upgrade pip pip install pytest + pip install -r requirements.txt pip install -e . + - name: List pip dependencies + run: pip list - name: Test with pytest run: | pytest tests diff --git a/src/terratorch/models/backbones/__init__.py b/src/terratorch/models/backbones/__init__.py deleted file mode 100644 index 50c59bd5..00000000 --- a/src/terratorch/models/backbones/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# import so they get registered -import terratorch.models.backbones.prithvi_vit -import terratorch.models.backbones.prithvi_swin \ No newline at end of file diff --git a/src/terratorch/__about__.py b/terratorch/__about__.py similarity index 100% rename from src/terratorch/__about__.py rename to terratorch/__about__.py diff --git a/src/terratorch/__init__.py b/terratorch/__init__.py similarity index 67% rename from src/terratorch/__init__.py rename to terratorch/__init__.py index c7eac96e..961dbc9b 100644 --- a/src/terratorch/__init__.py +++ b/terratorch/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + # register models with timm import terratorch.models from terratorch.models.backbones import * # noqa: F403 diff --git a/src/terratorch/__main__.py b/terratorch/__main__.py similarity index 77% rename from src/terratorch/__main__.py rename to terratorch/__main__.py index 8a788a2d..30491170 100644 --- a/src/terratorch/__main__.py +++ b/terratorch/__main__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Command-line interface to TerraTorch.""" from terratorch.cli_tools import build_lightning_cli diff --git a/src/terratorch/cli_tools.py b/terratorch/cli_tools.py similarity index 99% rename from src/terratorch/cli_tools.py rename to terratorch/cli_tools.py index 63044357..e0d523e1 100644 --- a/src/terratorch/cli_tools.py +++ b/terratorch/cli_tools.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import logging # noqa: I001 import os import warnings diff --git a/src/terratorch/datamodules/__init__.py b/terratorch/datamodules/__init__.py similarity index 97% rename from src/terratorch/datamodules/__init__.py rename to terratorch/datamodules/__init__.py index cbec287d..3e35c579 100644 --- a/src/terratorch/datamodules/__init__.py +++ b/terratorch/datamodules/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from terratorch.datamodules.fire_scars import FireScarsNonGeoDataModule from terratorch.datamodules.generic_pixel_wise_data_module import ( GenericNonGeoPixelwiseRegressionDataModule, @@ -6,26 +8,26 @@ from terratorch.datamodules.generic_scalar_label_data_module import ( GenericNonGeoClassificationDataModule, ) - -# GenericNonGeoRegressionDataModule, -from terratorch.datamodules.sen1floods11 import Sen1Floods11NonGeoDataModule -from terratorch.datamodules.torchgeo_data_module import TorchGeoDataModule, TorchNonGeoDataModule - -# geobench classification datamodules -from terratorch.datamodules.m_eurosat import MEuroSATNonGeoDataModule from terratorch.datamodules.m_bigearthnet import MBigEarthNonGeoDataModule from terratorch.datamodules.m_brick_kiln import MBrickKilnNonGeoDataModule -from terratorch.datamodules.m_forestnet import MForestNetNonGeoDataModule -from terratorch.datamodules.m_so2sat import MSo2SatNonGeoDataModule -from terratorch.datamodules.m_pv4ger import MPv4gerNonGeoDataModule # geobench segmentation datamodules from terratorch.datamodules.m_cashew_plantation import MBeninSmallHolderCashewsNonGeoDataModule -from terratorch.datamodules.m_nz_cattle import MNzCattleNonGeoDataModule from terratorch.datamodules.m_chesapeake_landcover import MChesapeakeLandcoverNonGeoDataModule + +# geobench classification datamodules +from terratorch.datamodules.m_eurosat import MEuroSATNonGeoDataModule +from terratorch.datamodules.m_forestnet import MForestNetNonGeoDataModule +from terratorch.datamodules.m_neontree import MNeonTreeNonGeoDataModule +from terratorch.datamodules.m_nz_cattle import MNzCattleNonGeoDataModule +from terratorch.datamodules.m_pv4ger import MPv4gerNonGeoDataModule from terratorch.datamodules.m_pv4ger_seg import MPv4gerSegNonGeoDataModule from terratorch.datamodules.m_SA_crop_type import MSACropTypeNonGeoDataModule -from terratorch.datamodules.m_neontree import MNeonTreeNonGeoDataModule +from terratorch.datamodules.m_so2sat import MSo2SatNonGeoDataModule + +# GenericNonGeoRegressionDataModule, +from terratorch.datamodules.sen1floods11 import Sen1Floods11NonGeoDataModule +from terratorch.datamodules.torchgeo_data_module import TorchGeoDataModule, TorchNonGeoDataModule __all__ = ( "GenericNonGeoSegmentationDataModule", diff --git a/src/terratorch/datamodules/fire_scars.py b/terratorch/datamodules/fire_scars.py similarity index 98% rename from src/terratorch/datamodules/fire_scars.py rename to terratorch/datamodules/fire_scars.py index bc6e1614..fed5c945 100644 --- a/src/terratorch/datamodules/fire_scars.py +++ b/terratorch/datamodules/fire_scars.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from typing import Any import kornia.augmentation as K # noqa: N812 diff --git a/src/terratorch/datamodules/generic_pixel_wise_data_module.py b/terratorch/datamodules/generic_pixel_wise_data_module.py similarity index 99% rename from src/terratorch/datamodules/generic_pixel_wise_data_module.py rename to terratorch/datamodules/generic_pixel_wise_data_module.py index eff10407..16c4a31c 100644 --- a/src/terratorch/datamodules/generic_pixel_wise_data_module.py +++ b/terratorch/datamodules/generic_pixel_wise_data_module.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """ This module contains generic data modules for instantiation at runtime. """ diff --git a/src/terratorch/datamodules/generic_scalar_label_data_module.py b/terratorch/datamodules/generic_scalar_label_data_module.py similarity index 99% rename from src/terratorch/datamodules/generic_scalar_label_data_module.py rename to terratorch/datamodules/generic_scalar_label_data_module.py index 230db10a..5cd7470a 100644 --- a/src/terratorch/datamodules/generic_scalar_label_data_module.py +++ b/terratorch/datamodules/generic_scalar_label_data_module.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """ This module contains generic data modules for instantiation at runtime. """ diff --git a/src/terratorch/datamodules/m_SA_crop_type.py b/terratorch/datamodules/m_SA_crop_type.py similarity index 100% rename from src/terratorch/datamodules/m_SA_crop_type.py rename to terratorch/datamodules/m_SA_crop_type.py diff --git a/src/terratorch/datamodules/m_bigearthnet.py b/terratorch/datamodules/m_bigearthnet.py similarity index 100% rename from src/terratorch/datamodules/m_bigearthnet.py rename to terratorch/datamodules/m_bigearthnet.py diff --git a/src/terratorch/datamodules/m_brick_kiln.py b/terratorch/datamodules/m_brick_kiln.py similarity index 100% rename from src/terratorch/datamodules/m_brick_kiln.py rename to terratorch/datamodules/m_brick_kiln.py diff --git a/src/terratorch/datamodules/m_cashew_plantation.py b/terratorch/datamodules/m_cashew_plantation.py similarity index 100% rename from src/terratorch/datamodules/m_cashew_plantation.py rename to terratorch/datamodules/m_cashew_plantation.py diff --git a/src/terratorch/datamodules/m_chesapeake_landcover.py b/terratorch/datamodules/m_chesapeake_landcover.py similarity index 100% rename from src/terratorch/datamodules/m_chesapeake_landcover.py rename to terratorch/datamodules/m_chesapeake_landcover.py diff --git a/src/terratorch/datamodules/m_eurosat.py b/terratorch/datamodules/m_eurosat.py similarity index 100% rename from src/terratorch/datamodules/m_eurosat.py rename to terratorch/datamodules/m_eurosat.py diff --git a/src/terratorch/datamodules/m_forestnet.py b/terratorch/datamodules/m_forestnet.py similarity index 100% rename from src/terratorch/datamodules/m_forestnet.py rename to terratorch/datamodules/m_forestnet.py diff --git a/src/terratorch/datamodules/m_neontree.py b/terratorch/datamodules/m_neontree.py similarity index 100% rename from src/terratorch/datamodules/m_neontree.py rename to terratorch/datamodules/m_neontree.py diff --git a/src/terratorch/datamodules/m_nz_cattle.py b/terratorch/datamodules/m_nz_cattle.py similarity index 100% rename from src/terratorch/datamodules/m_nz_cattle.py rename to terratorch/datamodules/m_nz_cattle.py diff --git a/src/terratorch/datamodules/m_pv4ger.py b/terratorch/datamodules/m_pv4ger.py similarity index 100% rename from src/terratorch/datamodules/m_pv4ger.py rename to terratorch/datamodules/m_pv4ger.py diff --git a/src/terratorch/datamodules/m_pv4ger_seg.py b/terratorch/datamodules/m_pv4ger_seg.py similarity index 100% rename from src/terratorch/datamodules/m_pv4ger_seg.py rename to terratorch/datamodules/m_pv4ger_seg.py diff --git a/src/terratorch/datamodules/m_so2sat.py b/terratorch/datamodules/m_so2sat.py similarity index 100% rename from src/terratorch/datamodules/m_so2sat.py rename to terratorch/datamodules/m_so2sat.py diff --git a/src/terratorch/datamodules/sen1floods11.py b/terratorch/datamodules/sen1floods11.py similarity index 94% rename from src/terratorch/datamodules/sen1floods11.py rename to terratorch/datamodules/sen1floods11.py index d844d369..07996fc3 100644 --- a/src/terratorch/datamodules/sen1floods11.py +++ b/terratorch/datamodules/sen1floods11.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from pathlib import Path from typing import Any diff --git a/src/terratorch/datamodules/torchgeo_data_module.py b/terratorch/datamodules/torchgeo_data_module.py similarity index 99% rename from src/terratorch/datamodules/torchgeo_data_module.py rename to terratorch/datamodules/torchgeo_data_module.py index 08195bc3..07e5a427 100644 --- a/src/terratorch/datamodules/torchgeo_data_module.py +++ b/terratorch/datamodules/torchgeo_data_module.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Ugly proxy objects so parsing config file works with transforms. These are necessary since, for LightningCLI to instantiate arguments as diff --git a/src/terratorch/datamodules/utils.py b/terratorch/datamodules/utils.py similarity index 84% rename from src/terratorch/datamodules/utils.py rename to terratorch/datamodules/utils.py index eba03c33..0c25d6e2 100644 --- a/src/terratorch/datamodules/utils.py +++ b/terratorch/datamodules/utils.py @@ -1,6 +1,9 @@ -import albumentations as A +# Copyright contributors to the Terratorch project + from typing import Iterable +import albumentations as A + def wrap_in_compose_is_list(transform_list): # set check shapes to false because of the multitemporal case diff --git a/src/terratorch/datasets/__init__.py b/terratorch/datasets/__init__.py similarity index 97% rename from src/terratorch/datasets/__init__.py rename to terratorch/datasets/__init__.py index fc992701..ae19d1d8 100644 --- a/src/terratorch/datasets/__init__.py +++ b/terratorch/datasets/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from terratorch.datasets.fire_scars import FireScarsHLS, FireScarsNonGeo, FireScarsSegmentationMask from terratorch.datasets.generic_pixel_wise_dataset import ( GenericNonGeoPixelwiseRegressionDataset, @@ -6,30 +8,30 @@ from terratorch.datasets.generic_scalar_label_dataset import ( GenericNonGeoClassificationDataset, ) - -# GenericNonGeoRegressionDataset, -from terratorch.datasets.sen1floods11 import Sen1Floods11NonGeo -from terratorch.datasets.utils import HLSBands - -# TorchGeo RasterDatasets -from terratorch.datasets.wsf import WSF2019, WSFEvolution from terratorch.datasets.hls import HLSL30, HLSS30 - -# geobench datasets classification -from terratorch.datasets.m_eurosat import MEuroSATNonGeo from terratorch.datasets.m_bigearthnet import MBigEarthNonGeo from terratorch.datasets.m_brick_kiln import MBrickKilnNonGeo -from terratorch.datasets.m_forestnet import MForestNetNonGeo -from terratorch.datasets.m_so2sat import MSo2SatNonGeo -from terratorch.datasets.m_pv4ger import MPv4gerNonGeo # geobench datasets segmentation from terratorch.datasets.m_cashew_plantation import MBeninSmallHolderCashewsNonGeo -from terratorch.datasets.m_nz_cattle import MNzCattleNonGeo from terratorch.datasets.m_chesapeake_landcover import MChesapeakeLandcoverNonGeo + +# geobench datasets classification +from terratorch.datasets.m_eurosat import MEuroSATNonGeo +from terratorch.datasets.m_forestnet import MForestNetNonGeo +from terratorch.datasets.m_neontree import MNeonTreeNonGeo +from terratorch.datasets.m_nz_cattle import MNzCattleNonGeo +from terratorch.datasets.m_pv4ger import MPv4gerNonGeo from terratorch.datasets.m_pv4ger_seg import MPv4gerSegNonGeo from terratorch.datasets.m_SA_crop_type import MSACropTypeNonGeo -from terratorch.datasets.m_neontree import MNeonTreeNonGeo +from terratorch.datasets.m_so2sat import MSo2SatNonGeo + +# GenericNonGeoRegressionDataset, +from terratorch.datasets.sen1floods11 import Sen1Floods11NonGeo +from terratorch.datasets.utils import HLSBands + +# TorchGeo RasterDatasets +from terratorch.datasets.wsf import WSF2019, WSFEvolution __all__ = ( "GenericNonGeoSegmentationDataset", diff --git a/src/terratorch/datasets/fire_scars.py b/terratorch/datasets/fire_scars.py similarity index 98% rename from src/terratorch/datasets/fire_scars.py rename to terratorch/datasets/fire_scars.py index 397ef732..f1463816 100644 --- a/src/terratorch/datasets/fire_scars.py +++ b/terratorch/datasets/fire_scars.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import dataclasses import glob import os diff --git a/src/terratorch/datasets/generic_pixel_wise_dataset.py b/terratorch/datasets/generic_pixel_wise_dataset.py similarity index 99% rename from src/terratorch/datasets/generic_pixel_wise_dataset.py rename to terratorch/datasets/generic_pixel_wise_dataset.py index 4ebdd6da..083a2241 100644 --- a/src/terratorch/datasets/generic_pixel_wise_dataset.py +++ b/terratorch/datasets/generic_pixel_wise_dataset.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Module containing generic dataset classes """ import glob diff --git a/src/terratorch/datasets/generic_scalar_label_dataset.py b/terratorch/datasets/generic_scalar_label_dataset.py similarity index 99% rename from src/terratorch/datasets/generic_scalar_label_dataset.py rename to terratorch/datasets/generic_scalar_label_dataset.py index 0a47b2da..85b16a75 100644 --- a/src/terratorch/datasets/generic_scalar_label_dataset.py +++ b/terratorch/datasets/generic_scalar_label_dataset.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Module containing generic dataset classes """ import glob diff --git a/src/terratorch/datasets/hls.py b/terratorch/datasets/hls.py similarity index 97% rename from src/terratorch/datasets/hls.py rename to terratorch/datasets/hls.py index a348e070..a33fb9e1 100644 --- a/src/terratorch/datasets/hls.py +++ b/terratorch/datasets/hls.py @@ -1,13 +1,14 @@ -# Copyright (c) IBM Corp. All rights reserved. -# Licensed under the MIT License. +# Copyright contributors to the Terratorch project + """Harmonized Landsat and Sentinel-2 datasets.""" import abc from collections.abc import Iterable, Sequence +from typing import Any, Callable, Optional, Union + from rasterio.crs import CRS from torchgeo.datasets import Landsat -from typing import Any, Callable, Optional, Union class HLS(Landsat, abc.ABC): diff --git a/src/terratorch/datasets/m_SA_crop_type.py b/terratorch/datasets/m_SA_crop_type.py similarity index 100% rename from src/terratorch/datasets/m_SA_crop_type.py rename to terratorch/datasets/m_SA_crop_type.py diff --git a/src/terratorch/datasets/m_bigearthnet.py b/terratorch/datasets/m_bigearthnet.py similarity index 100% rename from src/terratorch/datasets/m_bigearthnet.py rename to terratorch/datasets/m_bigearthnet.py diff --git a/src/terratorch/datasets/m_brick_kiln.py b/terratorch/datasets/m_brick_kiln.py similarity index 100% rename from src/terratorch/datasets/m_brick_kiln.py rename to terratorch/datasets/m_brick_kiln.py diff --git a/src/terratorch/datasets/m_cashew_plantation.py b/terratorch/datasets/m_cashew_plantation.py similarity index 100% rename from src/terratorch/datasets/m_cashew_plantation.py rename to terratorch/datasets/m_cashew_plantation.py diff --git a/src/terratorch/datasets/m_chesapeake_landcover.py b/terratorch/datasets/m_chesapeake_landcover.py similarity index 100% rename from src/terratorch/datasets/m_chesapeake_landcover.py rename to terratorch/datasets/m_chesapeake_landcover.py diff --git a/src/terratorch/datasets/m_eurosat.py b/terratorch/datasets/m_eurosat.py similarity index 100% rename from src/terratorch/datasets/m_eurosat.py rename to terratorch/datasets/m_eurosat.py diff --git a/src/terratorch/datasets/m_forestnet.py b/terratorch/datasets/m_forestnet.py similarity index 100% rename from src/terratorch/datasets/m_forestnet.py rename to terratorch/datasets/m_forestnet.py diff --git a/src/terratorch/datasets/m_neontree.py b/terratorch/datasets/m_neontree.py similarity index 100% rename from src/terratorch/datasets/m_neontree.py rename to terratorch/datasets/m_neontree.py diff --git a/src/terratorch/datasets/m_nz_cattle.py b/terratorch/datasets/m_nz_cattle.py similarity index 100% rename from src/terratorch/datasets/m_nz_cattle.py rename to terratorch/datasets/m_nz_cattle.py diff --git a/src/terratorch/datasets/m_pv4ger.py b/terratorch/datasets/m_pv4ger.py similarity index 100% rename from src/terratorch/datasets/m_pv4ger.py rename to terratorch/datasets/m_pv4ger.py diff --git a/src/terratorch/datasets/m_pv4ger_seg.py b/terratorch/datasets/m_pv4ger_seg.py similarity index 100% rename from src/terratorch/datasets/m_pv4ger_seg.py rename to terratorch/datasets/m_pv4ger_seg.py diff --git a/src/terratorch/datasets/m_so2sat.py b/terratorch/datasets/m_so2sat.py similarity index 100% rename from src/terratorch/datasets/m_so2sat.py rename to terratorch/datasets/m_so2sat.py diff --git a/src/terratorch/datasets/sen1floods11.py b/terratorch/datasets/sen1floods11.py similarity index 99% rename from src/terratorch/datasets/sen1floods11.py rename to terratorch/datasets/sen1floods11.py index 268c761e..2e8f02c0 100644 --- a/src/terratorch/datasets/sen1floods11.py +++ b/terratorch/datasets/sen1floods11.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import dataclasses import glob import os diff --git a/src/terratorch/datasets/transforms.py b/terratorch/datasets/transforms.py similarity index 98% rename from src/terratorch/datasets/transforms.py rename to terratorch/datasets/transforms.py index f2fc537d..c3b608b8 100644 --- a/src/terratorch/datasets/transforms.py +++ b/terratorch/datasets/transforms.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from albumentations import BasicTransform, Compose, ImageOnlyTransform from einops import rearrange from torch import Tensor diff --git a/src/terratorch/datasets/utils.py b/terratorch/datasets/utils.py similarity index 97% rename from src/terratorch/datasets/utils.py rename to terratorch/datasets/utils.py index 266d8bd1..0dee447e 100644 --- a/src/terratorch/datasets/utils.py +++ b/terratorch/datasets/utils.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import os from collections.abc import Iterator from enum import Enum diff --git a/src/terratorch/datasets/wsf.py b/terratorch/datasets/wsf.py similarity index 97% rename from src/terratorch/datasets/wsf.py rename to terratorch/datasets/wsf.py index 02cea664..492d3b9e 100644 --- a/src/terratorch/datasets/wsf.py +++ b/terratorch/datasets/wsf.py @@ -1,16 +1,16 @@ -# Copyright (c) IBM Corp. All rights reserved. -# Licensed under the MIT License. +# Copyright contributors to the Terratorch project + """World Settlement Footprint datasets.""" import abc +from collections.abc import Iterable, Sequence +from typing import Any, Callable, Optional, Union + import matplotlib.pyplot as plt import numpy as np - -from collections.abc import Iterable, Sequence from rasterio.crs import CRS from torchgeo.datasets import RasterDataset -from typing import Any, Callable, Optional, Union class WSF(RasterDataset, abc.ABC): diff --git a/src/terratorch/io/file.py b/terratorch/io/file.py similarity index 100% rename from src/terratorch/io/file.py rename to terratorch/io/file.py diff --git a/src/terratorch/models/__init__.py b/terratorch/models/__init__.py similarity index 91% rename from src/terratorch/models/__init__.py rename to terratorch/models/__init__.py index cb3e3129..a04404ad 100644 --- a/src/terratorch/models/__init__.py +++ b/terratorch/models/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from terratorch.models.prithvi_model_factory import PrithviModelFactory from terratorch.models.satmae_model_factory import SatMAEModelFactory from terratorch.models.scalemae_model_factory import ScaleMAEModelFactory diff --git a/terratorch/models/backbones/__init__.py b/terratorch/models/backbones/__init__.py new file mode 100644 index 00000000..1f27dfd4 --- /dev/null +++ b/terratorch/models/backbones/__init__.py @@ -0,0 +1,5 @@ +# Copyright contributors to the Terratorch project + +# import so they get registered +import terratorch.models.backbones.prithvi_swin +import terratorch.models.backbones.prithvi_vit diff --git a/src/terratorch/models/backbones/prithvi_select_patch_embed_weights.py b/terratorch/models/backbones/prithvi_select_patch_embed_weights.py similarity index 97% rename from src/terratorch/models/backbones/prithvi_select_patch_embed_weights.py rename to terratorch/models/backbones/prithvi_select_patch_embed_weights.py index a50937b8..db38aa29 100644 --- a/src/terratorch/models/backbones/prithvi_select_patch_embed_weights.py +++ b/terratorch/models/backbones/prithvi_select_patch_embed_weights.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import logging import torch diff --git a/src/terratorch/models/backbones/prithvi_swin.py b/terratorch/models/backbones/prithvi_swin.py similarity index 99% rename from src/terratorch/models/backbones/prithvi_swin.py rename to terratorch/models/backbones/prithvi_swin.py index d83edac0..2587a545 100644 --- a/src/terratorch/models/backbones/prithvi_swin.py +++ b/terratorch/models/backbones/prithvi_swin.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """This module handles registering prithvi_swin models into timm. """ diff --git a/src/terratorch/models/backbones/prithvi_vit.py b/terratorch/models/backbones/prithvi_vit.py similarity index 98% rename from src/terratorch/models/backbones/prithvi_vit.py rename to terratorch/models/backbones/prithvi_vit.py index f06f3872..a9448762 100644 --- a/src/terratorch/models/backbones/prithvi_vit.py +++ b/terratorch/models/backbones/prithvi_vit.py @@ -1,5 +1,5 @@ -# Copyright (c) IBM Corp. All rights reserved. -# Licensed under the MIT License. +# Copyright contributors to the Terratorch project + import logging from functools import partial diff --git a/src/terratorch/models/backbones/swin_encoder_decoder.py b/terratorch/models/backbones/swin_encoder_decoder.py similarity index 99% rename from src/terratorch/models/backbones/swin_encoder_decoder.py rename to terratorch/models/backbones/swin_encoder_decoder.py index 459f8720..0ca68550 100644 --- a/src/terratorch/models/backbones/swin_encoder_decoder.py +++ b/terratorch/models/backbones/swin_encoder_decoder.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Swin transformer implementation. Mix of MMSegmentation implementation and timm implementation. We use this implementation instead of the original implementation or timm's. diff --git a/src/terratorch/models/backbones/vit_encoder_decoder.py b/terratorch/models/backbones/vit_encoder_decoder.py similarity index 99% rename from src/terratorch/models/backbones/vit_encoder_decoder.py rename to terratorch/models/backbones/vit_encoder_decoder.py index e3f23992..4082d506 100644 --- a/src/terratorch/models/backbones/vit_encoder_decoder.py +++ b/terratorch/models/backbones/vit_encoder_decoder.py @@ -6,6 +6,9 @@ # DeiT: https://github.com/facebookresearch/deit # -------------------------------------------------------- +# Copyright contributors to the Terratorch project + + from functools import lru_cache import numpy as np diff --git a/src/terratorch/models/clay_model_factory.py b/terratorch/models/clay_model_factory.py similarity index 100% rename from src/terratorch/models/clay_model_factory.py rename to terratorch/models/clay_model_factory.py diff --git a/src/terratorch/models/decoders/__init__.py b/terratorch/models/decoders/__init__.py similarity index 87% rename from src/terratorch/models/decoders/__init__.py rename to terratorch/models/decoders/__init__.py index bd32174a..c4b6465a 100644 --- a/src/terratorch/models/decoders/__init__.py +++ b/terratorch/models/decoders/__init__.py @@ -1,6 +1,8 @@ +# Copyright contributors to the Terratorch project + from terratorch.models.decoders.fcn_decoder import FCNDecoder from terratorch.models.decoders.identity_decoder import IdentityDecoder -from terratorch.models.decoders.upernet_decoder import UperNetDecoder from terratorch.models.decoders.satmae_head import SatMAEHead, SatMAEHeadViT +from terratorch.models.decoders.upernet_decoder import UperNetDecoder __all__ = ["FCNDecoder", "UperNetDecoder", "IdentityDecoder", "SatMAEHead", "SatMAEHeadViT"] diff --git a/src/terratorch/models/decoders/fcn_decoder.py b/terratorch/models/decoders/fcn_decoder.py similarity index 97% rename from src/terratorch/models/decoders/fcn_decoder.py rename to terratorch/models/decoders/fcn_decoder.py index a25935b5..00574b96 100644 --- a/src/terratorch/models/decoders/fcn_decoder.py +++ b/terratorch/models/decoders/fcn_decoder.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from torch import Tensor, nn diff --git a/src/terratorch/models/decoders/identity_decoder.py b/terratorch/models/decoders/identity_decoder.py similarity index 92% rename from src/terratorch/models/decoders/identity_decoder.py rename to terratorch/models/decoders/identity_decoder.py index 08b279e1..69495511 100644 --- a/src/terratorch/models/decoders/identity_decoder.py +++ b/terratorch/models/decoders/identity_decoder.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """Pass the features straight through """ diff --git a/src/terratorch/models/decoders/satmae_head.py b/terratorch/models/decoders/satmae_head.py similarity index 97% rename from src/terratorch/models/decoders/satmae_head.py rename to terratorch/models/decoders/satmae_head.py index 557b2bb6..f79bd61f 100644 --- a/src/terratorch/models/decoders/satmae_head.py +++ b/terratorch/models/decoders/satmae_head.py @@ -1,7 +1,9 @@ +# Copyright contributors to the Terratorch project + import torch -import torch.nn as nn - -from timm.models.vision_transformer import PatchEmbed, Block +import torch.nn as nn +from timm.models.vision_transformer import Block, PatchEmbed + class SatMAEHead(nn.Module): diff --git a/src/terratorch/models/decoders/upernet_decoder.py b/terratorch/models/decoders/upernet_decoder.py similarity index 99% rename from src/terratorch/models/decoders/upernet_decoder.py rename to terratorch/models/decoders/upernet_decoder.py index a37ec747..90d2973c 100644 --- a/src/terratorch/models/decoders/upernet_decoder.py +++ b/terratorch/models/decoders/upernet_decoder.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import torch import torch.nn.functional as F # noqa: N812 from torch import Tensor, nn diff --git a/src/terratorch/models/heads/__init__.py b/terratorch/models/heads/__init__.py similarity index 84% rename from src/terratorch/models/heads/__init__.py rename to terratorch/models/heads/__init__.py index bee71f51..c7675171 100644 --- a/src/terratorch/models/heads/__init__.py +++ b/terratorch/models/heads/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from terratorch.models.heads.classification_head import ClassificationHead from terratorch.models.heads.regression_head import RegressionHead from terratorch.models.heads.segmentation_head import SegmentationHead diff --git a/src/terratorch/models/heads/classification_head.py b/terratorch/models/heads/classification_head.py similarity index 97% rename from src/terratorch/models/heads/classification_head.py rename to terratorch/models/heads/classification_head.py index f3b6cccd..4bf444e9 100644 --- a/src/terratorch/models/heads/classification_head.py +++ b/terratorch/models/heads/classification_head.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from torch import Tensor, nn diff --git a/src/terratorch/models/heads/regression_head.py b/terratorch/models/heads/regression_head.py similarity index 98% rename from src/terratorch/models/heads/regression_head.py rename to terratorch/models/heads/regression_head.py index 33e16bd2..e1a0f598 100644 --- a/src/terratorch/models/heads/regression_head.py +++ b/terratorch/models/heads/regression_head.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import importlib from torch import nn diff --git a/src/terratorch/models/heads/segmentation_head.py b/terratorch/models/heads/segmentation_head.py similarity index 96% rename from src/terratorch/models/heads/segmentation_head.py rename to terratorch/models/heads/segmentation_head.py index 9491b010..aeea1473 100644 --- a/src/terratorch/models/heads/segmentation_head.py +++ b/terratorch/models/heads/segmentation_head.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from torch import nn diff --git a/src/terratorch/models/model.py b/terratorch/models/model.py similarity index 97% rename from src/terratorch/models/model.py rename to terratorch/models/model.py index 358245f2..31072677 100644 --- a/src/terratorch/models/model.py +++ b/terratorch/models/model.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from abc import ABC, abstractmethod from dataclasses import dataclass diff --git a/src/terratorch/models/pixel_wise_model.py b/terratorch/models/pixel_wise_model.py similarity index 99% rename from src/terratorch/models/pixel_wise_model.py rename to terratorch/models/pixel_wise_model.py index c10ac6ea..b9215997 100644 --- a/src/terratorch/models/pixel_wise_model.py +++ b/terratorch/models/pixel_wise_model.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from collections.abc import Callable import torch diff --git a/src/terratorch/models/prithvi_model_factory.py b/terratorch/models/prithvi_model_factory.py similarity index 99% rename from src/terratorch/models/prithvi_model_factory.py rename to terratorch/models/prithvi_model_factory.py index a84a35a8..5347bca5 100644 --- a/src/terratorch/models/prithvi_model_factory.py +++ b/terratorch/models/prithvi_model_factory.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from collections.abc import Callable import timm diff --git a/src/terratorch/models/satmae_model_factory.py b/terratorch/models/satmae_model_factory.py similarity index 99% rename from src/terratorch/models/satmae_model_factory.py rename to terratorch/models/satmae_model_factory.py index 5b73c0fa..93d32e64 100644 --- a/src/terratorch/models/satmae_model_factory.py +++ b/terratorch/models/satmae_model_factory.py @@ -1,6 +1,8 @@ +# Copyright contributors to the Terratorch project + import importlib -from collections.abc import Callable import sys +from collections.abc import Callable import numpy as np import timm diff --git a/src/terratorch/models/scalar_output_model.py b/terratorch/models/scalar_output_model.py similarity index 98% rename from src/terratorch/models/scalar_output_model.py rename to terratorch/models/scalar_output_model.py index fd7fc288..ca5ea86a 100644 --- a/src/terratorch/models/scalar_output_model.py +++ b/terratorch/models/scalar_output_model.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from collections.abc import Callable import torch diff --git a/src/terratorch/models/scalemae_model_factory.py b/terratorch/models/scalemae_model_factory.py similarity index 99% rename from src/terratorch/models/scalemae_model_factory.py rename to terratorch/models/scalemae_model_factory.py index 92dd7125..401b0c94 100644 --- a/src/terratorch/models/scalemae_model_factory.py +++ b/terratorch/models/scalemae_model_factory.py @@ -1,6 +1,8 @@ +# Copyright contributors to the Terratorch project + import importlib -from collections.abc import Callable import sys +from collections.abc import Callable import numpy as np import timm diff --git a/src/terratorch/models/smp_model_factory.py b/terratorch/models/smp_model_factory.py similarity index 98% rename from src/terratorch/models/smp_model_factory.py rename to terratorch/models/smp_model_factory.py index 00dfd03b..ee58c0d1 100644 --- a/src/terratorch/models/smp_model_factory.py +++ b/terratorch/models/smp_model_factory.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """ This is just an example of a possible structure to include SMP models Right now it always returns a UNET, but could easily be extended to many of the models provided by SMP. diff --git a/src/terratorch/models/timm_model_factory.py b/terratorch/models/timm_model_factory.py similarity index 98% rename from src/terratorch/models/timm_model_factory.py rename to terratorch/models/timm_model_factory.py index 0fa28476..53f6c0f3 100644 --- a/src/terratorch/models/timm_model_factory.py +++ b/terratorch/models/timm_model_factory.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + """ This is just an example of a possible structure to include timm models """ diff --git a/src/terratorch/samplers/__init__.py b/terratorch/samplers/__init__.py similarity index 59% rename from src/terratorch/samplers/__init__.py rename to terratorch/samplers/__init__.py index 743a250d..2de7bdbc 100644 --- a/src/terratorch/samplers/__init__.py +++ b/terratorch/samplers/__init__.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + from .single import ( RandomMultiSampler, SequentialMultiSampler, diff --git a/src/terratorch/samplers/single.py b/terratorch/samplers/single.py similarity index 95% rename from src/terratorch/samplers/single.py rename to terratorch/samplers/single.py index 38b263e5..0550785d 100644 --- a/src/terratorch/samplers/single.py +++ b/terratorch/samplers/single.py @@ -1,8 +1,12 @@ +# Copyright contributors to the Terratorch project + from random import choice +from typing import Iterable, Iterator + from torch.utils.data import Sampler from torchgeo.datasets import BoundingBox from torchgeo.samplers import GeoSampler -from typing import Iterable, Iterator + class MultiSampler(Sampler[BoundingBox]): def __init__(self, samplers: Iterable[GeoSampler]) -> None: diff --git a/src/terratorch/tasks/__init__.py b/terratorch/tasks/__init__.py similarity index 100% rename from src/terratorch/tasks/__init__.py rename to terratorch/tasks/__init__.py diff --git a/src/terratorch/tasks/classification_tasks.py b/terratorch/tasks/classification_tasks.py similarity index 100% rename from src/terratorch/tasks/classification_tasks.py rename to terratorch/tasks/classification_tasks.py diff --git a/src/terratorch/tasks/loss_handler.py b/terratorch/tasks/loss_handler.py similarity index 100% rename from src/terratorch/tasks/loss_handler.py rename to terratorch/tasks/loss_handler.py diff --git a/src/terratorch/tasks/multilabel_classification_tasks.py b/terratorch/tasks/multilabel_classification_tasks.py similarity index 100% rename from src/terratorch/tasks/multilabel_classification_tasks.py rename to terratorch/tasks/multilabel_classification_tasks.py diff --git a/src/terratorch/tasks/optimizer_factory.py b/terratorch/tasks/optimizer_factory.py similarity index 100% rename from src/terratorch/tasks/optimizer_factory.py rename to terratorch/tasks/optimizer_factory.py diff --git a/src/terratorch/tasks/regression_tasks.py b/terratorch/tasks/regression_tasks.py similarity index 100% rename from src/terratorch/tasks/regression_tasks.py rename to terratorch/tasks/regression_tasks.py diff --git a/src/terratorch/tasks/segmentation_tasks.py b/terratorch/tasks/segmentation_tasks.py similarity index 100% rename from src/terratorch/tasks/segmentation_tasks.py rename to terratorch/tasks/segmentation_tasks.py diff --git a/src/terratorch/tasks/tiled_inference.py b/terratorch/tasks/tiled_inference.py similarity index 100% rename from src/terratorch/tasks/tiled_inference.py rename to terratorch/tasks/tiled_inference.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..1de4e6c2 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,2 @@ +# Copyright contributors to the Terratorch project + diff --git a/tests/test_backbones.py b/tests/test_backbones.py index 6b8c36b9..d1f58ecb 100644 --- a/tests/test_backbones.py +++ b/tests/test_backbones.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import pytest import timm import torch diff --git a/tests/test_generic_dataset.py b/tests/test_generic_dataset.py index 077d57c6..7ec70933 100644 --- a/tests/test_generic_dataset.py +++ b/tests/test_generic_dataset.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import os import pytest diff --git a/tests/test_prithvi_model_factory.py b/tests/test_prithvi_model_factory.py index ad7f53a5..6d3a4b82 100644 --- a/tests/test_prithvi_model_factory.py +++ b/tests/test_prithvi_model_factory.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import os import pytest diff --git a/tests/test_prithvi_tasks.py b/tests/test_prithvi_tasks.py index ca5280a3..cccb1193 100644 --- a/tests/test_prithvi_tasks.py +++ b/tests/test_prithvi_tasks.py @@ -1,3 +1,5 @@ +# Copyright contributors to the Terratorch project + import pytest import torch From 9259d41541b0ecab198d3b816d8bd3bbd2935e2d Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 12:10:27 +0200 Subject: [PATCH 2/6] dependabot setup Signed-off-by: Carlos Gomes --- .github/workflows/dependabot.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/dependabot.yaml diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml new file mode 100644 index 00000000..e323900a --- /dev/null +++ b/.github/workflows/dependabot.yaml @@ -0,0 +1,24 @@ +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file +# mostly from https://github.com/microsoft/torchgeo/blob/main/.github/dependabot.yml +version: 1 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + groups: + # torchvision pins torch, must update in unison + torch: + patterns: + - "torch" + - "torchvision" + ignore: + # setuptools releases new versions almost daily + - dependency-name: "setuptools" + update-types: ["version-update:semver-patch"] + # segmentation-models-pytorch pins timm, must update in unison + - dependency-name: "timm" \ No newline at end of file From 0563d61eb7ad27b994599e7369b2490b3f66de50 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 13:53:16 +0200 Subject: [PATCH 3/6] dependabot yaml version 2 Signed-off-by: Carlos Gomes --- .github/workflows/dependabot.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml index e323900a..96812e26 100644 --- a/.github/workflows/dependabot.yaml +++ b/.github/workflows/dependabot.yaml @@ -1,6 +1,6 @@ # https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file # mostly from https://github.com/microsoft/torchgeo/blob/main/.github/dependabot.yml -version: 1 +version: 2 updates: - package-ecosystem: "github-actions" directory: "/" From 8609a11d5148736c8b6f816b4b261c28c4d65dda Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 13:57:27 +0200 Subject: [PATCH 4/6] move test dependencies to optional Signed-off-by: Carlos Gomes --- README.md | 2 +- pyproject.toml | 7 +++++-- requirements-dev.txt | 7 ------- requirements.txt | 12 ------------ 4 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 requirements.txt diff --git a/README.md b/README.md index fe15bfe6..546b43a8 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ If you prefer to get the most recent version of the main branch, install the lib TerraTorch requires gdal to be installed, which can be quite a complex process. If you don't have GDAL set up on your system, we reccomend using a conda environment and installing it with `conda install -c conda-forge gdal`. -To install as a developer (e.g. to extend the library) clone this repo, install dependencies using `pip install -r requirements.txt` and run `pip install -e .` +To install as a developer (e.g. to extend the library) clone this repo, install dependencies using `pip install -r requirements/required.txt -r requirements/dev.txt` and run `pip install -e .` ## Quick start diff --git a/pyproject.toml b/pyproject.toml index 818d9fe0..692f7b3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,8 +26,6 @@ classifiers = [ "Programming Language :: Python :: Implementation :: PyPy", ] dependencies = [ - "coverage", - "pytest", "torch>=2.1.0", "torchvision>=0.16.0", "torchgeo>=0.5.1", @@ -50,6 +48,11 @@ dev = [ "mkdocstrings[python]" ] +test = [ + "coverage", + "pytest" +] + [project.urls] Documentation = "https://github.com/IBM/terratorch#readme" Issues = "https://github.com/IBM/terratorch/issues" diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index bc2b3eec..00000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,7 +0,0 @@ -coverage[toml]>=6.5 -pytest-cov==4.1.0 -pytest==7.4.3 -mkdocs-material==9.4.14 -mkdocstrings[python] -h5py==3.10.0 -geobench==1.0.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 80114f18..00000000 --- a/requirements.txt +++ /dev/null @@ -1,12 +0,0 @@ -torchgeo==0.5.1 -rioxarray==0.15.0 -albumentations==1.3.1 -rasterio==1.3.9 -torch==2.1.0 -torchvision==0.16.0 -torchmetrics==1.3.1 -geopandas==0.14.2 -lightly==1.4.25 -h5py==3.10.0 -geobench==1.0.0 -mlflow==2.12.1 From b427754676df2e81dfe0d426dd00175dd461ef31 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 14:01:26 +0200 Subject: [PATCH 5/6] change requirements install path Signed-off-by: Carlos Gomes --- .github/workflows/test.yaml | 6 ++---- requirements/dev.txt | 4 ++++ requirements/required.txt | 12 ++++++++++++ requirements/test.txt | 3 +++ 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 requirements/dev.txt create mode 100644 requirements/required.txt create mode 100644 requirements/test.txt diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 479c1e90..9ef75813 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11"] steps: - name: Clone repo @@ -27,9 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pytest - pip install -r requirements.txt - pip install -e . + pip install -r requirements/required.txt -r requirements/test.txt - name: List pip dependencies run: pip list - name: Test with pytest diff --git a/requirements/dev.txt b/requirements/dev.txt new file mode 100644 index 00000000..95fc76b8 --- /dev/null +++ b/requirements/dev.txt @@ -0,0 +1,4 @@ +mkdocs-material==9.4.14 +mkdocstrings[python] +h5py==3.10.0 +geobench==1.0.0 \ No newline at end of file diff --git a/requirements/required.txt b/requirements/required.txt new file mode 100644 index 00000000..80114f18 --- /dev/null +++ b/requirements/required.txt @@ -0,0 +1,12 @@ +torchgeo==0.5.1 +rioxarray==0.15.0 +albumentations==1.3.1 +rasterio==1.3.9 +torch==2.1.0 +torchvision==0.16.0 +torchmetrics==1.3.1 +geopandas==0.14.2 +lightly==1.4.25 +h5py==3.10.0 +geobench==1.0.0 +mlflow==2.12.1 diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 00000000..51d98159 --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,3 @@ +coverage[toml]>=6.5 +pytest-cov==4.1.0 +pytest==7.4.3 \ No newline at end of file From 0068b3a0b20dfdc7d728eed07407efa6c0126665 Mon Sep 17 00:00:00 2001 From: Carlos Gomes Date: Tue, 2 Jul 2024 14:20:48 +0200 Subject: [PATCH 6/6] move dependabot.yaml to the correct directory Signed-off-by: Carlos Gomes --- .github/workflows/dependabot.yaml | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 .github/workflows/dependabot.yaml diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml deleted file mode 100644 index 96812e26..00000000 --- a/.github/workflows/dependabot.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file -# mostly from https://github.com/microsoft/torchgeo/blob/main/.github/dependabot.yml -version: 2 -updates: - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "weekly" - - package-ecosystem: "pip" - directory: "/" - schedule: - interval: "daily" - groups: - # torchvision pins torch, must update in unison - torch: - patterns: - - "torch" - - "torchvision" - ignore: - # setuptools releases new versions almost daily - - dependency-name: "setuptools" - update-types: ["version-update:semver-patch"] - # segmentation-models-pytorch pins timm, must update in unison - - dependency-name: "timm" \ No newline at end of file