Created
January 11, 2020 16:14
-
-
Save Hiroshiba/4f9095c91885f776c2e98e2d813ecb2e to your computer and use it in GitHub Desktop.
JVSデータでの話者re-identifierの精度評価
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import numpy | |
from scipy.spatial.distance import cdist | |
def load_vector(path_format: Path): | |
predicted_vectors = [] | |
true_speaker_nums = [] | |
for speaker_num in range(100): | |
if speaker_num in (5, 27): | |
continue | |
for i in range(5): | |
true_speaker_nums.append(speaker_num) | |
predicted_vectors.append(numpy.load(str(path_format).format(speaker_num=speaker_num, i=i))) | |
return ( | |
numpy.asarray(predicted_vectors), | |
numpy.asarray(true_speaker_nums), | |
) | |
def main(): | |
path_format = Path('/path/to/vectors/{speaker_num}-{i}.npy') | |
predicted_vectors, true_speaker_nums = load_vector(path_format=path_format) | |
# top1 | |
distance = cdist(predicted_vectors, predicted_vectors) | |
top1_index = numpy.argsort(distance, axis=1)[:, 1] | |
top1_speaker_nums = true_speaker_nums[top1_index] | |
# result | |
rate = (top1_speaker_nums == true_speaker_nums).mean() | |
print('rate', rate) | |
breakpoint() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment