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 aid dataset datamodule and download script
1 parent
481346a
commit 306d05b
Showing
6 changed files
with
102 additions
and
8 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
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 instal gdown | ||
mkdir -p .data | ||
gdown --id 1cvjfe_MZJI9HXwkRgoQbSCH55qQd6Esm | ||
unzip AID.zip -d .data/ | ||
rm AID.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,26 @@ | ||
import torchvision.transforms as T | ||
from torchvision.datasets import ImageFolder | ||
|
||
|
||
class AID(ImageFolder): | ||
""" Image Scene Classification dataset from 'Remote Sensing Image | ||
Scene Classification: Benchmark and State of the Art', Cheng at al. (2017) | ||
https://arxiv.org/abs/1703.00121 | ||
'We propose a large-scale dataset, termed "NWPU-RESISC45", which is a publicly | ||
available benchmark for REmote Sensing Image Scene Classification (RESISC), created | ||
by Northwestern Polytechnical University (NWPU). This dataset contains 31,500 images, | ||
covering 45 scene classes with 700 images in each class. The proposed NWPU-RESISC45 (i) | ||
is large-scale on the scene classes and the total image number, (ii) holds big variations | ||
in translation, spatial resolution, viewpoint, object pose, illumination, background, and | ||
occlusion, and (iii) has high within-class diversity and between-class similarity.' | ||
""" | ||
def __init__( | ||
self, | ||
root: str = ".data/AID", | ||
transform: T.Compose = T.Compose([T.ToTensor()]) | ||
): | ||
super().__init__( | ||
root=root, | ||
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 AID | ||
|
||
|
||
class AIDDataModule(BaseDataModule): | ||
|
||
def __init__( | ||
self, | ||
root: str = ".data/NWPU-RESISC45", | ||
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 = AID(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 | ||
) |