moe 8 exp no freeze
Browse files
script.py
CHANGED
|
@@ -51,38 +51,38 @@ print('Define Model')
|
|
| 51 |
# model_path = './checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 52 |
# model.load_state_dict(torch.load(model_path, map_location=device))
|
| 53 |
|
| 54 |
-
# LCNN MODEL
|
| 55 |
-
model = LCNN(return_emb=False).to(device)
|
| 56 |
-
# model_path = './checkpoints/LCNN_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 57 |
-
# model_path = './checkpoints/LCNN_ALL_DATA.pth'
|
| 58 |
-
# model_path = './checkpoints/LCNN_ALL_DATA_AUG.pth'
|
| 59 |
-
# model_path = './checkpoints/LCNN_ALL_DATA_TTS_AUG.pth'
|
| 60 |
-
model_path = './checkpoints/LCNN_ALL_DATA_TTS_MOD.pth'
|
| 61 |
-
model.load_state_dict(torch.load(model_path, map_location=device))
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
# #
|
| 72 |
-
# #
|
| 73 |
-
|
| 74 |
-
#
|
| 75 |
-
# #
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
#
|
| 82 |
-
#
|
| 83 |
-
#
|
| 84 |
# model_path = './checkpoints/MOE_TRANSF_8EXP_AUG.pth'
|
| 85 |
-
|
| 86 |
|
| 87 |
|
| 88 |
model = (model).to(device)
|
|
@@ -96,18 +96,18 @@ print('Loaded Weights')
|
|
| 96 |
# del model
|
| 97 |
# model = Model().to(device)
|
| 98 |
|
| 99 |
-
SAMPLING_RATE_CODES = {
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
seen_frequencies = set()
|
| 111 |
|
| 112 |
# iterate over the dataset
|
| 113 |
out = []
|
|
@@ -151,17 +151,17 @@ for el in tqdm.tqdm(dataset_remote):
|
|
| 151 |
# "id" and "pred" are required. "score" will not be used in scoring but we encourage you to include it. We'll use it for analysis of the results
|
| 152 |
|
| 153 |
# RUNNING ON HUGGINGFACE
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
freq = sr if sr in SAMPLING_RATE_CODES else "other"
|
| 157 |
-
|
| 158 |
-
# Assegna total_time: codice se è la prima occorrenza, 0 altrimenti
|
| 159 |
-
if freq not in seen_frequencies:
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
# else:
|
| 163 |
-
# total_time = 0
|
| 164 |
-
total_time = 1
|
| 165 |
|
| 166 |
out.append(dict(id=el["id"], pred=pred, score=score, time=total_time))
|
| 167 |
# # RUNNING LOCALLY
|
|
|
|
| 51 |
# model_path = './checkpoints/RAWNET_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 52 |
# model.load_state_dict(torch.load(model_path, map_location=device))
|
| 53 |
|
| 54 |
+
# # LCNN MODEL
|
| 55 |
+
# model = LCNN(return_emb=False).to(device)
|
| 56 |
+
# # model_path = './checkpoints/LCNN_ASVSPOOF_FOR_INTHEWILD_PURDUE.pth'
|
| 57 |
+
# # model_path = './checkpoints/LCNN_ALL_DATA.pth'
|
| 58 |
+
# # model_path = './checkpoints/LCNN_ALL_DATA_AUG.pth'
|
| 59 |
+
# # model_path = './checkpoints/LCNN_ALL_DATA_TTS_AUG.pth'
|
| 60 |
+
# model_path = './checkpoints/LCNN_ALL_DATA_TTS_MOD.pth'
|
| 61 |
+
# model.load_state_dict(torch.load(model_path, map_location=device))
|
| 62 |
|
| 63 |
+
# MOE MODEL
|
| 64 |
+
expert_1 = LCNN(return_emb=True).to(device)
|
| 65 |
+
expert_2 = LCNN(return_emb=True).to(device)
|
| 66 |
+
expert_3 = LCNN(return_emb=True).to(device)
|
| 67 |
+
expert_4 = LCNN(return_emb=True).to(device)
|
| 68 |
+
expert_5 = LCNN(return_emb=True).to(device)
|
| 69 |
+
expert_6 = LCNN(return_emb=True).to(device)
|
| 70 |
+
|
| 71 |
+
# # model = UltimateMOE(experts=[expert_1, expert_2, expert_3, expert_4])
|
| 72 |
+
# # model_path = './checkpoints/MOE_ULTIMATE.pth'
|
| 73 |
+
|
| 74 |
+
# model = MOE_attention(experts=[expert_1, expert_2, expert_3, expert_4, expert_5, expert_6], device=device)
|
| 75 |
+
# # model_path = './checkpoints/MOE_ATTENTION.pth'
|
| 76 |
+
# model_path = './checkpoints/MOE_TRANSF.pth'
|
| 77 |
+
|
| 78 |
+
expert_7 = LCNN(return_emb=True).to(device)
|
| 79 |
+
expert_8 = LCNN(return_emb=True).to(device)
|
| 80 |
+
model = MOE_attention(experts=[expert_1, expert_2, expert_3, expert_4, expert_5, expert_6, expert_7, expert_8], device=device, freezing=True)
|
| 81 |
+
# model_path = './checkpoints/MOE_TRANSF_7EXP.pth'
|
| 82 |
+
# model_path = './checkpoints/MOE_TRANSF_7EXP_AUG.pth'
|
| 83 |
+
# model_path = './checkpoints/MOE_TRANSF_7EXP_AUG_NO_FREEZE.pth'
|
| 84 |
# model_path = './checkpoints/MOE_TRANSF_8EXP_AUG.pth'
|
| 85 |
+
model_path = './checkpoints/MOE_TRANSF_8EXP_AUG_NO_FREEZE.pth'
|
| 86 |
|
| 87 |
|
| 88 |
model = (model).to(device)
|
|
|
|
| 96 |
# del model
|
| 97 |
# model = Model().to(device)
|
| 98 |
|
| 99 |
+
# SAMPLING_RATE_CODES = {
|
| 100 |
+
# 8000: 2,
|
| 101 |
+
# 16000: 3,
|
| 102 |
+
# 22050: 5,
|
| 103 |
+
# 24000: 7,
|
| 104 |
+
# 32000: 11,
|
| 105 |
+
# 44100: 13,
|
| 106 |
+
# 48000: 17,
|
| 107 |
+
# "other": 19
|
| 108 |
+
# }
|
| 109 |
+
#
|
| 110 |
+
# seen_frequencies = set()
|
| 111 |
|
| 112 |
# iterate over the dataset
|
| 113 |
out = []
|
|
|
|
| 151 |
# "id" and "pred" are required. "score" will not be used in scoring but we encourage you to include it. We'll use it for analysis of the results
|
| 152 |
|
| 153 |
# RUNNING ON HUGGINGFACE
|
| 154 |
+
total_time = time.time() - start_time
|
| 155 |
+
|
| 156 |
+
# freq = sr if sr in SAMPLING_RATE_CODES else "other"
|
| 157 |
+
#
|
| 158 |
+
# # Assegna total_time: codice se è la prima occorrenza, 0 altrimenti
|
| 159 |
+
# if freq not in seen_frequencies:
|
| 160 |
+
# total_time = SAMPLING_RATE_CODES[freq]
|
| 161 |
+
# seen_frequencies.add(freq)
|
| 162 |
+
# # else:
|
| 163 |
+
# # total_time = 0
|
| 164 |
+
# total_time = 1
|
| 165 |
|
| 166 |
out.append(dict(id=el["id"], pred=pred, score=score, time=total_time))
|
| 167 |
# # RUNNING LOCALLY
|