-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathget_car_list.py
54 lines (44 loc) · 1.38 KB
/
get_car_list.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
import os
def get_car_list(tgtdir, listfn):
car_dirs = os.listdir(tgtdir)
carlist = open(listfn, 'w')
for car in car_dirs:
car_dir = tgtdir + '/' + car
car_files = os.listdir(car_dir)
linetxt = car_dir
for onecf in car_files:
linetxt += ',' + onecf
carlist.write(linetxt + '\n')
carlist.close()
def get_part_car_list(tgtdir, listfn, prenum):
car_dirs = os.listdir(tgtdir)
carlist = open(listfn, 'w')
for car in car_dirs:
if prenum>0 and int(car) >= prenum:
continue
car_dir = tgtdir + '/' + car
car_files = os.listdir(car_dir)
linetxt = car_dir
for onecf in car_files:
linetxt += ',' + onecf
carlist.write(linetxt + '\n')
carlist.close()
def get_part_car_each_list(tgtdir, listfn, prenum):
car_dirs = os.listdir(tgtdir)
carlist = open(listfn, 'w')
for car in car_dirs:
if prenum>0 and int(car) >= prenum:
continue
car_dir = tgtdir + '/' + car
car_files = os.listdir(car_dir)
linetxt = car_dir
for onecf in car_files:
linetxttmp = linetxt + ',' + onecf
carlist.write(linetxttmp + '\n')
carlist.close()
if __name__=='__main__':
tgtdir = "/media/data1/mzhang/data/car_ReID_for_zhangming/data"
tgtdir = "/home/mingzhang/data/car_ReID_for_zhangming/data"
listfn = "data_each.500.list"
get_part_car_each_list(tgtdir, listfn, 500)
# get_part_car_list(tgtdir, listfn, 10)