-
Notifications
You must be signed in to change notification settings - Fork 3
/
summarize_results_Cat2.py
124 lines (122 loc) · 4.1 KB
/
summarize_results_Cat2.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import xlwt
from argparse import ArgumentParser
parser = ArgumentParser(description='LSRN-PCGC summarize results')
parser.add_argument('-model', '--model', default='LSRN', type=str,
help='LSRN')
parser.add_argument('-act', '--activation', default='Sine', type=str,
help='Sine')
parser.add_argument('-bc', '--base_channel', type=int, default=16,
help='base channel (default: 16)')
parser.add_argument('-nl', '--num_layers', type=int, default=1,
help='Number of layers (default: 1)')
parser.add_argument('-D', '--D', type=int, default=2,
help='neighbors (2D+1)^3-1')
parser.add_argument('-precision', '--precision', type=int, default=16,
help=' (default: 16)')
parser.add_argument('-fsr', '--frame_sampling_rate', type=int, default=10,
help='#frame sampling rate (default: 10)')
parser.add_argument('-lr', '--lr', type=float, default=1e-3,
help='learning rate (default: 1e-3)')
parser.add_argument('-bs', '--batch_size', type=int, default=2048,
help='batch size (default: 2048)')
parser.add_argument('-e', '--epochs', type=int, default=150,
help='number of epochs to train (default: 150)')
args = parser.parse_args()
logpath = 'logs_eval/' # eval
fs_base = '{}_{}_bc{}_nl{}_D{}_p{}_lr{}_fsr{}_bs{}_e{}'
format_str = fs_base.format(args.model, args.activation, args.base_channel, args.num_layers, args.D,
args.precision, args.lr, args.frame_sampling_rate, args.batch_size, args.epochs)
excel_file = '{}.xls'.format(format_str)
datasetname_lst = list([
'loot',
'redandblack',
'soldier',
'queen',
'longdress',
'basketball_player_vox11',
'dancer_vox11',
# 'queen_frame_0200_n.ply',
])
pqs_lst = list([
64,
32,
16,
8,
4,
2,
])
wbk = xlwt.Workbook()
sheet = wbk.add_sheet('C2 lossyG,lossyA,intra', cell_overwrite_ok=True)
output = open('{}.txt'.format(format_str), 'w')
file_lst = list()
for name in datasetname_lst:
for pqs in pqs_lst:
file_lst.append(logpath+format_str+'_{}_pqs{}'.format(name, pqs))
row = 0
col = 0
missed = 0
for k, file_name in enumerate(file_lst):
print(file_name)
record = list()
netparam = 0
base = 0
points = 0
D1 = 0
D2 = 0
nF = 0
try:
reader = open(file_name, 'r')
for line in reader:
words = line.split()
if ('network' in words) :
netparam = int(words[-2])
if ('scaling' in words):
points += int(words[-2][:-1])
nF += 1
if (('mseF,PSNR' in words) and ('(p2point):' in words)):
D1 += float(words[2])
if (('mseF,PSNR' in words) and ('(p2plane):' in words)):
D2 += float(words[2])
if (('Total' in words) and ('bitstream' in words)) :
base += int(words[3]) * 8
reader.close()
D1 = D1 / nF
D2 = D2 / nF
except IOError:
print('No files found!')
base = int(base / 2) # encoder+decoder
geom = base + netparam
total = geom
print(points, geom, base, netparam, D1, D2)
if base != 0:
if points != 0:
record.append(str(points))
sheet.write(row, col, points)
if total != 0:
record.append(str(total))
sheet.write(row, col+1, total)
if geom != 0:
record.append(str(base))
sheet.write(row, col+2, base)
record.append(str(netparam))
sheet.write(row, col+3, netparam)
if D1 != 0:
record.append(str(D1))
sheet.write(row, col+5, D1)
if D2 != 0:
record.append(str(D2))
sheet.write(row, col+6, D2)
record_str = ''
row = row + 1
else:
missed += 1
record_str = ''
if (k+1)%6==0: # 6 rate points / pc
row = row + missed
missed = 0
for word in record:
record_str = record_str + str(word) + ' '
record_str = record_str + '\n'
output.write(record_str)
output.close()
wbk.save(excel_file)