From 8f31d522d07b4ffdcdce8dcb03ebe830d9ab44ba Mon Sep 17 00:00:00 2001 From: Ashwin Nair Date: Mon, 29 Jul 2024 20:50:37 +0400 Subject: [PATCH 1/3] Rename bbox -> geo_bbox --- tests/data/western_usa_live_fuel_moisture/data.py | 2 +- tests/datamodules/test_geo.py | 2 +- torchgeo/datamodules/geo.py | 2 +- torchgeo/datasets/agrifieldnet.py | 2 +- torchgeo/datasets/chesapeake.py | 2 +- torchgeo/datasets/eddmaps.py | 2 +- torchgeo/datasets/enviroatlas.py | 2 +- torchgeo/datasets/gbif.py | 2 +- torchgeo/datasets/geo.py | 4 ++-- torchgeo/datasets/globbiomass.py | 2 +- torchgeo/datasets/inaturalist.py | 2 +- torchgeo/datasets/landcoverai.py | 2 +- torchgeo/datasets/openbuildings.py | 2 +- torchgeo/datasets/south_africa_crop_type.py | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/data/western_usa_live_fuel_moisture/data.py b/tests/data/western_usa_live_fuel_moisture/data.py index 44fc8717b47..5faff05400c 100755 --- a/tests/data/western_usa_live_fuel_moisture/data.py +++ b/tests/data/western_usa_live_fuel_moisture/data.py @@ -172,7 +172,7 @@ 'type': 'text/csv', }, }, - 'bbox': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], + 'geo_bbox': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], 'collection': 'su_sar_moisture_content', 'geometry': {'coordinates': [-115.8855556, 42.44111111], 'type': 'Point'}, 'id': 'su_sar_moisture_content_0001', diff --git a/tests/datamodules/test_geo.py b/tests/datamodules/test_geo.py index 8380ce242b8..a12eacf2e07 100644 --- a/tests/datamodules/test_geo.py +++ b/tests/datamodules/test_geo.py @@ -32,7 +32,7 @@ def __init__( def __getitem__(self, query: BoundingBox) -> dict[str, Any]: image = torch.arange(3 * 2 * 2).view(3, 2, 2) - return {'image': image, 'crs': CRS.from_epsg(4326), 'bbox': query} + return {'image': image, 'crs': CRS.from_epsg(4326), 'geo_bbox': query} def plot(self, *args: Any, **kwargs: Any) -> Figure: return plt.figure() diff --git a/torchgeo/datamodules/geo.py b/torchgeo/datamodules/geo.py index 5f77c0c4d6b..3be991d2508 100644 --- a/torchgeo/datamodules/geo.py +++ b/torchgeo/datamodules/geo.py @@ -353,7 +353,7 @@ def transfer_batch_to_device( """ # Non-Tensor values cannot be moved to a device del batch['crs'] - del batch['bbox'] + del batch['geo_bbox'] batch = super().transfer_batch_to_device(batch, device, dataloader_idx) return batch diff --git a/torchgeo/datasets/agrifieldnet.py b/torchgeo/datasets/agrifieldnet.py index 51d84ca242a..74f25b24e3b 100644 --- a/torchgeo/datasets/agrifieldnet.py +++ b/torchgeo/datasets/agrifieldnet.py @@ -221,7 +221,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: sample = { 'crs': self.crs, - 'bbox': query, + 'geo_bbox': query, 'image': image.float(), 'mask': mask.long(), } diff --git a/torchgeo/datasets/chesapeake.py b/torchgeo/datasets/chesapeake.py index 00b415e0959..50286ae170f 100644 --- a/torchgeo/datasets/chesapeake.py +++ b/torchgeo/datasets/chesapeake.py @@ -607,7 +607,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: hits = self.index.intersection(tuple(query), objects=True) filepaths = cast(list[dict[str, str]], [hit.object for hit in hits]) - sample = {'image': [], 'mask': [], 'crs': self.crs, 'bbox': query} + sample = {'image': [], 'mask': [], 'crs': self.crs, 'geo_bbox': query} if len(filepaths) == 0: raise IndexError( diff --git a/torchgeo/datasets/eddmaps.py b/torchgeo/datasets/eddmaps.py index 5f6fb267751..660c72e1c3f 100644 --- a/torchgeo/datasets/eddmaps.py +++ b/torchgeo/datasets/eddmaps.py @@ -100,6 +100,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'bbox': bboxes} + sample = {'crs': self.crs, 'geo_bbox': bboxes} return sample diff --git a/torchgeo/datasets/enviroatlas.py b/torchgeo/datasets/enviroatlas.py index 9b22d80c03e..a116981ea07 100644 --- a/torchgeo/datasets/enviroatlas.py +++ b/torchgeo/datasets/enviroatlas.py @@ -347,7 +347,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: hits = self.index.intersection(tuple(query), objects=True) filepaths = cast(list[dict[str, str]], [hit.object for hit in hits]) - sample = {'image': [], 'mask': [], 'crs': self.crs, 'bbox': query} + sample = {'image': [], 'mask': [], 'crs': self.crs, 'geo_bbox': query} if len(filepaths) == 0: raise IndexError( diff --git a/torchgeo/datasets/gbif.py b/torchgeo/datasets/gbif.py index 3e6f078faa4..2ff3e62529e 100644 --- a/torchgeo/datasets/gbif.py +++ b/torchgeo/datasets/gbif.py @@ -137,6 +137,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'bbox': bboxes} + sample = {'crs': self.crs, 'geo_bbox': bboxes} return sample diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py index 57718fcb4c8..e02790449f7 100644 --- a/torchgeo/datasets/geo.py +++ b/torchgeo/datasets/geo.py @@ -546,7 +546,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: else: data = self._merge_files(filepaths, query, self.band_indexes) - sample = {'crs': self.crs, 'bbox': query} + sample = {'crs': self.crs, 'geo_bbox': query} data = data.to(self.dtype) if self.is_image: @@ -776,7 +776,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: masks = array_to_tensor(masks) masks = masks.to(self.dtype) - sample = {'mask': masks, 'crs': self.crs, 'bbox': query} + sample = {'mask': masks, 'crs': self.crs, 'geo_bbox': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/globbiomass.py b/torchgeo/datasets/globbiomass.py index fc15e918dbd..f3d53dfc1cb 100644 --- a/torchgeo/datasets/globbiomass.py +++ b/torchgeo/datasets/globbiomass.py @@ -207,7 +207,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: mask = torch.cat((mask, std_err_mask), dim=0) - sample = {'mask': mask, 'crs': self.crs, 'bbox': query} + sample = {'mask': mask, 'crs': self.crs, 'geo_bbox': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/inaturalist.py b/torchgeo/datasets/inaturalist.py index 06aa3e6185f..1ca8cd5d092 100644 --- a/torchgeo/datasets/inaturalist.py +++ b/torchgeo/datasets/inaturalist.py @@ -107,6 +107,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'bbox': bboxes} + sample = {'crs': self.crs, 'geo_bbox': bboxes} return sample diff --git a/torchgeo/datasets/landcoverai.py b/torchgeo/datasets/landcoverai.py index e6bdd34d1c9..957dc3c17d9 100644 --- a/torchgeo/datasets/landcoverai.py +++ b/torchgeo/datasets/landcoverai.py @@ -268,7 +268,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: mask = self._merge_files(mask_filepaths, query, self.band_indexes) sample = { 'crs': self.crs, - 'bbox': query, + 'geo_bbox': query, 'image': img.float(), 'mask': mask.long(), } diff --git a/torchgeo/datasets/openbuildings.py b/torchgeo/datasets/openbuildings.py index f3500f35733..b983a61f546 100644 --- a/torchgeo/datasets/openbuildings.py +++ b/torchgeo/datasets/openbuildings.py @@ -328,7 +328,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: else: masks = torch.zeros(size=(1, round(height), round(width))) - sample = {'mask': masks, 'crs': self.crs, 'bbox': query} + sample = {'mask': masks, 'crs': self.crs, 'geo_bbox': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/south_africa_crop_type.py b/torchgeo/datasets/south_africa_crop_type.py index 947b4bb98d8..e034b781613 100644 --- a/torchgeo/datasets/south_africa_crop_type.py +++ b/torchgeo/datasets/south_africa_crop_type.py @@ -228,7 +228,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: sample = { 'crs': self.crs, - 'bbox': query, + 'geo_bbox': query, 'image': image.float(), 'mask': mask.long(), } From 33b44936c9ac25ee18faa6cde85c7cc26a2b439c Mon Sep 17 00:00:00 2001 From: Ashwin Nair Date: Mon, 29 Jul 2024 22:09:12 +0400 Subject: [PATCH 2/3] Rename to bounds --- tests/data/western_usa_live_fuel_moisture/data.py | 2 +- tests/datamodules/test_geo.py | 2 +- torchgeo/datamodules/geo.py | 2 +- torchgeo/datasets/agrifieldnet.py | 2 +- torchgeo/datasets/chesapeake.py | 2 +- torchgeo/datasets/eddmaps.py | 2 +- torchgeo/datasets/enviroatlas.py | 2 +- torchgeo/datasets/gbif.py | 2 +- torchgeo/datasets/geo.py | 4 ++-- torchgeo/datasets/globbiomass.py | 2 +- torchgeo/datasets/inaturalist.py | 2 +- torchgeo/datasets/landcoverai.py | 2 +- torchgeo/datasets/openbuildings.py | 2 +- torchgeo/datasets/south_africa_crop_type.py | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/data/western_usa_live_fuel_moisture/data.py b/tests/data/western_usa_live_fuel_moisture/data.py index 5faff05400c..7d81bd3bc11 100755 --- a/tests/data/western_usa_live_fuel_moisture/data.py +++ b/tests/data/western_usa_live_fuel_moisture/data.py @@ -172,7 +172,7 @@ 'type': 'text/csv', }, }, - 'geo_bbox': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], + 'bounds': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], 'collection': 'su_sar_moisture_content', 'geometry': {'coordinates': [-115.8855556, 42.44111111], 'type': 'Point'}, 'id': 'su_sar_moisture_content_0001', diff --git a/tests/datamodules/test_geo.py b/tests/datamodules/test_geo.py index a12eacf2e07..8e5fd13d292 100644 --- a/tests/datamodules/test_geo.py +++ b/tests/datamodules/test_geo.py @@ -32,7 +32,7 @@ def __init__( def __getitem__(self, query: BoundingBox) -> dict[str, Any]: image = torch.arange(3 * 2 * 2).view(3, 2, 2) - return {'image': image, 'crs': CRS.from_epsg(4326), 'geo_bbox': query} + return {'image': image, 'crs': CRS.from_epsg(4326), 'bounds': query} def plot(self, *args: Any, **kwargs: Any) -> Figure: return plt.figure() diff --git a/torchgeo/datamodules/geo.py b/torchgeo/datamodules/geo.py index 3be991d2508..5f5ae76b939 100644 --- a/torchgeo/datamodules/geo.py +++ b/torchgeo/datamodules/geo.py @@ -353,7 +353,7 @@ def transfer_batch_to_device( """ # Non-Tensor values cannot be moved to a device del batch['crs'] - del batch['geo_bbox'] + del batch['bounds'] batch = super().transfer_batch_to_device(batch, device, dataloader_idx) return batch diff --git a/torchgeo/datasets/agrifieldnet.py b/torchgeo/datasets/agrifieldnet.py index 74f25b24e3b..c1eae6de222 100644 --- a/torchgeo/datasets/agrifieldnet.py +++ b/torchgeo/datasets/agrifieldnet.py @@ -221,7 +221,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: sample = { 'crs': self.crs, - 'geo_bbox': query, + 'bounds': query, 'image': image.float(), 'mask': mask.long(), } diff --git a/torchgeo/datasets/chesapeake.py b/torchgeo/datasets/chesapeake.py index 50286ae170f..86d75f6276b 100644 --- a/torchgeo/datasets/chesapeake.py +++ b/torchgeo/datasets/chesapeake.py @@ -607,7 +607,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: hits = self.index.intersection(tuple(query), objects=True) filepaths = cast(list[dict[str, str]], [hit.object for hit in hits]) - sample = {'image': [], 'mask': [], 'crs': self.crs, 'geo_bbox': query} + sample = {'image': [], 'mask': [], 'crs': self.crs, 'bounds': query} if len(filepaths) == 0: raise IndexError( diff --git a/torchgeo/datasets/eddmaps.py b/torchgeo/datasets/eddmaps.py index 660c72e1c3f..d3a046993a1 100644 --- a/torchgeo/datasets/eddmaps.py +++ b/torchgeo/datasets/eddmaps.py @@ -100,6 +100,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'geo_bbox': bboxes} + sample = {'crs': self.crs, 'bounds': bboxes} return sample diff --git a/torchgeo/datasets/enviroatlas.py b/torchgeo/datasets/enviroatlas.py index a116981ea07..1d71a8940e6 100644 --- a/torchgeo/datasets/enviroatlas.py +++ b/torchgeo/datasets/enviroatlas.py @@ -347,7 +347,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: hits = self.index.intersection(tuple(query), objects=True) filepaths = cast(list[dict[str, str]], [hit.object for hit in hits]) - sample = {'image': [], 'mask': [], 'crs': self.crs, 'geo_bbox': query} + sample = {'image': [], 'mask': [], 'crs': self.crs, 'bounds': query} if len(filepaths) == 0: raise IndexError( diff --git a/torchgeo/datasets/gbif.py b/torchgeo/datasets/gbif.py index 2ff3e62529e..3e8cfb6c883 100644 --- a/torchgeo/datasets/gbif.py +++ b/torchgeo/datasets/gbif.py @@ -137,6 +137,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'geo_bbox': bboxes} + sample = {'crs': self.crs, 'bounds': bboxes} return sample diff --git a/torchgeo/datasets/geo.py b/torchgeo/datasets/geo.py index e02790449f7..8a679c1688e 100644 --- a/torchgeo/datasets/geo.py +++ b/torchgeo/datasets/geo.py @@ -546,7 +546,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: else: data = self._merge_files(filepaths, query, self.band_indexes) - sample = {'crs': self.crs, 'geo_bbox': query} + sample = {'crs': self.crs, 'bounds': query} data = data.to(self.dtype) if self.is_image: @@ -776,7 +776,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: masks = array_to_tensor(masks) masks = masks.to(self.dtype) - sample = {'mask': masks, 'crs': self.crs, 'geo_bbox': query} + sample = {'mask': masks, 'crs': self.crs, 'bounds': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/globbiomass.py b/torchgeo/datasets/globbiomass.py index f3d53dfc1cb..007466738d2 100644 --- a/torchgeo/datasets/globbiomass.py +++ b/torchgeo/datasets/globbiomass.py @@ -207,7 +207,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: mask = torch.cat((mask, std_err_mask), dim=0) - sample = {'mask': mask, 'crs': self.crs, 'geo_bbox': query} + sample = {'mask': mask, 'crs': self.crs, 'bounds': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/inaturalist.py b/torchgeo/datasets/inaturalist.py index 1ca8cd5d092..f33f2d14d57 100644 --- a/torchgeo/datasets/inaturalist.py +++ b/torchgeo/datasets/inaturalist.py @@ -107,6 +107,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: f'query: {query} not found in index with bounds: {self.bounds}' ) - sample = {'crs': self.crs, 'geo_bbox': bboxes} + sample = {'crs': self.crs, 'bounds': bboxes} return sample diff --git a/torchgeo/datasets/landcoverai.py b/torchgeo/datasets/landcoverai.py index 957dc3c17d9..5273c03303c 100644 --- a/torchgeo/datasets/landcoverai.py +++ b/torchgeo/datasets/landcoverai.py @@ -268,7 +268,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: mask = self._merge_files(mask_filepaths, query, self.band_indexes) sample = { 'crs': self.crs, - 'geo_bbox': query, + 'bounds': query, 'image': img.float(), 'mask': mask.long(), } diff --git a/torchgeo/datasets/openbuildings.py b/torchgeo/datasets/openbuildings.py index b983a61f546..9e341b6822d 100644 --- a/torchgeo/datasets/openbuildings.py +++ b/torchgeo/datasets/openbuildings.py @@ -328,7 +328,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: else: masks = torch.zeros(size=(1, round(height), round(width))) - sample = {'mask': masks, 'crs': self.crs, 'geo_bbox': query} + sample = {'mask': masks, 'crs': self.crs, 'bounds': query} if self.transforms is not None: sample = self.transforms(sample) diff --git a/torchgeo/datasets/south_africa_crop_type.py b/torchgeo/datasets/south_africa_crop_type.py index e034b781613..688ce166924 100644 --- a/torchgeo/datasets/south_africa_crop_type.py +++ b/torchgeo/datasets/south_africa_crop_type.py @@ -228,7 +228,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]: sample = { 'crs': self.crs, - 'geo_bbox': query, + 'bounds': query, 'image': image.float(), 'mask': mask.long(), } From 110aaa2c01b63a55f4a619df76558461a83955ac Mon Sep 17 00:00:00 2001 From: Ashwin Nair Date: Wed, 31 Jul 2024 21:29:55 +0400 Subject: [PATCH 3/3] Undo rename in data.py --- tests/data/western_usa_live_fuel_moisture/data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/western_usa_live_fuel_moisture/data.py b/tests/data/western_usa_live_fuel_moisture/data.py index 7d81bd3bc11..44fc8717b47 100755 --- a/tests/data/western_usa_live_fuel_moisture/data.py +++ b/tests/data/western_usa_live_fuel_moisture/data.py @@ -172,7 +172,7 @@ 'type': 'text/csv', }, }, - 'bounds': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], + 'bbox': [-115.8855556, 42.44111111, -115.8855556, 42.44111111], 'collection': 'su_sar_moisture_content', 'geometry': {'coordinates': [-115.8855556, 42.44111111], 'type': 'Point'}, 'id': 'su_sar_moisture_content_0001',