Commit 75fdd313 authored by Colleen Beaumard's avatar Colleen Beaumard
Browse files
parents 20322684 3af95d6c
......@@ -35,7 +35,9 @@ def build():
feature_size = self.preprocessor.n_mfcc
self.loss = loss
self.speaker_number = speaker_number
self.param_device_detection = nn.Parameter(torch.empty(0)) # Empty parameter used to detect model device location
self.param_device_detection = nn.Parameter(
torch.empty(0)
) # Empty parameter used to detect model device location
self.sequence_network = nn.Sequential(
OrderedDict(
......@@ -113,8 +115,15 @@ def build():
- the x-vector embedding
i.e., (loss, cce), x_vector = model([...])
"""
x = args["speech"].to(self.param_device_detection.device)
x = x.squeeze(1)
# not using data_loading_hook hook
# unly used for SCORING by other scrips "./local/scoring.sh"
if not isinstance(args, dict):
x = args
else:
x = args["speech"].to(self.param_device_detection.device)
x = x.squeeze(1)
x = self.preprocessor(x)
x = self.sequence_network(x)
x = self.stat_pooling(x)
......@@ -223,7 +232,9 @@ def build():
key.non = key.non[ndx.trialmask]
pmiss, pfa = sidekit.bosaris.detplot.rocch(scores[key.tar], scores[key.non])
eer = sidekit.bosaris.detplot.rocch2eer(pmiss, pfa)
print(f"**Test metrics - Test EER = {eer * 100} %")
# print(f"**Test metrics - Test EER = {eer * 100} %")
norm_eer = None # no norm EER
return eer, norm_eer
def new_epoch_hook(self, current_epoch, total_epoch):
pass
......@@ -281,6 +292,7 @@ def get_data_loading_hook(sessions):
return _hook
# Custom data collate for padding with zeroes
# when the whole audio file is considered
def collate_hook(batch):
......@@ -294,9 +306,17 @@ def collate_hook(batch):
target_spk_list.append(target)
# Pad tensors lists if required and construct output data
out_speech = nn.utils.rnn.pad_sequence(data_speech_list, batch_first=True, padding_value=0.0)
out_f0 = nn.utils.rnn.pad_sequence(data_f0_list, batch_first=True, padding_value=0.0)
out_data_dict = {"speech": out_speech.unsqueeze(1), "F0": out_f0.unsqueeze(1), "emotion": torch.tensor(data_emotion_list)}
out_speech = nn.utils.rnn.pad_sequence(
data_speech_list, batch_first=True, padding_value=0.0
)
out_f0 = nn.utils.rnn.pad_sequence(
data_f0_list, batch_first=True, padding_value=0.0
)
out_data_dict = {
"speech": out_speech.unsqueeze(1),
"F0": out_f0.unsqueeze(1),
"emotion": torch.tensor(data_emotion_list),
}
out_target = torch.tensor(target_spk_list)
return out_data_dict, out_target
......@@ -30,7 +30,7 @@ scheduler:
# Evaluation options
compute_test_eer: false
compute_test_eer: true
log_interval: 50
validation_frequency: 1
......
......@@ -8,7 +8,7 @@ data_dir=${2:-"./data/asv_test_libri"}
trial_wav_scp=$data_dir/trials_wav.scp
enroll_wav_scp=$data_dir/enrolls_wav.scp
trials=$data_dir/trials_test
enroll_utt2spk=$data_dir/utt2spk_enrolls_test
enroll_utt2spk=$data_dir/enrolls_utt2spk
trial_xvector_scp=$data_dir/trials_xvector.scp
enroll_xvector_scp=$data_dir/enrolls_xvector.scp
......@@ -18,13 +18,13 @@ score_file=$data_dir/cosine_scoring.txt
extract_xvectors.py --model $model \
--wav-scp $enroll_wav_scp \
--out-scp $enroll_xvector_scp \
--device "cuda:0" &
--device "cuda:0"
# Extract trials xvector
extract_xvectors.py --model $model \
--wav-scp $trial_wav_scp \
--out-scp $trial_xvector_scp \
--device "cuda:1"
--device "cuda:0"
wait
......
......@@ -995,12 +995,11 @@ def xtrain(dataset_description,
test_eer = None
norm_eer = None
if local_rank < 1:
if local_rank < 1 and training_opts["compute_test_eer"]:
if hasattr(model, 'external_model') and hasattr(model.external_model, 'test'):
model.external_model.test(model_opts, dataset_opts, training_opts, device=device)
if training_opts["compute_test_eer"] and local_rank < 1:
test_eer, norm_eer = test_metrics(model, device, model_opts, dataset_opts, training_opts)
test_eer, norm_eer = model.external_model.test(model_opts, dataset_opts, training_opts, device=device)
else:
test_eer, norm_eer = test_metrics(model, device, model_opts, dataset_opts, training_opts)
monitor.update(test_eer=test_eer,
norm_eer=norm_eer,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment