forked from isaaccorley/torchrs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added patternnet dataset, datamodule, and download script. updated re…
…adme
- Loading branch information
1 parent
89d3416
commit 2ede7a5
Showing
7 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pip install gdown | ||
mkdir -p .data/ | ||
gdown --id 127lxXYqzO6Bd0yZhvEbgIfz95HaEnr9K | ||
unzip PatternNet.zip -d .data/ | ||
rm PatternNet.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
|
||
import torchvision.transforms as T | ||
from torchvision.datasets import ImageFolder | ||
|
||
|
||
class PatternNet(ImageFolder): | ||
""" PatternNet dataset from 'PatternNet: A benchmark dataset for performance | ||
evaluation of remote sensing image retrieval', Zhou at al. (2018) | ||
https://arxiv.org/abs/1706.03424 | ||
""" | ||
def __init__( | ||
self, | ||
root: str = ".data/PatternNet", | ||
transform: T.Compose = T.Compose([T.ToTensor()]) | ||
): | ||
super().__init__( | ||
root=os.path.join(root, "images"), | ||
transform=transform | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Optional | ||
|
||
import torchvision.transforms as T | ||
|
||
from torchrs.datasets.utils import dataset_split | ||
from torchrs.train.datamodules import BaseDataModule | ||
from torchrs.datasets import PatternNet | ||
|
||
|
||
class PatternNetDataModule(BaseDataModule): | ||
|
||
def __init__( | ||
self, | ||
root: str = ".data/PatternNet", | ||
transform: T.Compose = T.Compose([T.ToTensor()]), | ||
*args, **kwargs | ||
): | ||
super().__init__(*args, **kwargs) | ||
self.root = root | ||
self.transform = transform | ||
|
||
def setup(self, stage: Optional[str] = None): | ||
dataset = PatternNet(root=self.root, transform=self.transform) | ||
self.train_dataset, self.val_dataset, self.test_dataset = dataset_split( | ||
dataset, val_pct=self.val_split, test_pct=self.test_split | ||
) |