Example #1
0
def aggregate(model: Model, output_file: Path, n_tracks: Optional[int] = None):
    tracks = tqdm(Track.get_all(limit=n_tracks), desc=str(model))
    embeddings = model.get_embeddings_from_file(tracks)
    embeddings = np.vstack(embeddings)
    embeddings = embeddings.astype(np.float16)
    np.save(output_file, embeddings)
Example #2
0
def _get_mean_and_std(model: Model, tracks: Iterable[Track]):
    embeddings = model.get_embeddings_from_file(tracks)
    embeddings_stacked = np.vstack(embeddings)
    return embeddings_stacked.mean(axis=0), embeddings_stacked.std(axis=0)