Safemotion Lib
Loading...
Searching...
No Matches
cuhk_sysu.py
Go to the documentation of this file.
1# encoding: utf-8
2"""
3@author: xingyu liao
4@contact: sherlockliao01@gmail.com
5"""
6
7import glob
8import os.path as osp
9import re
10import warnings
11
12from .bases import ImageDataset
13from ..datasets import DATASET_REGISTRY
14
15
16@DATASET_REGISTRY.register()
18 r"""CUHK SYSU datasets.
19
20 The dataset is collected from two sources: street snap and movie.
21 In street snap, 12,490 images and 6,057 query persons were collected
22 with movable cameras across hundreds of scenes while 5,694 images and
23 2,375 query persons were selected from movies and TV dramas.
24
25 Dataset statistics:
26 - identities: xxx.
27 - images: 12936 (train).
28 """
29 dataset_dir = 'cuhk_sysu'
30 dataset_name = "cuhksysu"
31
32 def __init__(self, root='datasets', **kwargs):
33 self.root = root
35
36 self.data_dir = osp.join(self.dataset_dirdataset_dir, "cropped_images")
37
38 required_files = [self.data_dir]
39 self.check_before_run(required_files)
40
41 train = self.process_dir(self.data_dir)
42 query = []
43 gallery = []
44
45 super(cuhkSYSU, self).__init__(train, query, gallery, **kwargs)
46
47 def process_dir(self, dir_path):
48 img_paths = glob.glob(osp.join(dir_path, '*.jpg'))
49 pattern = re.compile(r'p([-\d]+)_s(\d)')
50
51 data = []
52 for img_path in img_paths:
53 pid, _ = map(int, pattern.search(img_path).groups())
54 pid = self.dataset_name + "_" + str(pid)
55 camid = self.dataset_name + "_0"
56 data.append((img_path, pid, camid))
57
58 return data
check_before_run(self, required_files)
Definition bases.py:113
__init__(self, root='datasets', **kwargs)
Definition cuhk_sysu.py:32