Skip to content

Commit

Permalink
Makes it optional to oversample images with building damage
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianGer committed Oct 24, 2024
1 parent f932a8b commit 60ceeb9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions configs/dataset/xview2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ auto_download: False
img_size: 1024
multi_temporal: False
multi_modal: False
oversample_building_damage: True

# classes
ignore_index: -1
Expand Down
5 changes: 4 additions & 1 deletion pangaea/datasets/xview2.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def __init__(
data_max: dict[str, list[str]],
download_url: str,
auto_download: bool,
oversample_building_damage: bool
):
"""Initialize the xView2 dataset.
Link: https://xview2.org/dataset
Expand Down Expand Up @@ -70,6 +71,7 @@ def __init__(
e.g. {"s2": [b1_max, ..., bn_max], "s1": [b1_max, ..., bn_max]}
download_url (str): url to download the dataset.
auto_download (bool): whether to download the dataset automatically.
oversample_building_damage (bool): whether to oversample images with building damage
"""
super(xView2, self).__init__(
split=split,
Expand Down Expand Up @@ -105,6 +107,7 @@ def __init__(
self.ignore_index = ignore_index
self.download_url = download_url
self.auto_download = auto_download
self.oversample_building_damage = oversample_building_damage

self.all_files = self.get_all_files()

Expand All @@ -124,7 +127,7 @@ def get_all_files(self) -> Sequence[str]:
if self.split != "test":
train_val_idcs = self.get_stratified_train_val_split(all_files)

if self.split == "train":
if self.split == "train" and self.oversample_building_damage:
train_val_idcs[self.split] = self.oversample_building_files(all_files, train_val_idcs[self.split])


Expand Down

0 comments on commit 60ceeb9

Please sign in to comment.