-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake.py
40 lines (35 loc) · 1010 Bytes
/
make.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
from glob import glob
import os
train_path = os.getcwd()+'/train/'
val_path = os.getcwd()+'/val/'
label = 0
arr = []
filename = []
for root, ds, fs in os.walk(train_path):
for d in ds:
arr.append(d)
arr.sort()
for i in range(0, 1000):
filepath = os.path.join(root, arr[i])
#print(filepath)
list = os.listdir(filepath)
for j in range(len(list)):
filename.append("train/"+arr[i]+"/"+list[j]+"\t"+str(i)+"\n")
with open('train_map.txt', 'w') as f:
f.writelines(filename)
break
arr = []
filename = []
for root, ds, fs in os.walk(val_path):
for d in ds:
arr.append(d)
arr.sort()
for i in range(0, 1000):
filepath = os.path.join(root, arr[i])
#print(filepath)
list = os.listdir(file-path)
for j in range(len(list)):
filename.append("val/"+arr[i]+"/"+list[j]+"\t"+str(i)+"\n")
with open('val_map.txt', 'w') as f:
f.writelines(filename)
break