TorchGeo: datasets, samplers, transforms, and pre-trained models for geospatial data
Перейти к файлу
Maciej Kilian 6f23fa42c5
OSCDDataModule: add random crop augmentation (#257)
* OSCDDataModule: add random crop augmentation

* typing: use sequence instead of tuple

* use RandomCrop

* Use kornia instead

* add description of crop_size

* Only RandomCrop train and val set, not test set

* black fix

* working random_crops

* Resizing dummy test data to 3x3 so we can test RandomCrop Augmentations

* assert crops are proper size

* not working yet but some progress

* issue with amount of slices

* forgot to set val and test batch_size to 1

* some style fixes

* setting the dataset.transforms attribute doesn't work unless you do it in __init__ for now val_dataset must have random crop

* nevermind we don't need this

* style fixes + do we need mask to be torch.long?

* einops

* unsure why this doesn't work

* dataset.transforms

* mypy fix

* hacky flake8 fix

* non-hacky flake8 fix

* mypy fix

* adjust val test size

* passing tests

* mypy fix

* adding n_random_crops

* adjust param in testing

* working collate_fn but breaks mypy

* flattening (2, 13) into 26

* fix mypy

* style fixes

* add testing for new shapes

* Adjusting DataModule docstring

* remove clamp since we are standardizing

* name change to train_batch_size

* splitting crop-size into patch_size and num_patches_per_tile
2021-12-01 23:34:33 -08:00
.github/workflows GitHub Actions: use Agg backend for matplotlib (#261) 2021-11-25 11:05:29 -06:00
conf Adding eval script (#244) 2021-11-14 21:32:44 -08:00
docs Add SpaceNet5 (#263) 2021-11-29 11:39:54 -08:00
experiments Trainers: split tasks into separate files, add SemanticSegmentationTask (#224) 2021-11-06 23:57:40 -05:00
logo Add favicon to ReadTheDocs 2021-09-08 16:08:04 -05:00
tests OSCDDataModule: add random crop augmentation (#257) 2021-12-01 23:34:33 -08:00
torchgeo OSCDDataModule: add random crop augmentation (#257) 2021-12-01 23:34:33 -08:00
.codecov.yml Remove Codecov annotations from PRs 2021-09-19 11:07:39 -05:00
.flake8 Removing some headers 2021-08-31 13:25:05 -05:00
.gitattributes Removing some headers 2021-08-31 13:25:05 -05:00
.gitignore Ignore PDF figures 2021-10-09 11:58:19 -05:00
.pre-commit-config.yaml black: skip magic trailing comma 2021-10-26 16:26:58 -05:00
.readthedocs.yaml Reduce number of files listing deps (#154) 2021-09-22 09:41:00 -05:00
CITATION.cff Use bibtex format auto-generated by GitHub 2021-11-17 22:39:54 -06:00
CODE_OF_CONDUCT.md Add Microsoft open-source template 2021-05-21 11:35:58 -05:00
LICENSE Add Microsoft open-source template 2021-05-21 11:35:58 -05:00
README.md Use bibtex format auto-generated by GitHub 2021-11-17 22:39:54 -06:00
SECURITY.md Add Microsoft open-source template 2021-05-21 11:35:58 -05:00
SUPPORT.md Add Microsoft open-source template 2021-05-21 11:35:58 -05:00
benchmark.py black: skip magic trailing comma 2021-10-26 16:26:58 -05:00
environment.yml 0.1.0 release (#226) 2021-11-07 22:05:58 -06:00
evaluate.py Adding eval script (#244) 2021-11-14 21:32:44 -08:00
pyproject.toml black: always skip magic trailing commas 2021-11-13 13:56:29 -06:00
setup.cfg Fix #230 (#249) 2021-11-16 11:24:10 -06:00
setup.py File permissions? 2021-08-31 13:25:05 -05:00
train.py Adding eval script (#244) 2021-11-14 21:32:44 -08:00

README.md

TorchGeo

TorchGeo is a PyTorch domain library, similar to torchvision, that provides datasets, transforms, samplers, and pre-trained models specific to geospatial data.

The goal of this library is to make it simple:

  1. for machine learning experts to use geospatial data in their workflows, and
  2. for remote sensing experts to use their data in machine learning workflows.

See our installation instructions, documentation, and examples to learn how to use torchgeo.

External links: docs codecov pypi conda spack

Tests: docs style tests

Installation instructions

The recommended way to install TorchGeo is with pip:

$ pip install torchgeo

For conda and spack installation instructions, see the documentation.

Documentation

You can find the documentation for torchgeo on ReadTheDocs.

Example usage

The following sections give basic examples of what you can do with torchgeo. For more examples, check out our tutorials.

Train and test models using our PyTorch Lightning based training script

We provide a script, train.py for training models using a subset of the datasets. We do this with the PyTorch Lightning LightningModules and LightningDataModules implemented under the torchgeo.trainers namespace. The train.py script is configurable via the command line and/or via YAML configuration files. See the conf/ directory for example configuration files that can be customized for different training runs.

$ python train.py config_file=conf/landcoverai.yaml

Download and use the Tropical Cyclone Wind Estimation Competition dataset

This dataset is from a competition hosted by Driven Data in collaboration with Radiant Earth. See here for more information.

Using this dataset in torchgeo is as simple as importing and instantiating the appropriate class.

import torchgeo.datasets

dataset = torchgeo.datasets.TropicalCycloneWindEstimation(split="train", download=True)
print(dataset[0]["image"].shape)
print(dataset[0]["label"])

Citation

If you use this software in your work, please cite our paper:

@article{Stewart_TorchGeo_deep_learning_2021,
    author = {Stewart, Adam J. and Robinson, Caleb and Corley, Isaac A. and Ortiz, Anthony and Lavista Ferres, Juan M. and Banerjee, Arindam},
    journal = {arXiv preprint arXiv:2111.08872},
    month = {11},
    title = {{TorchGeo: deep learning with geospatial data}},
    url = {https://github.com/microsoft/torchgeo},
    year = {2021}
}

Contributing

This project welcomes contributions and suggestions. If you would like to submit a pull request, see our Contribution Guide for more information.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.