-
Notifications
You must be signed in to change notification settings - Fork 931
/
Copy pathgen_data_path.py
73 lines (63 loc) · 2.77 KB
/
gen_data_path.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import os
import glob
import _init_paths
def gen_caltech_path(root_path):
label_path = 'Caltech/data/labels_with_ids'
real_path = os.path.join(root_path, label_path)
image_path = real_path.replace('labels_with_ids', 'images')
images_exist = sorted(glob.glob(image_path + '/*.png'))
with open('../src/data/caltech.all', 'w') as f:
labels = sorted(glob.glob(real_path + '/*.txt'))
for label in labels:
image = label.replace('labels_with_ids', 'images').replace('.txt', '.png')
if image in images_exist:
print(image[22:], file=f)
f.close()
def gen_data_path(root_path):
mot_path = 'MOT17/images/train'
real_path = os.path.join(root_path, mot_path)
seq_names = [s for s in sorted(os.listdir(real_path)) if s.endswith('SDP')]
with open('/home/yfzhang/PycharmProjects/fairmot/src/data/mot17.half', 'w') as f:
for seq_name in seq_names:
seq_path = os.path.join(real_path, seq_name)
seq_path = os.path.join(seq_path, 'img1')
images = sorted(glob.glob(seq_path + '/*.jpg'))
len_all = len(images)
len_half = int(len_all / 2)
for i in range(len_half):
image = images[i]
print(image[22:], file=f)
f.close()
def gen_data_path_mot17_val(root_path):
mot_path = 'MOT17/images/train'
real_path = os.path.join(root_path, mot_path)
seq_names = [s for s in sorted(os.listdir(real_path)) if s.endswith('SDP')]
with open('/home/yfzhang/PycharmProjects/fairmot2/src/data/mot17.val', 'w') as f:
for seq_name in seq_names:
seq_path = os.path.join(real_path, seq_name)
seq_path = os.path.join(seq_path, 'img1')
images = sorted(glob.glob(seq_path + '/*.jpg'))
len_all = len(images)
len_half = int(len_all / 2)
for i in range(len_half, len_all):
image = images[i]
print(image[22:], file=f)
f.close()
def gen_data_path_mot17_emb(root_path):
mot_path = 'MOT17/images/train'
real_path = os.path.join(root_path, mot_path)
seq_names = [s for s in sorted(os.listdir(real_path)) if s.endswith('SDP')]
with open('/home/yfzhang/PycharmProjects/fairmot2/src/data/mot17.emb', 'w') as f:
for seq_name in seq_names:
seq_path = os.path.join(real_path, seq_name)
seq_path = os.path.join(seq_path, 'img1')
images = sorted(glob.glob(seq_path + '/*.jpg'))
len_all = len(images)
len_half = int(len_all / 2)
for i in range(len_half, len_all, 3):
image = images[i]
print(image[22:], file=f)
f.close()
if __name__ == '__main__':
root = '/data/yfzhang/MOT/JDE'
gen_data_path_mot17_emb(root)