Safemotion Lib
Loading...
Searching...
No Matches
dukemtmcreid.py
Go to the documentation of this file.
1# encoding: utf-8
2"""
3@author: liaoxingyu
4@contact: liaoxingyu2@jd.com
5"""
6
7import glob
8import os.path as osp
9import re
10
11from .bases import ImageDataset
12from ..datasets import DATASET_REGISTRY
13
14
15@DATASET_REGISTRY.register()
17 """DukeMTMC-reID.
18
19 Reference:
20 - Ristani et al. Performance Measures and a Data Set for Multi-Target, Multi-Camera Tracking. ECCVW 2016.
21 - Zheng et al. Unlabeled Samples Generated by GAN Improve the Person Re-identification Baseline in vitro. ICCV 2017.
22
23 URL: `<https://github.com/layumi/DukeMTMC-reID_evaluation>`_
24
25 Dataset statistics:
26 - identities: 1404 (train + query).
27 - images:16522 (train) + 2228 (query) + 17661 (gallery).
28 - cameras: 8.
29 """
30 dataset_dir = '/workspace/LUPerson/fast-reid/datasets'
31 dataset_url = 'http://vision.cs.duke.edu/DukeMTMC/data/misc/DukeMTMC-reID.zip'
32 dataset_name = "dukemtmc"
33
34 def __init__(self, root='datasets', **kwargs):
35 # self.root = osp.abspath(osp.expanduser(root))
36 self.root = root
38 self.train_dir = osp.join(self.dataset_dirdataset_dir, 'bounding_box_train')
39 self.query_dir = osp.join(self.dataset_dirdataset_dir, 'query')
40 self.gallery_dir = osp.join(self.dataset_dirdataset_dir, 'bounding_box_test')
41
42 required_files = [
44 self.train_dir,
45 self.query_dir,
46 self.gallery_dir,
47 ]
48 self.check_before_run(required_files)
49
50 train = self.process_dir(self.train_dir)
51 query = self.process_dir(self.query_dir, is_train=False)
52 gallery = self.process_dir(self.gallery_dir, is_train=False)
53
54 super(DukeMTMC, self).__init__(train, query, gallery, **kwargs)
55
56 def process_dir(self, dir_path, is_train=True):
57 img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
58 pattern = re.compile(r'([-\d]+)_c(\d)')
59
60 data = []
61 for img_path in img_paths:
62 pid, camid = map(int, pattern.search(img_path).groups())
63 assert 1 <= camid <= 8
64 camid -= 1 # index starts from 0
65 if is_train:
66 pid = self.dataset_name + "_" + str(pid)
67 camid = self.dataset_name + "_" + str(camid)
68 data.append((img_path, pid, camid))
69
70 return data
check_before_run(self, required_files)
Definition bases.py:113
process_dir(self, dir_path, is_train=True)
__init__(self, root='datasets', **kwargs)