Skip to content

Commit

Permalink
update tutorial for pretrained_weights
Browse files Browse the repository at this point in the history
  • Loading branch information
hfangcat committed Dec 6, 2024
1 parent d579fe0 commit 8b00b92
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions docs/tutorials/pretrained_weights.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"source": [
"# Pretrained Weights\n",
"\n",
"_Written by: Adam J. Stewart and Heng Fang_\n",
"\n",
"In this tutorial, we demonstrate some available pretrained weights in TorchGeo. The implementation follows torchvisions' recently introduced [Multi-Weight API](https://pytorch.org/blog/introducing-torchvision-new-multi-weight-support-api/). We will use the [EuroSAT](https://torchgeo.readthedocs.io/en/stable/api/datasets.html#eurosat) dataset throughout this tutorial. Specifically, a subset containing only 100 images.\n",
"\n",
"It's recommended to run this notebook on Google Colab if you don't have your own GPU. Click the \"Open in Colab\" button above to get started."
Expand Down Expand Up @@ -147,9 +149,11 @@
"source": [
"## Weights\n",
"\n",
"Available pretrained weights are listed on the model documentation [page](https://torchgeo.readthedocs.io/en/stable/api/models.html). While some weights only accept RGB channel input, some weights have been pretrained on Sentinel 2 imagery with 13 input channels and can hence prove useful for transfer learning tasks involving Sentinel 2 data.\n",
"Pretrained weights for `torchgeo.models` are available and sorted by satellite or sensor type: sensor-agnostic, Landsat, NAIP, Sentinel-1, and Sentinel-2. Refer to the model documentation page [page](https://torchgeo.readthedocs.io/en/stable/api/models.html#pretrained-weights) for a complete list of weights. Choose from the provided pre-trained weights based on your specific use case.\n",
"\n",
"While some weights only accept RGB channel input, some weights have been pretrained on Sentinel 2 imagery with 13 input channels and can hence prove useful for transfer learning tasks involving Sentinel 2 data.\n",
"\n",
"To access these weights you can do the following:"
"To use these weights, you can load them as follows:"
]
},
{
Expand All @@ -169,7 +173,16 @@
"id": "EIpnXuXgrMOM"
},
"source": [
"This set of weights is a torchvision `WeightEnum` and holds information such as the download url link or additional meta data. TorchGeo takes care of the downloading and initialization of models with a desired set of weights. Given that EuroSAT is a classification dataset, we can use a `ClassificationTask` object that holds the model and optimizer object as well as the training logic."
"This set of weights is a torchvision `WeightEnum` and holds information such as the download url link or additional meta data. TorchGeo takes care of the downloading and initialization of models with a desired set of weights. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`torchgeo.trainers` provides specialized task classes that simplify training workflows for common geospatial tasks. Depending on your objective, you can select the appropriate trainer class, such as `ClassificationTask` for classification, `SegmentationTask` for semantic segmentation, or other task-specific trainers. Check the [documentation](https://torchgeo.readthedocs.io/en/stable/api/trainers.html) for more information.\n",
"\n",
"Given that EuroSAT is a classification dataset, we can use a `ClassificationTask` object that holds the model and optimizer object as well as the training logic."
]
},
{
Expand Down Expand Up @@ -495,7 +508,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.6"
},
"vscode": {
"interpreter": {
Expand Down

0 comments on commit 8b00b92

Please sign in to comment.