-
Notifications
You must be signed in to change notification settings - Fork 0
/
8. Salient计数统计代码
52 lines (46 loc) · 1.22 KB
/
8. Salient计数统计代码
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
count0=0
count1=0
count2=0
count3=0
count4=0
count5=0
count6=0
count7=0
count8=0
create_file = open('SOC_Subitizing.txt', 'w')
pic_names = [i[:-4] for i in os.listdir('./gt/') if 'png' in i]
for pic_name in pic_names:
if (os.path.exists('./Instance name/' + pic_name + '.txt') == True):
file = open('./Instance name/' + pic_name + '.txt', 'r')
line_number = file.readlines()
create_file.write(str(pic_name) + ',' + str(len(line_number)) + '\n')
if len(line_number) == 1:
count1 +=1
elif len(line_number) == 2:
count2 += 1
elif len(line_number) == 3:
count3 += 1
elif len(line_number) == 4:
count4 += 1
elif len(line_number) == 5:
count5 += 1
elif len(line_number) == 6:
count6 += 1
elif len(line_number) == 7:
count7 += 1
elif len(line_number) == 8:
count8 += 1
else:
create_file.write(str(pic_name) + ',0' + '\n')
count0 +=1
print(count0)
print(count1)
print(count2)
print(count3)
print(count4)
print(count5)
print(count6)
print(count7)
print(count8)
print(count0+count1+count2+count3+count4+count5+count6+count7+count8)