Skip to content

Commit 88676c9

Browse files
committed
request
1 parent 0c8d112 commit 88676c9

File tree

4 files changed

+23
-21
lines changed

4 files changed

+23
-21
lines changed

docs/api/datasets.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ BioMassters
217217

218218
.. autoclass:: BioMassters
219219

220-
BRIGHT DFC2025
221-
^^^^^^^^^^^^^^
220+
BRIGHT
221+
^^^^^^
222222

223223
.. autoclass:: BRIGHTDFC2025
224224

docs/api/datasets/non_geo_datasets.csv

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Dataset,Task,Source,License,# Samples,# Classes,Size (px),Resolution (m),Bands
33
`Benin Cashew Plantations`_,S,Airbus Pléiades,"CC-BY-4.0",70,6,"1,122x1,186",10,MSI
44
`BigEarthNet`_,C,Sentinel-1/2,"CDLA-Permissive-1.0","590,326",19--43,120x120,10,"SAR, MSI"
55
`BioMassters`_,R,Sentinel-1/2 and Lidar,"CC-BY-4.0",,,256x256, 10, "SAR, MSI"
6-
`BRIGHT DFC2025`_,CD,"MAXAR, NAIP, Capella, Umbra","CC-BY-SA-4.0",3239,4,"0.1-1","RGB,SAR"
6+
`BRIGHT`_,CD,"MAXAR, NAIP, Capella, Umbra","CC-BY-NC-4.0",3239,4,"0.1-1","RGB,SAR"
77
`CaBuAr`_,CD,Sentinel-2,"OpenRAIL",424,2,512x512,20,MSI
88
`CaFFe`_,S,"Sentinel-1, TerraSAR-X, TanDEM-X, ENVISAT, ERS-1/2, ALOS PALSAR, and RADARSAT-1","CC-BY-4.0","19092","2 or 4","512x512",6-20,"SAR"
99
`ChaBuD`_,CD,Sentinel-2,"OpenRAIL",356,2,512x512,10,MSI

tests/datasets/test_bright.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ def dataset(
3232
def test_getitem(self, dataset: BRIGHTDFC2025) -> None:
3333
x = dataset[0]
3434
assert isinstance(x, dict)
35-
assert isinstance(x['pre_image'], torch.Tensor)
36-
assert x['pre_image'].shape[0] == 3
37-
assert isinstance(x['post_image'], torch.Tensor)
38-
assert x['post_image'].shape[0] == 3
39-
assert x['pre_image'].shape[-2:] == x['post_image'].shape[-2:]
35+
assert isinstance(x['image_pre'], torch.Tensor)
36+
assert x['image_pre'].shape[0] == 3
37+
assert isinstance(x['image_post'], torch.Tensor)
38+
assert x['image_post'].shape[0] == 3
39+
assert x['image_pre'].shape[-2:] == x['image_post'].shape[-2:]
4040
if dataset.split != 'test':
4141
assert isinstance(x['mask'], torch.Tensor)
42-
assert x['pre_image'].shape[-2:] == x['mask'].shape[-2:]
42+
assert x['image_pre'].shape[-2:] == x['mask'].shape[-2:]
4343

4444
def test_len(self, dataset: BRIGHTDFC2025) -> None:
4545
if dataset.split == 'train':

torchgeo/datasets/bright.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
class BRIGHTDFC2025(NonGeoDataset):
2727
"""BRIGHT DFC2025 dataset.
2828
29-
The `BRIGHT <https://github.com/ChenHongruixuan/BRIGHT>`__ dataset consists of bi-temporal high-resolution multimodal images for
29+
The `BRIGHT <https://github.com/ChenHongruixuan/BRIGHT>`__ dataset consists of bi-temporal
30+
high-resolution multimodal images for
3031
building damage assessment. The dataset is part of the 2025 IEEE GRSS Data Fusion Contest.
3132
The pre-disaster images are optical images and the post-disaster images are SAR images, and
3233
targets were manually annotated. The dataset is split into train, val, and test splits, but
@@ -64,7 +65,7 @@ class BRIGHTDFC2025(NonGeoDataset):
6465

6566
md5 = '2c435bb50345d425390eff59a92134ac'
6667

67-
url = 'https://huggingface.co/datasets/Kullervo/BRIGHT/resolve/50901f05db4acbd141e7c96d719d8317910498fb/dfc25_track2_trainval.zip'
68+
url = 'https://huggingface.co/datasets/torchgeo/bright/resolve/d19972f5e682ad684dcde35529a6afad4c719f1b/dfc25_track2_trainval_with_split.zip'
6869

6970
data_dir = 'dfc25_track2_trainval'
7071

@@ -126,17 +127,18 @@ def __getitem__(self, index: int) -> dict[str, Tensor]:
126127
index: index to return
127128
128129
Returns:
129-
data and target at that index
130+
data and target at that index, pre and post image
131+
are returned under separate image keys
130132
"""
131133
idx_paths = self.sample_paths[index]
132134

133-
pre_image = self._load_image(idx_paths['pre_image']).float()
134-
post_image = self._load_image(idx_paths['post_image']).float()
135+
image_pre = self._load_image(idx_paths['image_pre']).float()
136+
image_post = self._load_image(idx_paths['image_post']).float()
135137
# https://github.com/ChenHongruixuan/BRIGHT/blob/11b1ffafa4d30d2df2081189b56864b0de4e3ed7/dfc25_benchmark/dataset/make_data_loader.py#L101
136138
# post image is stacked to also have 3 channels
137-
post_image = repeat(post_image, 'c h w -> (repeat c) h w', repeat=3)
139+
image_post = repeat(image_post, 'c h w -> (repeat c) h w', repeat=3)
138140

139-
sample = {'pre_image': pre_image, 'post_image': post_image}
141+
sample = {'image_pre': image_pre, 'image_post': image_post}
140142

141143
if 'target' in idx_paths and self.split != 'test':
142144
target = self._load_image(idx_paths['target']).long()
@@ -151,7 +153,7 @@ def _get_paths(self) -> list[dict[str, str]]:
151153
"""Get paths to the dataset files based on specified splits.
152154
153155
Returns:
154-
a list of dictionaries containing paths to the pre,post and target images
156+
a list of dictionaries containing paths to the pre, post, and target images
155157
"""
156158
split_file = self.split_files[self.split]
157159

@@ -166,14 +168,14 @@ def _get_paths(self) -> list[dict[str, str]]:
166168

167169
sample_paths = [
168170
{
169-
'pre_image': os.path.join(
171+
'image_pre': os.path.join(
170172
self.root,
171173
self.data_dir,
172174
dir_split_name,
173175
'pre-event',
174176
f'{sample_id.strip()}_pre_disaster.tif',
175177
),
176-
'post_image': os.path.join(
178+
'image_post': os.path.join(
177179
self.root,
178180
self.data_dir,
179181
dir_split_name,
@@ -290,10 +292,10 @@ def plot(
290292

291293
fig, axs = plt.subplots(nrows=1, ncols=ncols, figsize=(15, 5))
292294

293-
axs[0].imshow(sample['pre_image'].permute(1, 2, 0) / 255.0)
295+
axs[0].imshow(sample['image_pre'].permute(1, 2, 0) / 255.0)
294296
axs[0].axis('off')
295297

296-
axs[1].imshow(sample['post_image'].permute(1, 2, 0) / 255.0)
298+
axs[1].imshow(sample['image_post'].permute(1, 2, 0) / 255.0)
297299
axs[1].axis('off')
298300

299301
cmap = colors.ListedColormap(self.colormap)

0 commit comments

Comments
 (0)