-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlabel.py
42 lines (34 loc) · 898 Bytes
/
label.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
import os
file = open("labels.txt","w")
cnt=0
for path, subdirs, files in os.walk('./test_images/'):
for name in files:
if cnt==0:
cnt=cnt+1
continue
else:
img_path = os.path.join(path,name)
t1,t2=os.path.split(img_path)
w,folder,correct_cat=t1.split('/')
x,end=t2.split('.')
if end=='jpg':
if correct_cat == "0":
label = 0
elif correct_cat == "1":
label = 1
elif correct_cat == "2":
label = 2
elif correct_cat == "3":
label = 3
elif correct_cat == "4":
label = 4
elif correct_cat == 5:
label = 5
elif correct_cat == "6":
label = 6
else:
label = 7
temp = img_path + " " + str(label) + "\n"
file.write(temp)
cnt=cnt+1
print(cnt)