Safemotion Lib
Loading...
Searching...
No Matches
veri.py
Go to the documentation of this file.
1# encoding: utf-8
2"""
3@author: Jinkai Zheng
4@contact: 1315673509@qq.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 """VeRi.
18
19 Reference:
20 Liu et al. A Deep Learning based Approach for Progressive Vehicle Re-Identification. ECCV 2016.
21
22 URL: `<https://vehiclereid.github.io/VeRi/>`_
23
24 Dataset statistics:
25 - identities: 775.
26 - images: 37778 (train) + 1678 (query) + 11579 (gallery).
27 """
28 dataset_dir = "veri"
29 dataset_name = "veri"
30
31 def __init__(self, root='datasets', **kwargs):
33
34 self.train_dir = osp.join(self.dataset_dirdataset_dir, 'image_train')
35 self.query_dir = osp.join(self.dataset_dirdataset_dir, 'image_query')
36 self.gallery_dir = osp.join(self.dataset_dirdataset_dir, 'image_test')
37
38 required_files = [
40 self.train_dir,
41 self.query_dir,
42 self.gallery_dir,
43 ]
44 self.check_before_run(required_files)
45
46 train = self.process_dir(self.train_dir)
47 query = self.process_dir(self.query_dir, is_train=False)
48 gallery = self.process_dir(self.gallery_dir, is_train=False)
49
50 super(VeRi, self).__init__(train, query, gallery, **kwargs)
51
52 def process_dir(self, dir_path, is_train=True):
53 img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
54 pattern = re.compile(r'([\d]+)_c(\d\d\d)')
55
56 data = []
57 for img_path in img_paths:
58 pid, camid = map(int, pattern.search(img_path).groups())
59 if pid == -1: continue # junk images are just ignored
60 assert 1 <= pid <= 776
61 assert 1 <= camid <= 20
62 camid -= 1 # index starts from 0
63 if is_train:
64 pid = self.dataset_name + "_" + str(pid)
65 camid = self.dataset_name + "_" + str(camid)
66 data.append((img_path, pid, camid))
67
68 return data
check_before_run(self, required_files)
Definition bases.py:113
process_dir(self, dir_path, is_train=True)
Definition veri.py:52
__init__(self, root='datasets', **kwargs)
Definition veri.py:31