Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCMerced: fix image shape bug #1238

Merged
merged 30 commits into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
01856cd
fix resize bug in ucmerced
isaaccorley Apr 12, 2023
7724c71
remove unused test
isaaccorley Apr 13, 2023
72af489
update tests
isaaccorley Apr 13, 2023
af1817e
move resize to dataset
isaaccorley Apr 14, 2023
576fc13
fix resize bug in ucmerced
isaaccorley Apr 12, 2023
f85565f
remove unused test
isaaccorley Apr 13, 2023
7cbef78
update tests
isaaccorley Apr 13, 2023
22e8c7e
Merge branch 'datasets/ucmerced-size-bug' of github.com:isaaccorley/t…
isaaccorley Apr 14, 2023
cf64bf7
remove changes to datamodule
isaaccorley Apr 14, 2023
841e73b
Update torchgeo/datasets/ucmerced.py
isaaccorley Apr 14, 2023
4690751
fix docstring
isaaccorley Apr 15, 2023
d475361
fix resize bug in ucmerced
isaaccorley Apr 12, 2023
5ee2925
remove unused test
isaaccorley Apr 13, 2023
5678102
update tests
isaaccorley Apr 13, 2023
53c619f
move resize to dataset
isaaccorley Apr 14, 2023
390c77e
fix resize bug in ucmerced
isaaccorley Apr 12, 2023
73e76e2
remove unused test
isaaccorley Apr 13, 2023
2f165c1
update tests
isaaccorley Apr 13, 2023
a1a6485
remove changes to datamodule
isaaccorley Apr 14, 2023
14a146e
Update torchgeo/datasets/ucmerced.py
isaaccorley Apr 14, 2023
8866b22
fix docstring
isaaccorley Apr 15, 2023
dacd60d
Merge branch 'datasets/ucmerced-size-bug' of github.com:isaaccorley/t…
isaaccorley Apr 15, 2023
b095cc4
update docstring
isaaccorley Apr 15, 2023
d2aed56
Merge branch 'main' into datasets/ucmerced-size-bug
isaaccorley Apr 15, 2023
06cab16
update docstring x3
isaaccorley Apr 16, 2023
9491f9e
Merge branch 'main' into datasets/ucmerced-size-bug
isaaccorley Apr 16, 2023
821b3bf
remove Dict
isaaccorley Apr 16, 2023
d65359a
remove Tuple
isaaccorley Apr 16, 2023
d42d2d4
Fix base class docs
adamjstewart Apr 16, 2023
998d519
Grammar fix
adamjstewart Apr 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/conf/ucmerced.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ experiment:
datamodule:
root: "tests/data/ucmerced"
download: true
batch_size: 1
batch_size: 2
num_workers: 0
7 changes: 4 additions & 3 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ def __getitem__(self, index: int) -> dict[str, Tensor]:

Args:
index: index to return

Returns:
data and label at that index
"""
Expand All @@ -756,13 +757,13 @@ def __len__(self) -> int:
return len(self.imgs)

def _load_image(self, index: int) -> tuple[Tensor, Tensor]:
"""Load a single image and it's class label.
"""Load a single image and its class label.

Args:
index: index to return

Returns:
the image
the image class label
the image and class label
"""
img, label = ImageFolder.__getitem__(self, index)
array: "np.typing.NDArray[np.int_]" = np.array(img)
Expand Down
14 changes: 14 additions & 0 deletions torchgeo/datasets/ucmerced.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import matplotlib.pyplot as plt
import numpy as np
import torchvision.transforms.functional as F
from torch import Tensor

from .geo import NonGeoClassificationDataset
Expand Down Expand Up @@ -143,6 +144,19 @@ def __init__(
is_valid_file=is_in_split,
)

def _load_image(self, index: int) -> tuple[Tensor, Tensor]:
"""Load a single image and its class label.

Args:
index: index to return
adamjstewart marked this conversation as resolved.
Show resolved Hide resolved

Returns:
the image and class label
"""
img, label = super()._load_image(index)
img = F.resize(img, size=(256, 256), antialias=True)
return img, label

def _check_integrity(self) -> bool:
"""Check integrity of dataset.

Expand Down