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

Rareplanes #104

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion common/vision/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
from .retinopathy import Retinopathy
from .eurosat import EuroSAT
from .resisc45 import Resisc45
from .rareplanes import Rareplanes

__all__ = ['ImageList', 'Office31', 'OfficeHome', "VisDA2017", "OfficeCaltech", "DomainNet", "ImageNetR", "ImageNetSketch",
"Aircraft", "cub200", "StanfordCars", "StanfordDogs", "COCO70", "OxfordIIITPet", "PACS", "DTD",
"OxfordFlowers102", "PatchCamelyon", "Retinopathy", "EuroSAT", "Resisc45"]
"OxfordFlowers102", "PatchCamelyon", "Retinopathy", "EuroSAT", "Resisc45", "Rareplanes"]
57 changes: 57 additions & 0 deletions common/vision/datasets/rareplanes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""
@author: Hao Chen
@contact: [email protected]
"""
import os
from typing import Optional
from .imagelist import ImageList
from ._util import download as download_data, check_exits


class Rareplanes(ImageList):
"""`OfficeHome <http://hemanthdv.org/OfficeHome-Dataset/>`_ Dataset.

Args:
root (str): Root directory of dataset
task (str): The task (domain) to create dataset. Choices include ``'Ar'``: Art, \
``'Cl'``: Clipart, ``'Pr'``: Product and ``'Rw'``: Real_World.
download (bool, optional): If true, downloads the dataset from the internet and puts it \
in root directory. If dataset is already downloaded, it is not downloaded again.
transform (callable, optional): A function/transform that takes in an PIL image and returns a \
transformed version. E.g, :class:`torchvision.transforms.RandomCrop`.
target_transform (callable, optional): A function/transform that takes in the target and transforms it.

.. note:: In `root`, there will exist following files after downloading.
::
rareplanes/
Alarm_Clock/*.jpg
...
fgvc/
image_list/
rareplanes.txt
fgvc.txt
"""
download_list = [
]
image_list = {
"rareplanes": "image_list/rareplanes.txt",
"fgvc": "image_list/fgvc.txt",
}
CLASSES = ['707-320','Boeing_717','727-200','737-200','737-300','747-200','757-300','767-200',
'767-400','777-300','A300B4','A319','A320','A330-300','A340-300','A380','Cessna_172',
'BAE_146-300','Fokker_100','MD-11']

def __init__(self, root: str, task: str, download: Optional[bool] = False, **kwargs):
assert task in self.image_list
data_list_file = os.path.join(root, self.image_list[task])

if download:
list(map(lambda args: download_data(root, *args), self.download_list))
else:
list(map(lambda file_name, _: check_exits(root, file_name), self.download_list))

super(Rareplanes, self).__init__(root, Rareplanes.CLASSES, data_list_file=data_list_file, **kwargs)

@classmethod
def domains(cls):
return list(cls.image_list.keys())
7 changes: 4 additions & 3 deletions examples/domain_adaptation/image_classification/dann.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,10 @@ def train(train_source_iter: ForeverDataIterator, train_target_iter: ForeverData
# dataset parameters
parser.add_argument('root', metavar='DIR',
help='root path of dataset')
parser.add_argument('-d', '--data', metavar='DATA', default='Office31', choices=utils.get_dataset_names(),
help='dataset: ' + ' | '.join(utils.get_dataset_names()) +
' (default: Office31)')
# parser.add_argument('-d', '--data', metavar='DATA', default='Office31', choices=utils.get_dataset_names(),
# help='dataset: ' + ' | '.join(utils.get_dataset_names()) +
# ' (default: Office31)')
parser.add_argument('-d', '--data', default='default') # -chh
parser.add_argument('-s', '--source', help='source domain(s)', nargs='+')
parser.add_argument('-t', '--target', help='target domain(s)', nargs='+')
parser.add_argument('--train-resizing', type=str, default='default')
Expand Down