-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move DataModules to torchgeo.datamodules (#321)
* Move DataModules to torchgeo.datamodules * Clean up local imports
- Loading branch information
1 parent
5a57d6c
commit cbebc1e
Showing
100 changed files
with
3,978 additions
and
3,500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
torchgeo.datamodules | ||
==================== | ||
|
||
.. module:: torchgeo.datamodules | ||
|
||
Geospatial DataModules | ||
---------------------- | ||
|
||
Chesapeake Bay High-Resolution Land Cover Project | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: ChesapeakeCVPRDataModule | ||
|
||
National Agriculture Imagery Program (NAIP) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: NAIPChesapeakeDataModule | ||
|
||
Non-geospatial DataModules | ||
-------------------------- | ||
|
||
BigEarthNet | ||
^^^^^^^^^^^ | ||
|
||
.. autoclass:: BigEarthNetDataModule | ||
|
||
Cars Overhead With Context (COWC) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: COWCCountingDataModule | ||
|
||
ETCI2021 Flood Detection | ||
^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: ETCI2021DataModule | ||
|
||
EuroSAT | ||
^^^^^^^ | ||
|
||
.. autoclass:: EuroSATDataModule | ||
|
||
FAIR1M (Fine-grAined object recognItion in high-Resolution imagery) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: FAIR1MDataModule | ||
|
||
LandCover.ai (Land Cover from Aerial Imagery) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: LandCoverAIDataModule | ||
|
||
LoveDA (Land-cOVEr Domain Adaptive semantic segmentation) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: LoveDADataModule | ||
|
||
NASA Marine Debris | ||
^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: NASAMarineDebrisDataModule | ||
|
||
OSCD (Onera Satellite Change Detection) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: OSCDDataModule | ||
|
||
Potsdam | ||
^^^^^^^ | ||
|
||
.. autoclass:: Potsdam2DDataModule | ||
|
||
RESISC45 (Remote Sensing Image Scene Classification) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: RESISC45DataModule | ||
|
||
SEN12MS | ||
^^^^^^^ | ||
|
||
.. autoclass:: SEN12MSDataModule | ||
|
||
So2Sat | ||
^^^^^^ | ||
|
||
.. autoclass:: So2SatDataModule | ||
|
||
Tropical Cyclone Wind Estimation Competition | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
.. autoclass:: CycloneDataModule | ||
|
||
UC Merced | ||
^^^^^^^^^ | ||
|
||
.. autoclass:: UCMercedDataModule | ||
|
||
Vaihingen | ||
^^^^^^^^^ | ||
|
||
.. autoclass:: Vaihingen2DDataModule | ||
|
||
xView2 | ||
^^^^^^ | ||
|
||
.. autoclass:: XView2DataModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import os | ||
|
||
import pytest | ||
from _pytest.fixtures import SubRequest | ||
|
||
from torchgeo.datamodules import BigEarthNetDataModule | ||
|
||
|
||
class TestBigEarthNetDataModule: | ||
@pytest.fixture(scope="class", params=["s1", "s2", "all"]) | ||
def datamodule(self, request: SubRequest) -> BigEarthNetDataModule: | ||
bands = request.param | ||
root = os.path.join("tests", "data", "bigearthnet") | ||
num_classes = 19 | ||
batch_size = 1 | ||
num_workers = 0 | ||
dm = BigEarthNetDataModule(root, bands, num_classes, batch_size, num_workers) | ||
dm.prepare_data() | ||
dm.setup() | ||
return dm | ||
|
||
def test_train_dataloader(self, datamodule: BigEarthNetDataModule) -> None: | ||
next(iter(datamodule.train_dataloader())) | ||
|
||
def test_val_dataloader(self, datamodule: BigEarthNetDataModule) -> None: | ||
next(iter(datamodule.val_dataloader())) | ||
|
||
def test_test_dataloader(self, datamodule: BigEarthNetDataModule) -> None: | ||
next(iter(datamodule.test_dataloader())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import os | ||
|
||
import pytest | ||
import torch | ||
from _pytest.fixtures import SubRequest | ||
|
||
from torchgeo.datamodules import ChesapeakeCVPRDataModule | ||
|
||
|
||
class TestChesapeakeCVPRDataModule: | ||
@pytest.fixture(scope="class", params=[5, 7]) | ||
def datamodule(self, request: SubRequest) -> ChesapeakeCVPRDataModule: | ||
dm = ChesapeakeCVPRDataModule( | ||
os.path.join("tests", "data", "chesapeake", "cvpr"), | ||
["de-test"], | ||
["de-test"], | ||
["de-test"], | ||
patch_size=32, | ||
patches_per_tile=2, | ||
batch_size=2, | ||
num_workers=0, | ||
class_set=request.param, | ||
) | ||
dm.prepare_data() | ||
dm.setup() | ||
return dm | ||
|
||
def test_train_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: | ||
next(iter(datamodule.train_dataloader())) | ||
|
||
def test_val_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: | ||
next(iter(datamodule.val_dataloader())) | ||
|
||
def test_test_dataloader(self, datamodule: ChesapeakeCVPRDataModule) -> None: | ||
next(iter(datamodule.test_dataloader())) | ||
|
||
def test_nodata_check(self, datamodule: ChesapeakeCVPRDataModule) -> None: | ||
nodata_check = datamodule.nodata_check(4) | ||
sample = { | ||
"image": torch.ones(1, 2, 2), # type: ignore[attr-defined] | ||
"mask": torch.ones(2, 2), # type: ignore[attr-defined] | ||
} | ||
out = nodata_check(sample) | ||
assert torch.equal( # type: ignore[attr-defined] | ||
out["image"], torch.zeros(1, 4, 4) # type: ignore[attr-defined] | ||
) | ||
assert torch.equal( # type: ignore[attr-defined] | ||
out["mask"], torch.zeros(4, 4) # type: ignore[attr-defined] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import os | ||
|
||
import pytest | ||
|
||
from torchgeo.datamodules import COWCCountingDataModule | ||
|
||
|
||
class TestCOWCCountingDataModule: | ||
@pytest.fixture(scope="class") | ||
def datamodule(self) -> COWCCountingDataModule: | ||
root = os.path.join("tests", "data", "cowc_counting") | ||
seed = 0 | ||
batch_size = 1 | ||
num_workers = 0 | ||
dm = COWCCountingDataModule(root, seed, batch_size, num_workers) | ||
dm.prepare_data() | ||
dm.setup() | ||
return dm | ||
|
||
def test_train_dataloader(self, datamodule: COWCCountingDataModule) -> None: | ||
next(iter(datamodule.train_dataloader())) | ||
|
||
def test_val_dataloader(self, datamodule: COWCCountingDataModule) -> None: | ||
next(iter(datamodule.val_dataloader())) | ||
|
||
def test_test_dataloader(self, datamodule: COWCCountingDataModule) -> None: | ||
next(iter(datamodule.test_dataloader())) |
Oops, something went wrong.