-
Notifications
You must be signed in to change notification settings - Fork 2
/
ensemble_ntu_cv.py
48 lines (42 loc) · 1.8 KB
/
ensemble_ntu_cv.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
import pickle
import numpy as np
from tqdm import tqdm
# Linear
print('-' * 20 + 'Linear Eval' + '-' * 20)
joint_path = '/mnt/netdisk/zhangjh/Code/AimCLR_loss/work_dir/NTU60/xview/Transformer/joint_MutalDDM_with4parallel_ablmask02/linear_Adam/'
bone_path = '/mnt/netdisk/zhangjh/Code/AimCLR_loss/work_dir/NTU60/xview/Transformer/bone_MutalDDM_with4parallel_ablmask02/linear_tmp_noaug/'
motion_path = '/mnt/netdisk/zhangjh/Code/AimCLR_loss/work_dir/NTU60/xview/Transformer/motion_MutalDDM_with4parallel_ablmask/linear_tmp/'
#label = open('/mnt/netdisk/linlilang/CrosSCLR/data/NTU-RGB-D_120/xset/val_label.pkl', 'rb')
label = open('/mnt/netdisk/linlilang/CrosSCLR/data/NTU-RGB-D/xview/val_label.pkl', 'rb')
label = np.array(pickle.load(label))
r1 = open(joint_path + 'test_result.pkl', 'rb')
r1 = list(pickle.load(r1).items())
r2 = open(bone_path + 'test_result.pkl', 'rb')
r2 = list(pickle.load(r2).items())
r3 = open(motion_path + 'test_result.pkl', 'rb')
r3 = list(pickle.load(r3).items())
alpha1 = [0.5,0.5,0.5]# average fusion
alpha2 = [0.6, 0.6, 0.4] # aimclr weighted fusion
if 1:
best = 0.0
best_weight = []
for alpha in [alpha1,alpha2]:
right_num = total_num = right_num_5 = 0
for i in tqdm(range(len(label[0]))):
_, l = label[:, i]
_, r11 = r1[i]
_, r22 = r2[i]
_, r33 = r3[i]
r = r11 * alpha[0] + r22 * alpha[1] + r33 * alpha[2]
rank_5 = r.argsort()[-5:]
right_num_5 += int(int(l) in rank_5)
r = np.argmax(r)
right_num += int(r == int(l))
total_num += 1
acc = right_num / total_num
acc5 = right_num_5 / total_num
if acc> best:
best = acc
best_weight = alpha
print(alpha, 'top1: ', acc)
print(best_weight, best)