Skip to content

Commit

Permalink
added aid dataset datamodule and download script
Browse files Browse the repository at this point in the history
isaaccorley committed Aug 28, 2021
1 parent 481346a commit 306d05b
Showing 6 changed files with 102 additions and 8 deletions.
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -40,13 +40,14 @@ pip install 'git+https://github.com/isaaccorley/torchrs.git#egg=torch-rs[train]'
* [RSICD - Remote Sensing Image Captioning Dataset](https://github.com/isaaccorley/torchrs#remote-sensing-image-captioning-dataset-rsicd)
* [Sydney Captions](https://github.com/isaaccorley/torchrs#sydney-captions)
* [UC Merced (UCM) Captions](https://github.com/isaaccorley/torchrs#uc-merced-ucm-captions)
* [RESISC45 - Remote Sensing Image Scene Classification](https://github.com/isaaccorley/torchrs#remote-sensing-image-scene-classification-resisc45)
* [EuroSAT](https://github.com/isaaccorley/torchrs#eurosat)
* [SAT-4-&-SAT-6](https://github.com/isaaccorley/torchrs#sat-4--sat-6)
* [Inria Aerial Image Labeling - Building Segmentation](https://github.com/isaaccorley/torchrs#inria-aerial-image-labeling)
* [RESISC45 - Scene Classification](https://github.com/isaaccorley/torchrs#remote-sensing-image-scene-classification-resisc45)
* [EuroSAT - Scene Classification](https://github.com/isaaccorley/torchrs#eurosat)
* [SAT-4-&-SAT-6 - Scene Classification](https://github.com/isaaccorley/torchrs#sat-4--sat-6)
* [AID - Scene Classification](https://github.com/isaaccorley/torchrs#aid)
* [Inria Aerial Image Labeling - Building Semantic Segmentation](https://github.com/isaaccorley/torchrs#inria-aerial-image-labeling)
* [GID-15 - Semantic Segmentation](https://github.com/isaaccorley/torchrs#gid-15)
* [ZueriCrop - Time-Series Instance Segmentation](https://github.com/isaaccorley/torchrs#zuericrop)
* [TiSeLaC - Time-series Land Cover Classification](https://github.com/isaaccorley/torchrs#tiselac)
* [TiSeLaC - Time-Series Land Cover Classification](https://github.com/isaaccorley/torchrs#tiselac)

### PROBA-V Super Resolution

@@ -473,7 +474,7 @@ x: dict(

<img src="./assets/resisc45.png" width="500px"></img>

The [RESISC45](http://www.escience.cn/people/JunweiHan/NWPU-RESISC45.html) dataset, proposed in ["Remote Sensing Image Scene Classification: Benchmark and State of the Art", Cheng et al.](https://arxiv.org/abs/1703.00121) is an scene classification dataset of 31,500 RGB images extracted using [Google Earth Engine](https://earthengine.google.com/). The dataset contains 45 scenes with 700 images per class from over 100 countries and was selected to optimize for high variability in image conditions (spatial resolution, occlusion, weather, illumination, etc.).
The [RESISC45](http://www.escience.cn/people/JunweiHan/NWPU-RESISC45.html) dataset, proposed in ["Remote Sensing Image Scene Classification: Benchmark and State of the Art", Cheng et al.](https://arxiv.org/abs/1703.00121) is a scene classification dataset of 31,500 RGB images extracted using [Google Earth](https://earth.google.com/web/). The dataset contains 45 scenes with 700 images per class from over 100 countries and was selected to optimize for high variability in image conditions (spatial resolution, occlusion, weather, illumination, etc.).

The dataset can be downloaded (0.47GB) using `scripts/download_resisc45.sh` and instantiated below:

@@ -600,6 +601,40 @@ dataset.classes
"""
```

### Aerial Image Dataset (AID)

<img src="./assets/aid.png" width="500px"></img>

The [AID](https://captain-whu.github.io/AID/) dataset, proposed in ["AID: A Benchmark Dataset for Performance Evaluation of Aerial Scene Classification", Xia et al.](https://arxiv.org/abs/1608.05167) is a scene classification dataset of 10k 600x600 RGB images extracted using [Google Earth](https://earth.google.com/web/). The dataset contains 30 scenes with several hundred images per class from regions and countries around the world. This dataset is fairly easy with ~90% accuracy achievable with a VGG-16.

The dataset can be downloaded (2.6GB) using `scripts/download_aid.sh` and instantiated below:

```python
import torchvision.transforms as T
from torchrs.datasets import AID

transform = T.Compose([T.ToTensor()])

dataset = AID(
root="path/to/dataset/",
transform=transform
)

x, y = dataset[0]
"""
x: (3, 600, 600)
y: int
"""

dataset.classes
"""
['Airport', 'BareLand', 'BaseballField', 'Beach', 'Bridge', 'Center', 'Church', 'Commercial',
'DenseResidential', 'Desert', 'Farmland', 'Forest', 'Industrial', 'Meadow', 'MediumResidential',
'Mountain', 'Park', 'Parking', 'Playground', 'Pond', 'Port', 'RailwayStation', 'Resort',
'River', 'School', 'SparseResidential', 'Square', 'Stadium', 'StorageTanks', 'Viaduct']
"""
```

### Inria Aerial Image Labeling

<img src="./assets/inria_ail.png" width="950px"></img>
5 changes: 5 additions & 0 deletions scripts/download_aid.sh
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
3 changes: 2 additions & 1 deletion torchrs/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -19,11 +19,12 @@
from .tiselac import Tiselac
from .gid15 import GID15
from .zuericrop import ZueriCrop
from .aid import AID


__all__ = [
"PROBAV", "ETCI2021", "RSVQALR", "RSVQAxBEN", "EuroSATRGB", "EuroSATMS",
"RESISC45", "RSICD", "OSCD", "S2Looking", "LEVIRCDPlus", "FAIR1M",
"SydneyCaptions", "UCMCaptions", "S2MTCP", "ADVANCE", "SAT4", "SAT6",
"HRSCD", "InriaAIL", "Tiselac", "GID15", "ZueriCrop"
"HRSCD", "InriaAIL", "Tiselac", "GID15", "ZueriCrop", "AID"
]
26 changes: 26 additions & 0 deletions torchrs/datasets/aid.py
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
)
3 changes: 2 additions & 1 deletion torchrs/train/datamodules/__init__.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
from .tiselac import TiselacDataModule
from .gid15 import GID15DataModule
from .zuericrop import ZueriCropDataModule
from .aid import AIDDataModule


__all__ = [
@@ -27,5 +28,5 @@
"RSICDDataModule", "OSCDDataModule", "S2LookingDataModule", "LEVIRCDPlusDataModule",
"FAIR1MDataModule", "SydneyCaptionsDataModule", "UCMCaptionsDataModule", "S2MTCPDataModule",
"ADVANCEDataModule", "SAT4DataModule", "SAT6DataModule", "HRSCDDataModule", "InriaAILDataModule",
"TiselacDataModule", "GID15DataModule", "ZueriCropDataModule"
"TiselacDataModule", "GID15DataModule", "ZueriCropDataModule", "AIDDataModule"
]
26 changes: 26 additions & 0 deletions torchrs/train/datamodules/aid.py
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
)

0 comments on commit 306d05b

Please sign in to comment.