diff --git a/.github/dependabot.yml b/.github/dependabot.yml index fd7657e43e7..d85c8612873 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,5 @@ updates: # Allow up to 2 open pull requests at a time open-pull-requests-limit: 2 ignore: - # torch, tensorboard require protobuf < 4 - - dependency-name: "protobuf" # segmentation-models-pytorch requires older timm, can't update - dependency-name: "timm" diff --git a/docs/conf.py b/docs/conf.py index 558bf9b710e..11df4f7ef13 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,6 +60,7 @@ ("py:class", ".."), # TODO: can't figure out why this isn't found ("py:class", "LightningDataModule"), + ("py:class", "pytorch_lightning.core.module.LightningModule"), # Undocumented class ("py:class", "torchvision.models.resnet.ResNet"), ("py:class", "segmentation_models_pytorch.base.model.SegmentationModel"), diff --git a/experiments/test_chesapeakecvpr_models.py b/experiments/test_chesapeakecvpr_models.py index 38ab24fa842..492eb4af97e 100755 --- a/experiments/test_chesapeakecvpr_models.py +++ b/experiments/test_chesapeakecvpr_models.py @@ -89,8 +89,8 @@ def main(args: argparse.Namespace) -> None: trainer = pl.Trainer( gpus=[args.device] if torch.cuda.is_available() else None, logger=False, - progress_bar_refresh_rate=0, - checkpoint_callback=False, + enable_progress_bar=False, + enable_checkpointing=False, ) for experiment_dir in os.listdir(args.input_dir): diff --git a/pyproject.toml b/pyproject.toml index 7fb0324c083..baf144d9a8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,6 +71,8 @@ filterwarnings = [ # https://github.com/PyTorchLightning/pytorch-lightning/issues/13256 # https://github.com/PyTorchLightning/pytorch-lightning/pull/13261 "ignore:torch.distributed._sharded_tensor will be deprecated:DeprecationWarning:torch.distributed._sharded_tensor", + # https://github.com/Lightning-AI/lightning/issues/13989 + "ignore:SelectableGroups dict interface is deprecated. Use select.:DeprecationWarning:pytorch_lightning.trainer.connectors.callback_connector", # https://github.com/rasterio/rasterio/issues/1742 # https://github.com/rasterio/rasterio/pull/1753 "ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated:DeprecationWarning:rasterio.crs", diff --git a/requirements/required.old b/requirements/required.old index e76122f86a0..cca8a364b8e 100644 --- a/requirements/required.old +++ b/requirements/required.old @@ -11,7 +11,6 @@ numpy==1.21.6;python_version=='3.7' omegaconf==2.2.2 packaging==21.3 pillow==9.2.0 -protobuf==3.20.1 pyproj==3.3.1;python_version>='3.8' pyproj==3.2.0;python_version=='3.7' pytorch-lightning==1.6.4 diff --git a/requirements/required.txt b/requirements/required.txt index 0d3aa0dacf6..6d06f5e700a 100644 --- a/requirements/required.txt +++ b/requirements/required.txt @@ -10,9 +10,8 @@ numpy==1.23.1;python_version>='3.8' omegaconf==2.2.2 packaging==21.3 pillow==9.2.0 -protobuf==3.20.1 pyproj==3.3.1;python_version>='3.8' -pytorch-lightning==1.6.5 +pytorch-lightning==1.7.0 rasterio==1.3.0;python_version>='3.8' rtree==1.0.0 scikit-learn==1.1.1;python_version>='3.8' diff --git a/torchgeo/datamodules/bigearthnet.py b/torchgeo/datamodules/bigearthnet.py index aca9834fe81..67ea60f9814 100644 --- a/torchgeo/datamodules/bigearthnet.py +++ b/torchgeo/datamodules/bigearthnet.py @@ -90,7 +90,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.bands = bands self.num_classes = num_classes diff --git a/torchgeo/datamodules/chesapeake.py b/torchgeo/datamodules/chesapeake.py index 74eded7e09d..2eff5fb0d04 100644 --- a/torchgeo/datamodules/chesapeake.py +++ b/torchgeo/datamodules/chesapeake.py @@ -64,7 +64,7 @@ def __init__( Raises: ValueError: if ``use_prior_labels`` is used with ``class_set==7`` """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() for state in train_splits + val_splits + test_splits: assert state in ChesapeakeCVPR.splits assert class_set in [5, 7] diff --git a/torchgeo/datamodules/cowc.py b/torchgeo/datamodules/cowc.py index 736c13a35b7..4db43f7dc2d 100644 --- a/torchgeo/datamodules/cowc.py +++ b/torchgeo/datamodules/cowc.py @@ -36,7 +36,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.seed = seed self.batch_size = batch_size diff --git a/torchgeo/datamodules/cyclone.py b/torchgeo/datamodules/cyclone.py index 9a9724234b6..792e4027d78 100644 --- a/torchgeo/datamodules/cyclone.py +++ b/torchgeo/datamodules/cyclone.py @@ -44,7 +44,7 @@ def __init__( api_key: The RadiantEarth MLHub API key to use if the dataset needs to be downloaded """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.seed = seed self.batch_size = batch_size diff --git a/torchgeo/datamodules/deepglobelandcover.py b/torchgeo/datamodules/deepglobelandcover.py index 632add64a92..086c70e6e70 100644 --- a/torchgeo/datamodules/deepglobelandcover.py +++ b/torchgeo/datamodules/deepglobelandcover.py @@ -36,7 +36,7 @@ def __init__( num_workers: The number of workers to use in all created DataLoaders val_split_pct: What percentage of the dataset to use as a validation set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/etci2021.py b/torchgeo/datamodules/etci2021.py index 0477c1f4012..5620324726c 100644 --- a/torchgeo/datamodules/etci2021.py +++ b/torchgeo/datamodules/etci2021.py @@ -48,7 +48,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.seed = seed self.batch_size = batch_size diff --git a/torchgeo/datamodules/eurosat.py b/torchgeo/datamodules/eurosat.py index 2f6d990e8e3..47d0057a932 100644 --- a/torchgeo/datamodules/eurosat.py +++ b/torchgeo/datamodules/eurosat.py @@ -68,7 +68,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/fair1m.py b/torchgeo/datamodules/fair1m.py index a8459c7ba92..037337bd9bd 100644 --- a/torchgeo/datamodules/fair1m.py +++ b/torchgeo/datamodules/fair1m.py @@ -56,7 +56,7 @@ def __init__( val_split_pct: What percentage of the dataset to use as a validation set test_split_pct: What percentage of the dataset to use as a test set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/inria.py b/torchgeo/datamodules/inria.py index adea872cbf2..312a5d82dee 100644 --- a/torchgeo/datamodules/inria.py +++ b/torchgeo/datamodules/inria.py @@ -65,7 +65,7 @@ def __init__( num_patches_per_tile: Number of random patches per sample predict_on: Directory/Dataset of images to run inference on """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/landcoverai.py b/torchgeo/datamodules/landcoverai.py index b74f649fedf..b5a9675eb4c 100644 --- a/torchgeo/datamodules/landcoverai.py +++ b/torchgeo/datamodules/landcoverai.py @@ -33,7 +33,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/loveda.py b/torchgeo/datamodules/loveda.py index 2bfddd953c8..05e346ab8a5 100644 --- a/torchgeo/datamodules/loveda.py +++ b/torchgeo/datamodules/loveda.py @@ -39,7 +39,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.scene = scene self.batch_size = batch_size diff --git a/torchgeo/datamodules/naip.py b/torchgeo/datamodules/naip.py index acd8cdcbee7..b2076f2b847 100644 --- a/torchgeo/datamodules/naip.py +++ b/torchgeo/datamodules/naip.py @@ -46,7 +46,7 @@ def __init__( num_workers: The number of workers to use in all created DataLoaders patch_size: size of patches to sample """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.naip_root_dir = naip_root_dir self.chesapeake_root_dir = chesapeake_root_dir self.batch_size = batch_size diff --git a/torchgeo/datamodules/nasa_marine_debris.py b/torchgeo/datamodules/nasa_marine_debris.py index 989deeb815f..9c0221d1874 100644 --- a/torchgeo/datamodules/nasa_marine_debris.py +++ b/torchgeo/datamodules/nasa_marine_debris.py @@ -57,7 +57,7 @@ def __init__( val_split_pct: What percentage of the dataset to use as a validation set test_split_pct: What percentage of the dataset to use as a test set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/oscd.py b/torchgeo/datamodules/oscd.py index d11649a8a91..779566baaf0 100644 --- a/torchgeo/datamodules/oscd.py +++ b/torchgeo/datamodules/oscd.py @@ -87,7 +87,7 @@ def __init__( num_patches_per_tile: number of random patches per sample pad_size: size to pad images to during val/test steps """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.bands = bands self.train_batch_size = train_batch_size diff --git a/torchgeo/datamodules/potsdam.py b/torchgeo/datamodules/potsdam.py index 776d999cb1e..6d5a7bb2784 100644 --- a/torchgeo/datamodules/potsdam.py +++ b/torchgeo/datamodules/potsdam.py @@ -37,7 +37,7 @@ def __init__( num_workers: The number of workers to use in all created DataLoaders val_split_pct: What percentage of the dataset to use as a validation set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/resisc45.py b/torchgeo/datamodules/resisc45.py index 2c111b0431e..993f8c97ef4 100644 --- a/torchgeo/datamodules/resisc45.py +++ b/torchgeo/datamodules/resisc45.py @@ -38,7 +38,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/sen12ms.py b/torchgeo/datamodules/sen12ms.py index e248d718e74..45754424f07 100644 --- a/torchgeo/datamodules/sen12ms.py +++ b/torchgeo/datamodules/sen12ms.py @@ -72,7 +72,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() assert band_set in SEN12MS.BAND_SETS.keys() self.root_dir = root_dir diff --git a/torchgeo/datamodules/so2sat.py b/torchgeo/datamodules/so2sat.py index 968e81828ff..8f312e3cc01 100644 --- a/torchgeo/datamodules/so2sat.py +++ b/torchgeo/datamodules/so2sat.py @@ -75,7 +75,7 @@ def __init__( unsupervised_mode: Makes the train dataloader return imagery from the train, val, and test sets """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/ucmerced.py b/torchgeo/datamodules/ucmerced.py index f95f75cf454..2fc08d39778 100644 --- a/torchgeo/datamodules/ucmerced.py +++ b/torchgeo/datamodules/ucmerced.py @@ -34,7 +34,7 @@ def __init__( batch_size: The batch size to use in all created DataLoaders num_workers: The number of workers to use in all created DataLoaders """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/vaihingen.py b/torchgeo/datamodules/vaihingen.py index cced8a3ff27..49308732983 100644 --- a/torchgeo/datamodules/vaihingen.py +++ b/torchgeo/datamodules/vaihingen.py @@ -37,7 +37,7 @@ def __init__( num_workers: The number of workers to use in all created DataLoaders val_split_pct: What percentage of the dataset to use as a validation set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/datamodules/xview.py b/torchgeo/datamodules/xview.py index 2548c24851e..95868c8c335 100644 --- a/torchgeo/datamodules/xview.py +++ b/torchgeo/datamodules/xview.py @@ -37,7 +37,7 @@ def __init__( num_workers: The number of workers to use in all created DataLoaders val_split_pct: What percentage of the dataset to use as a validation set """ - super().__init__() # type: ignore[no-untyped-call] + super().__init__() self.root_dir = root_dir self.batch_size = batch_size self.num_workers = num_workers diff --git a/torchgeo/trainers/byol.py b/torchgeo/trainers/byol.py index 395a1caef7d..3fc67278c9e 100644 --- a/torchgeo/trainers/byol.py +++ b/torchgeo/trainers/byol.py @@ -6,6 +6,7 @@ import random from typing import Any, Callable, Dict, Optional, Tuple, cast +import pytorch_lightning as pl import torch import torch.nn.functional as F import torchvision @@ -13,7 +14,6 @@ from kornia import filters from kornia.geometry import transform as KorniaTransform from packaging.version import parse -from pytorch_lightning.core.lightning import LightningModule from torch import Tensor, optim from torch.autograd import Variable from torch.nn.modules import BatchNorm1d, Conv2d, Linear, Module, ReLU, Sequential @@ -304,7 +304,7 @@ def update_target(self) -> None: pt.data = self.beta * pt.data + (1 - self.beta) * p.data -class BYOLTask(LightningModule): +class BYOLTask(pl.LightningModule): """Class for pre-training any PyTorch model using BYOL.""" def config_task(self) -> None: diff --git a/torchgeo/trainers/classification.py b/torchgeo/trainers/classification.py index 804453b31fe..790b648d1ec 100644 --- a/torchgeo/trainers/classification.py +++ b/torchgeo/trainers/classification.py @@ -189,7 +189,7 @@ def validation_step(self, *args: Any, **kwargs: Any) -> None: if batch_idx < 10: try: - datamodule = self.trainer.datamodule # type: ignore[union-attr] + datamodule = self.trainer.datamodule # type: ignore[attr-defined] batch["prediction"] = y_hat_hard for key in ["image", "label", "prediction"]: batch[key] = batch[key].cpu() @@ -358,7 +358,7 @@ def validation_step(self, *args: Any, **kwargs: Any) -> None: if batch_idx < 10: try: - datamodule = self.trainer.datamodule # type: ignore[union-attr] + datamodule = self.trainer.datamodule # type: ignore[attr-defined] batch["prediction"] = y_hat_hard for key in ["image", "label", "prediction"]: batch[key] = batch[key].cpu() diff --git a/torchgeo/trainers/regression.py b/torchgeo/trainers/regression.py index 7f98de7fc8e..869ac1e1640 100644 --- a/torchgeo/trainers/regression.py +++ b/torchgeo/trainers/regression.py @@ -127,7 +127,7 @@ def validation_step(self, *args: Any, **kwargs: Any) -> None: if batch_idx < 10: try: - datamodule = self.trainer.datamodule # type: ignore[union-attr] + datamodule = self.trainer.datamodule # type: ignore[attr-defined] batch["prediction"] = y_hat for key in ["image", "label", "prediction"]: batch[key] = batch[key].cpu() diff --git a/torchgeo/trainers/segmentation.py b/torchgeo/trainers/segmentation.py index 375f5207bc4..f55e08cab3c 100644 --- a/torchgeo/trainers/segmentation.py +++ b/torchgeo/trainers/segmentation.py @@ -6,10 +6,10 @@ import warnings from typing import Any, Dict, cast +import pytorch_lightning as pl import segmentation_models_pytorch as smp import torch import torch.nn as nn -from pytorch_lightning.core.lightning import LightningModule from torch import Tensor from torch.optim.lr_scheduler import ReduceLROnPlateau from torch.utils.data import DataLoader @@ -23,7 +23,7 @@ DataLoader.__module__ = "torch.utils.data" -class SemanticSegmentationTask(LightningModule): +class SemanticSegmentationTask(pl.LightningModule): """LightningModule for semantic segmentation of images.""" def config_task(self) -> None: @@ -184,7 +184,7 @@ def validation_step(self, *args: Any, **kwargs: Any) -> None: if batch_idx < 10: try: - datamodule = self.trainer.datamodule # type: ignore[union-attr] + datamodule = self.trainer.datamodule # type: ignore[attr-defined] batch["prediction"] = y_hat_hard for key in ["image", "mask", "prediction"]: batch[key] = batch[key].cpu()