diff --git a/README.rst b/README.rst index 4c43472..56dfd5c 100755 --- a/README.rst +++ b/README.rst @@ -33,6 +33,7 @@ You can find some research projects that are built on top of Torchreid `here `_. - [Feb 2021] ``v1.3.5``: Now the `cython code `_ works on Windows (credit to `lablabla `_). - [Jan 2021] Our recent work, `MixStyle `_ (mixing instance-level feature statistics of samples of different domains for improving domain generalization), has been accepted to ICLR'21. The code has been released at https://github.com/KaiyangZhou/mixstyle-release where the person re-ID part is based on Torchreid. - [Jan 2021] A new evaluation metric called `mean Inverse Negative Penalty (mINP)` for person re-ID has been introduced in `Deep Learning for Person Re-identification: A Survey and Outlook (TPAMI 2021) `_. Their code can be accessed at ``_. @@ -230,6 +231,10 @@ Image-reid datasets - `QMUL-iLIDS `_ - `PRID `_ +Geo-localization datasets +^^^^^^^^^^^^^^^^^^^^^^^ +- `University-1652 `_ + Video-reid datasets ^^^^^^^^^^^^^^^^^^^^^^^ - `MARS `_ diff --git a/torchreid/data/datasets/__init__.py b/torchreid/data/datasets/__init__.py index 5f99dcc..53e6ed8 100644 --- a/torchreid/data/datasets/__init__.py +++ b/torchreid/data/datasets/__init__.py @@ -2,7 +2,7 @@ from __future__ import print_function, absolute_import from .image import ( GRID, PRID, CUHK01, CUHK02, CUHK03, MSMT17, VIPeR, SenseReID, Market1501, - DukeMTMCreID, iLIDS + DukeMTMCreID, iLIDS, University1652 ) from .video import PRID2011, Mars, DukeMTMCVidReID, iLIDSVID from .dataset import Dataset, ImageDataset, VideoDataset @@ -18,7 +18,8 @@ __image_datasets = { 'ilids': iLIDS, 'sensereid': SenseReID, 'prid': PRID, - 'cuhk02': CUHK02 + 'cuhk02': CUHK02, + 'university1652':University1652 } __video_datasets = { diff --git a/torchreid/data/datasets/image/__init__.py b/torchreid/data/datasets/image/__init__.py index 6be746e..91342cd 100644 --- a/torchreid/data/datasets/image/__init__.py +++ b/torchreid/data/datasets/image/__init__.py @@ -11,3 +11,4 @@ from .msmt17 import MSMT17 from .sensereid import SenseReID from .market1501 import Market1501 from .dukemtmcreid import DukeMTMCreID +from .university1652 import University1652 diff --git a/torchreid/data/datasets/image/university1652.py b/torchreid/data/datasets/image/university1652.py new file mode 100644 index 0000000..10db236 --- /dev/null +++ b/torchreid/data/datasets/image/university1652.py @@ -0,0 +1,102 @@ +from __future__ import division, print_function, absolute_import +import re +import glob +import os.path as osp +import os +import gdown + +from ..dataset import ImageDataset + + +class University1652(ImageDataset): + """University-1652. + + Reference: + - Zheng et al. University-1652: A Multi-view Multi-source Benchmark for Drone-based Geo-localization. ACM MM 2020. + + URL: ``_ +OneDrive: +https://studentutsedu-my.sharepoint.com/:u:/g/personal/12639605_student_uts_edu_au/Ecrz6xK-PcdCjFdpNb0T0s8B_9J5ynaUy3q63_XumjJyrA?e=z4hpcz +[Backup] GoogleDrive: +https://drive.google.com/file/d/1iVnP4gjw-iHXa0KerZQ1IfIO0i1jADsR/view?usp=sharing +[Backup] Baidu Yun: +https://pan.baidu.com/s/1H_wBnWwikKbaBY1pMPjoqQ password: hrqp + + Dataset statistics: + - buildings: 1652 (train + query). + - The dataset split is as follows: +| Split | #imgs | #buildings | #universities| +| -------- | ----- | ----| ----| +| Training | 50,218 | 701 | 33 | +| Query_drone | 37,855 | 701 | 39 | +| Query_satellite | 701 | 701 | 39| +| Query_ground | 2,579 | 701 | 39| +| Gallery_drone | 51,355 | 951 | 39| +| Gallery_satellite | 951 | 951 | 39| +| Gallery_ground | 2,921 | 793 | 39| + - cameras: None. +datamanager = torchreid.data.ImageDataManager( + root='reid-data', + sources='university1652', + targets='university1652', + height=256, + width=256, + batch_size_train=32, + batch_size_test=100, + transforms=['random_flip', 'random_crop'] +) + """ + dataset_dir = 'university1652' + dataset_url = 'https://drive.google.com/uc?id=1iVnP4gjw-iHXa0KerZQ1IfIO0i1jADsR' + def __init__(self, root='', **kwargs): + self.root = osp.abspath(osp.expanduser(root)) + self.dataset_dir = osp.join(self.root, self.dataset_dir) + print(self.dataset_dir) + if not os.path.isdir(self.dataset_dir): + os.mkdir(self.dataset_dir) + gdown.download(self.dataset_url, self.dataset_dir+'data.zip', quiet=False) + os.system('unzip %s'%(self.dataset_dir+'data.zip')) + self.train_dir = osp.join( + self.dataset_dir,'University-Release/train/' + ) + self.query_dir = osp.join(self.dataset_dir, 'University-Release/test/query_drone') + self.gallery_dir = osp.join( + self.dataset_dir, 'University-Release/test/gallery_satellite' + ) + + required_files = [ + self.dataset_dir, self.train_dir, self.query_dir, self.gallery_dir + ] + self.check_before_run(required_files) + + self.fake_camid = 0 + train = self.process_dir(self.train_dir, relabel=True, train=True) + query = self.process_dir(self.query_dir, relabel=False) + gallery = self.process_dir(self.gallery_dir, relabel=False) + + super(University1652, self).__init__(train, query, gallery, **kwargs) + + def process_dir(self, dir_path, relabel=False, train=False): + IMG_EXTENSIONS = ('.jpg', '.jpeg', '.png', '.ppm', '.bmp', '.pgm', '.tif', '.tiff', '.webp') + if train: + img_paths = glob.glob(osp.join(dir_path, '*/*/*')) + else: + img_paths = glob.glob(osp.join(dir_path, '*/*')) + pid_container = set() + for img_path in img_paths: + if not img_path.lower().endswith(IMG_EXTENSIONS): + continue + pid = int(os.path.basename(os.path.dirname(img_path))) + pid_container.add(pid) + pid2label = {pid: label for label, pid in enumerate(pid_container)} + data = [] + # no camera for university + for img_path in img_paths: + if not img_path.lower().endswith(IMG_EXTENSIONS): + continue + pid = int(os.path.basename(os.path.dirname(img_path))) + if relabel: + pid = pid2label[pid] + data.append((img_path, pid, self.fake_camid)) + self.fake_camid +=1 + return data