Skip to content

Commit

Permalink
docs: update recommended strategy for models with input and output im…
Browse files Browse the repository at this point in the history
…g and msk) (#2293)

* docs: update recommended strategy for models with input and output (img and msk)

Updates in the custom raster dataset tutorial and the actual file documentation. The previous recommended approach (overriding `__get_item__`) is outdated.

Refs: #2292 (reply in thread)

* fix: grammar and formatting

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

* fix: grammar

Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>

---------

Co-authored-by: Mathias Baumgartinger <hiasbaum@gmail.com>
Co-authored-by: Adam J. Stewart <ajstewart426@gmail.com>
  • Loading branch information
3 people committed Oct 10, 2024
1 parent 2bca82d commit e6696d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/tutorials/custom_raster_dataset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,10 @@
"\n",
"If your data only contains model inputs (such as images), use `is_image = True`. If your data only contains ground truth model outputs (such as segmentation masks), use `is_image = False` instead.\n",
"\n",
"Consequently, the sample returned by the dataset/data loader will use the \"image\" key if *is_image* is True, otherwise it will use the \"mask\" key.\n",
"\n",
"For datasets with both model inputs and outputs, the recommended approach is to use 2 `RasterDataset` instances and combine them using an `IntersectionDataset`. See L7 Irish, L8 Biome, and I/O Bench for examples of this in `torchgeo/datasets`.\n",
"\n",
"### `dtype`\n",
"\n",
"Defaults to float32 for `is_image == True` and long for `is_image == False`. This is what you want for 99% of datasets, but can be overridden for tasks like pixel-wise regression (where the target mask should be float32).\n",
Expand Down
4 changes: 2 additions & 2 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ class RasterDataset(GeoDataset):
#: The sample returned by the dataset/data loader will use the "image" key if
#: *is_image* is True, otherwise it will use the "mask" key.
#:
#: For datasets with both model inputs and outputs, a custom
#: :func:`~RasterDataset.__getitem__` method must be implemented.
#: For datasets with both model inputs and outputs, the recommended approach is
#: to use 2 `RasterDataset` instances and combine them using an `IntersectionDataset`.
is_image = True

#: True if data is stored in a separate file for each band, else False.
Expand Down

0 comments on commit e6696d7

Please sign in to comment.