Skip to content

Commit

Permalink
Merge branch 'microsoft:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sfalkena authored Sep 2, 2024
2 parents fedca36 + 370e460 commit 45f1c7e
Show file tree
Hide file tree
Showing 42 changed files with 127 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
changelog:
exclude:
authors:
- dependabot[bot]
- app/dependabot
categories:
- title: Backwards-incompatible changes
labels:
Expand Down
4 changes: 2 additions & 2 deletions docs/api/weights/agnostic.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Weight,Source,Citation,License,Spatial,Temporal,Spectral,m-bigearthnet,m-forestnet,m-brick-kiln,m-pv4ger,m-so2sat,m-eurosat,m-pv4ger-seg,m-nz-cattle,m-NeonTree,m-cashew-plant,m-SA-crop,m-chesapeake
DOFABase16_Weights.DOFA_MAE,`link <https://github.com/zhu-xlab/DOFA>`__,`link <https://arxiv.org/abs/2403.15356>`__,CC-BY-4.0,implicit,-,explicit,63.8,45.3,94.7,96.9,52.1,92.2,94.7,81.6,58.6,48.3,31.3,65.4
DOFALarge16_Weights.DOFA_MAE,`link <https://github.com/zhu-xlab/DOFA>`__,`link <https://arxiv.org/abs/2403.15356>`__,CC-BY-4.0,implicit,-,explicit,64.4,47.4,95.1,97.3,59.3,93.8,95.0,81.7,59.1,53.8,32.1,66.3
DOFABase16_Weights.DOFA_MAE,`link <https://github.com/zhu-xlab/DOFA>`__,`link <https://arxiv.org/abs/2403.15356>`__,CC-BY-4.0,implicit,-,explicit,65.7,50.9,95.8,96.9,55.1,93.9,94.5,81.4,58.8,51.5,33.0,65.3
DOFALarge16_Weights.DOFA_MAE,`link <https://github.com/zhu-xlab/DOFA>`__,`link <https://arxiv.org/abs/2403.15356>`__,CC-BY-4.0,implicit,-,explicit,67.5,54.6,96.9,97.3,60.1,97.1,95.0,81.8,59.4,56.9,32.1,66.3
ResNet50_Weights.FMOW_RGB_GASSL,`link <https://github.com/sustainlab-group/geography-aware-ssl>`__,`link <https://arxiv.org/abs/2011.09980>`__,-,implicit,-,-,,,,,,,,,,,,
ScaleMAE_ViTLarge16_Weights.FMOW_RGB_SCALEMAE,`link <https://github.com/bair-climate-initiative/scale-mae>`__,`link <https://arxiv.org/abs/2212.14532>`__,CC-BY-NC-4.0,explicit,-,-,,,,,,,,,,,
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build']

# Sphinx 3.0+ required for:
# autodoc_typehints_description_target = "documented"
# Sphinx 4.0+ required for autodoc_typehints_description_traget
needs_sphinx = '4.0'

nitpicky = True
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/pretrained_weights.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@
"id": "dWidC6vDrMON"
},
"source": [
"If you do not want to utilize the `ClassificationTask` functionality for your experiments, you can also just create a [timm](https://github.com/rwightman/pytorch-image-models) model with pretrained weights from TorchGeo as follows:"
"If you do not want to utilize the `ClassificationTask` functionality for your experiments, you can also just create a [timm](https://github.com/huggingface/pytorch-image-models) model with pretrained weights from TorchGeo as follows:"
]
},
{
Expand Down
19 changes: 9 additions & 10 deletions docs/user/alternatives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ When deciding which library is most useful to you, it is worth considering the f

Software is a living, breathing organism and is constantly undergoing change. If any of the above information is incorrect or out of date, or if you want to add a new project to this list, please open a PR!

*Last updated: 25 December 2023*
*Last updated: 28 August 2024*

Features
--------
Expand All @@ -22,7 +22,7 @@ Features

.. csv-table::
:align: center
:file: features.csv
:file: metrics/features.csv
:header-rows: 1
:widths: auto

Expand Down Expand Up @@ -55,7 +55,7 @@ These are metrics that can be scraped from GitHub.

.. csv-table::
:align: right
:file: github.csv
:file: metrics/github.csv
:header-rows: 1
:widths: auto

Expand All @@ -75,7 +75,7 @@ These are metrics that can be scraped from GitHub.

**Commits**: The number of commits on the main development branch. This is another metric for how active development has been. However, this can vary a lot depending on whether PRs are merged with or without squashing first.

**Core SLOCs**: The number of source lines of code in the core library, excluding empty lines and comments. This tells you how large the library is, and how long it would take someone to write something like it themselves. We use `scc <https://github.com/boyter/scc>`_ to compute SLOCs.
**Core SLOCs**: The number of source lines of code in the core library, excluding empty lines and comments. This tells you how large the library is, and how long it would take someone to write something like it themselves. We use `scc <https://github.com/boyter/scc>`_ to compute SLOCs and exclude markdown languages from the count.

**Test SLOCs**: The number of source lines of code in the testing suite, excluding empty lines and comments. This tells you how well tested the project is. A good goal to strive for is a similar amount of code for testing as there is in the core library itself.

Expand All @@ -86,17 +86,17 @@ These are metrics that can be scraped from GitHub.
Downloads
---------

These are download metrics for the project. Note that these numbers can be artificially inflated by installs during continuous integration. They give you a better idea of the number of projects that depend on a library than the number of users of that library.
These are download metrics for the project. Note that these numbers can be artificially inflated by mirrors and installs during continuous integration. They give you a better idea of the number of projects that depend on a library than the number of users of that library.

.. csv-table::
:align: right
:file: downloads.csv
:file: metrics/downloads.csv
:header-rows: 1
:widths: auto

**PyPI Downloads**: The number of downloads from the Python Packaging Index. PyPI download metrics are computed by `PePy <https://www.pepy.tech/>`_.
**PyPI Downloads**: The number of downloads from the Python Packaging Index. PyPI download metrics are computed by `PyPI Stats <https://pypistats.org/>`_ and `PePy <https://www.pepy.tech/>`_.

**CRAN Downloads**: The number of downloads from the Comprehensive R Archive Network. CRAN download metrics are computed by `Meta CRAN <https://cranlogs.r-pkg.org/>`_.
**CRAN Downloads**: The number of downloads from the Comprehensive R Archive Network. CRAN download metrics are computed by `Meta CRAN <https://cranlogs.r-pkg.org/>`_ and `DataScienceMeta <https://www.datasciencemeta.com/rpackages>`_.

**Conda Downloads**: The number of downloads from Conda Forge. Conda download metrics are computed by `Conda Forge <https://anaconda.org/conda-forge/>`_.

Expand All @@ -113,5 +113,4 @@ These are download metrics for the project. Note that these numbers can be artif
.. _DeepForest: https://github.com/weecology/DeepForest
.. _SITS: https://github.com/e-sensing/sits
.. _segment-geospatial: https://github.com/opengeos/segment-geospatial
.. _GeoTorchAI: https://github.com/wherobots/GeoTorchAI
.. _Moonshine: https://github.com/moonshinelabs-ai/moonshine
.. _TerraTorch: https://github.com/IBM/terratorch
14 changes: 7 additions & 7 deletions docs/user/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Tests

TorchGeo uses `GitHub Actions <https://docs.github.com/en/actions>`_ for Continuous Integration. We run a suite of unit tests on every commit to ensure that pull requests don't break anything. If you submit a pull request that adds or modifies any Python code, we require unit tests for that code before the pull request can be merged.

For example, if you add a new dataset in ``torchgeo/datasets/foo.py``, you'll need to create corresponding unit tests in ``tests/datasets/test_foo.py``. The easiest way to do this is to find unit tests for similar datasets and modify them for your dataset. These tests can then be run with `pytest <https://docs.pytest.org/>`_:
For example, if you add a new dataset in ``torchgeo/datasets/foo.py``, you'll need to create corresponding unit tests in ``tests/datasets/test_foo.py``. The easiest way to do this is to find unit tests for similar datasets and modify them for your dataset. These tests can then be run with `pytest <https://docs.pytest.org/en/stable/>`_:

.. code-block:: console
Expand All @@ -79,7 +79,7 @@ For example, if you add a new dataset in ``torchgeo/datasets/foo.py``, you'll ne
From this output, you can see that all tests pass, but many lines of code in ``torchgeo/datasets/foo.py`` are not being tested, including 376--403, 429--496, etc. In order for this pull request to be merged, additional tests will need to be added until there is 100% test coverage.

These tests require `pytest <https://docs.pytest.org/>`_ and `pytest-cov <https://pytest-cov.readthedocs.io/>`_ to be installed.
These tests require `pytest <https://docs.pytest.org/en/stable/>`_ and `pytest-cov <https://pytest-cov.readthedocs.io/en/latest/>`_ to be installed.

.. note:: If you add a new dataset, the tests will require some form of data to run. This data should be stored in ``tests/data/<dataset>``. Please don't include real data, as this may violate the license the data is distributed under, and can involve very large file sizes. Instead, create fake data examples using the instructions found `here <https://github.com/microsoft/torchgeo/blob/main/tests/data/README.md>`__.

Expand All @@ -88,18 +88,18 @@ These tests require `pytest <https://docs.pytest.org/>`_ and `pytest-cov <https:
Linters
-------

In order to remain `PEP-8 <https://peps.python.org/pep-0008/>`_ compliant and maintain a high-quality codebase, we use a couple of linting tools:
In order to remain `PEP-8 <https://peps.python.org/pep-0008/>`_ compliant and maintain a high-quality codebase, we use a few linting tools:

* `ruff <https://docs.astral.sh/ruff/>`_ for code formatting
* `mypy <https://mypy.readthedocs.io/>`_ for static type analysis
* `mypy <https://mypy.readthedocs.io/en/stable/>`_ for static type analysis
* `prettier <https://prettier.io/docs/en/>`_ for code formatting

These tools should be used from the root of the project to ensure that our configuration files are found. Ruff is relatively easy to use, and will automatically fix most issues it encounters:

.. code-block:: console
$ ruff check
$ ruff format
$ ruff check
Mypy won't fix your code for you, but will warn you about potential issues with your code:
Expand Down Expand Up @@ -142,7 +142,7 @@ Now, every time you run ``git commit``, pre-commit will run and let you know if
Documentation
-------------

All of our documentation is hosted on `Read the Docs <https://readthedocs.org/>`_. If you make non-trivial changes to the documentation, it helps to build the documentation yourself locally. To do this, make sure the dependencies are installed:
All of our documentation is hosted on `Read the Docs <https://about.readthedocs.com/>`_. If you make non-trivial changes to the documentation, it helps to build the documentation yourself locally. To do this, make sure the dependencies are installed:

.. code-block:: console
Expand All @@ -164,7 +164,7 @@ The resulting HTML files can be found in ``_build/html``. Open ``index.html`` in
Tutorials
---------

TorchGeo has a number of tutorials included in the documentation that can be run in `Google Colab <https://colab.research.google.com/>`_. These Jupyter notebooks are tested before each release to make sure that they still run properly. To test these locally, install `pytest <https://docs.pytest.org/>`_ and `nbmake <https://github.com/treebeardtech/nbmake>`_ and run:
TorchGeo has a number of tutorials included in the documentation that can be run in `Lightning Studios <https://lightning.ai/studios>`_ and `Google Colab <https://colab.research.google.com/>`_. These Jupyter notebooks are tested before each release to make sure that they still run properly. To test these locally, install `pytest <https://docs.pytest.org/en/stable/>`_ and `nbmake <https://github.com/treebeardtech/nbmake>`_ and run:

.. code-block:: console
Expand Down
10 changes: 0 additions & 10 deletions docs/user/downloads.csv

This file was deleted.

10 changes: 0 additions & 10 deletions docs/user/github.csv

This file was deleted.

6 changes: 3 additions & 3 deletions docs/user/installation.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Installation
============

TorchGeo is simple and easy to install. We support installation using the `pip <https://pip.pypa.io/>`_, `conda <https://docs.conda.io/>`_, and `spack <https://spack.io/>`_ package managers.
TorchGeo is simple and easy to install. We support installation using the `pip <https://pip.pypa.io/en/stable/>`_, `conda <https://docs.conda.io/en/latest/>`_, and `spack <https://spack.io/>`_ package managers.

pip
---
Expand Down Expand Up @@ -34,7 +34,7 @@ By default, only required dependencies are installed. TorchGeo has a number of o
$ pip install torchgeo[style,tests]
$ pip install torchgeo[all]
See the ``pyproject.toml`` for a complete list of options. See the `pip documentation <https://pip.pypa.io/>`_ for more details.
See the ``pyproject.toml`` for a complete list of options. See the `pip documentation <https://pip.pypa.io/en/stable/>`_ for more details.

conda
-----
Expand Down Expand Up @@ -82,4 +82,4 @@ Optional dependencies can be installed by enabling build variants:
$ spack install py-torchgeo+datasets
$ spack install py-torchgeo+style+tests
Run ``spack info py-torchgeo`` for a complete list of variants. See the `spack documentation <https://spack.readthedocs.io/>`_ for more details.
Run ``spack info py-torchgeo`` for a complete list of variants. See the `spack documentation <https://spack.readthedocs.io/en/latest/>`_ for more details.
9 changes: 9 additions & 0 deletions docs/user/metrics/downloads.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Library,PyPI/CRAN Last Week,PyPI/CRAN Last Month,PyPI/CRAN All Time,Conda All Time,Total All Time
`TorchGeo`_,"1,828","9,789","255,293","21,108","276,401"
`eo-learn`_,319,"1,560","141,983","36,205","178,188"
`Raster Vision`_,138,"652","61,938","3,254","65,192"
`PaddleRS`_,10,36,"1,642",0,"1,642"
`segment-geospatial`_,"1,553","7,363","117,664","18,147","135,811"
`DeepForest`_,564,"3,652","761,520","62,869","824,389"
`SITS`_,304,648,"12,767","78,976","91,743"
`TerraTorch`_,259,988,"2,378",0,"2,378"
9 changes: 4 additions & 5 deletions docs/user/features.csv → docs/user/metrics/features.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Library,ML Backend,I/O Backend,Spatial Backend,Transform Backend,Datasets,Weights,CLI,Reprojection,STAC,Time-Series
`TorchGeo`_,PyTorch,"GDAL, h5py, laspy, OpenCV, pandas, pillow, scipy",R-tree,Kornia,71,43,✅,✅,❌,🚧
`TorchGeo`_,PyTorch,"GDAL, h5py, laspy, OpenCV, pandas, pillow, scipy",R-tree,Kornia,82,68,✅,✅,❌,🚧
`eo-learn`_,scikit-learn,"GDAL, OpenCV, pandas",geopandas,numpy,0,0,❌,✅,❌,🚧
`Raster Vision`_,"PyTorch, TensorFlow*","GDAL, OpenCV, pandas, pillow, scipy, xarray",STAC,Albumentations,0,6,✅,✅,✅,✅
`PaddleRS`_,PaddlePaddle,"GDAL, OpenCV",shapely,numpy,7,14,🚧,✅,❌,🚧
`DeepForest`_,PyTorch,"GDAL, OpenCV, pandas, pillow, scipy",R-tree,Albumentations,0,2,❌,❌,❌,❌
`SITS`_,R Torch,GDAL,-,tidyverse,22,0,❌,✅,✅,✅
`segment-geospatial`_,PyTorch,"GDAL, OpenCV, pandas",geopandas,numpy,0,0,❌,✅,❌,❌
`GeoTorchAI`_,PyTorch,"GDAL, pandas, xarray",Sedona,numpy,14,0,❌,❌,❌,🚧
`Moonshine`_,PyTorch,-,-,numpy,0,3,❌,❌,❌,❌
`DeepForest`_,PyTorch,"GDAL, OpenCV, pandas, pillow, scipy",R-tree,Albumentations,0,3,❌,❌,❌,❌
`SITS`_,R Torch,GDAL,-,tidyverse,22,0,❌,✅,✅,✅
`TerraTorch`_,PyTorch,"GDAL, h5py, pandas, xarray",R-tree,Albumentations,16,1,✅,✅,❌,🚧
9 changes: 9 additions & 0 deletions docs/user/metrics/github.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Library,Contributors,Forks,Watchers,Stars,Issues,PRs,Releases,Commits,Core SLOCs,Test SLOCs,Test Coverage,License
`TorchGeo`_,72,308,44,"2,409",419,"1,714",11,"2,074","30,761","16,058",100%,MIT
`eo-learn`_,40,300,46,"1,108",159,638,44,"2,470","8,207","5,932",92%,MIT
`Raster Vision`_,32,381,71,"2,046",697,"1,382",22,"3,614","22,779","9,429",90%,Apache-2.0
`PaddleRS`_,23,89,13,374,91,116,3,644,"21,859","3,384",48%,Apache-2.0
`segment-geospatial`_,17,281,55,"2,834",129,104,27,186,"5,598",92,22%,MIT
`DeepForest`_,17,172,17,474,413,301,44,864,"3,357","1,794",86%,MIT
`SITS`_,14,76,28,451,622,583,44,"6,244","24,284","8,697",94%,GPL-2.0
`TerraTorch`_,9,10,9,121,46,92,2,243,"10,101",583,44%,Apache-2.0
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ docs = [
"nbsphinx>=0.8.5",
# release versions missing files, must install from master
"pytorch-sphinx-theme",
# sphinx 4+ required for autodoc_typehints_description_target = documented
# sphinx 4+ required for autodoc_typehints_description_target
# sphinx 6+ is incompatible with pytorch-sphinx-theme
# https://github.com/pytorch/pytorch_sphinx_theme/issues/175
"sphinx>=4,<6",
Expand Down Expand Up @@ -189,7 +189,7 @@ filterwarnings = [
# https://github.com/pytorch/vision/pull/5898
"ignore:.* is deprecated and will be removed in Pillow 10:DeprecationWarning:torchvision.transforms.functional_pil",
"ignore:.* is deprecated and will be removed in Pillow 10:DeprecationWarning:torchvision.transforms._functional_pil",
# https://github.com/rwightman/pytorch-image-models/pull/1256
# https://github.com/huggingface/pytorch-image-models/pull/1256
"ignore:.* is deprecated and will be removed in Pillow 10:DeprecationWarning:timm.data",
# https://github.com/pytorch/pytorch/issues/72906
# https://github.com/pytorch/pytorch/pull/69823
Expand Down Expand Up @@ -226,12 +226,15 @@ filterwarnings = [
"ignore:Deprecated call to `pkg_resources.declare_namespace:DeprecationWarning",
"ignore:pkg_resources is deprecated as an API.:DeprecationWarning:lightning_utilities.core.imports",
"ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated:DeprecationWarning:jsonargparse",
"ignore:`ModuleAvailableCache` is a special case of `RequirementCache`.:DeprecationWarning:lightning.fabric.plugins.environments.xla",
# https://github.com/pytorch/pytorch/issues/110549
"ignore:allow_ops_in_compiled_graph failed to import torch:ImportWarning:einops",
# https://github.com/rr-/docstring_parser/pull/82
"ignore:ast.* is deprecated and will be removed in Python 3.14:DeprecationWarning:docstring_parser.attrdoc",
# https://github.com/python/cpython/pull/102953
"ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchgeo.datasets.utils",
"ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchgeo.datasets.digital_typhoon",
"ignore:Python 3.14 will, by default, filter extracted tar archives and reject files or modify their metadata:DeprecationWarning:torchvision.datasets.utils",
# https://github.com/kornia/kornia/pull/2967
"ignore:`torch.cuda.amp.custom_fwd\\(args...\\)` is deprecated.:FutureWarning:kornia.feature.lightglue",
# https://github.com/kornia/kornia/pull/2981
Expand Down
2 changes: 1 addition & 1 deletion requirements/style.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# style
mypy==1.11.2
ruff==0.6.2
ruff==0.6.3
6 changes: 6 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.

from pathlib import Path
from typing import Any

import pytest
Expand All @@ -16,3 +17,8 @@ def load(*args: Any, progress: bool = False, **kwargs: Any) -> Any:
@pytest.fixture
def load_state_dict_from_url(monkeypatch: MonkeyPatch) -> None:
monkeypatch.setattr(torchvision.models._api, 'load_state_dict_from_url', load)


@pytest.fixture(autouse=True)
def torch_hub(tmp_path: Path) -> None:
torch.hub.set_dir(tmp_path) # type: ignore[no-untyped-call]
Loading

0 comments on commit 45f1c7e

Please sign in to comment.