Skip to content

Commit

Permalink
update tutorial for transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
hfangcat committed Dec 6, 2024
1 parent 3bd85a6 commit d579fe0
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions docs/tutorials/transforms.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
"# Transforms"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_Written by: Adam J. Stewart, Ashwin Nair and Heng Fang_"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -408,7 +415,7 @@
"id": "p28C8cTGE3dP"
},
"source": [
"Transforms are able to operate across batches of samples and singular samples. This allows them to be used inside the dataset itself or externally, chained together with other transform operations using `nn.Sequential`. "
"`torchgeo.transforms` work seamlessly with both singular samples and batches of data. They can be applied within datasets or externally and combined with other transforms using `nn.Sequential`. Built for multispectral imagery, they are fully compatible with `torchvision.transforms` and `kornia.augmentation`."
]
},
{
Expand All @@ -429,13 +436,39 @@
"print(x.dtype, x.min(), x.max())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Appending Indices with `torchgeo.transforms`\n",
"\n",
"`torchgeo.transforms` support appending indices to a specified channel dimension. The following transforms are available:\n",
"\n",
"- **AppendBNDVI**\n",
"- **AppendGBNDVI**\n",
"- **AppendGNDVI**\n",
"- **AppendGRNDVI**\n",
"- **AppendNBR**\n",
"- **AppendNDBI**\n",
"- **AppendNDRE**\n",
"- **AppendNDSI**\n",
"- **AppendNDVI**\n",
"- **AppendNDWI**\n",
"- **AppendNormalizedDifferenceIndex**\n",
"- **AppendRBNDVI**\n",
"- **AppendSWI**\n",
"- **AppendTriBandNormalizedDifferenceIndex**\n",
"\n",
"For detailed usage, refer to the [official documentation](https://torchgeo.readthedocs.io/en/stable/api/transforms.html)."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "KRjb-u0EEmDf"
},
"source": [
"Indices can also be computed on batches of images and appended as an additional band to the specified channel dimension. Notice how the number of channels increases from 13 -> 14."
"The following example shows how indices can be computed on batches of images and appended as an additional band to the specified channel dimension. Notice how the number of channels increases from 13 -> 14."
]
},
{
Expand Down Expand Up @@ -500,7 +533,9 @@
"id": "w4ZbjxPyHoiB"
},
"source": [
"It's even possible to chain indices along with augmentations from Kornia for a single callable during training."
"It's even possible to chain indices along with augmentations from Kornia for a single callable during training.\n",
"\n",
"Check out the documentation of Kornia's augmentations [here](https://kornia.readthedocs.io/en/latest/augmentation.html)."
]
},
{
Expand All @@ -515,6 +550,8 @@
},
"outputs": [],
"source": [
"# When using Kornia with a dictionary input, \n",
"# you must explicitly set data_keys=None during the creation of the augmentation pipeline.\n",
"transforms = K.AugmentationSequential(\n",
" MinMaxNormalize(mins, maxs),\n",
" indices.AppendNDBI(index_swir=11, index_nir=7),\n",
Expand Down Expand Up @@ -717,7 +754,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down

0 comments on commit d579fe0

Please sign in to comment.