Skip to content
Snippets Groups Projects
Commit 07a00170 authored by Paul Best's avatar Paul Best
Browse files

update readmes

parent 0aeeca5d
No related branches found
No related tags found
No related merge requests found
......@@ -8,4 +8,4 @@ sort_cluster.py
use `python myscript.py --help` to get more information on each scripts' usage
required packages can be install using `pip install -r requirements.txt requirements.txt`
required packages can be install using `pip install -r requirements.txt`
import soundfile as sf
import os
from tqdm import tqdm
import matplotlib.pyplot as plt
import soundfile as sf
import pandas as pd, numpy as np
import models, utils as u
import torch
from filterbank import MelFilter, STFT, Log1p, MedFilt
fs = 44_100
sampleDur = 2.5
nMel = 96
hop = 260
width = int((sampleDur * fs - 2048)/hop) + 1
pad_width = int((1 * fs)/hop) + 1
frontend = torch.nn.Sequential(
STFT(2048, hop),
MelFilter(fs, 2048, 96, 500, 4000),
Log1p(4),
MedFilt()
)
#df = pd.read_csv('S4A09100_20220527$045924.Table.1.selections.txt', delimiter='\t')
#df['filename'] = 'S4A09100_20220527$045924.wav'
#df['pos'] = df['Begin Time (s)'] + 1.25
#df['dur'] = df['End Time (s)'] - df['Begin Time (s)']
#df.drop(df[((df.dur < 2.5)|(df.dur > 8))].index, inplace=True)
df = pd.read_csv('all_annot.csv')
df = df['Cao'] = 'C'
df['pos'] = df['Begin Time (s)'] + 1.25
loader = torch.utils.data.DataLoader(u.Dataset(df, './', fs, 2.5 + 2), batch_size=1, num_workers=8, collate_fn=u.collate_fn)
for x, idx in tqdm(loader):
x = frontend(x).squeeze().detach()[:,pad_width:-pad_width]
plt.figure()
plt.imshow(x, origin='lower', aspect='auto')
plt.subplots_adjust(top=1, bottom=0, left=0, right=1)
plt.savefig(f'gibbon_calls/cao_vit_DL/{idx.item()}')
plt.close()
exit()
sig, fs = sf.read('S4A09100_20220527$045924.wav')
for i, r in tqdm(df.iterrows(), total=len(df)):
# x = frontend(torch.Tensor(sig[int(fs*r['Begin Time (s)']):int(fs*r['End Time (s)']), 1]).unsqueeze(0)).squeeze().detach()
x = frontend(torch.Tensor(sig[int(fs*r['Begin Time (s)']):int(fs*(r['Begin Time (s)']+2.5)), 1]).unsqueeze(0)).squeeze().detach()
plt.imshow(x, origin='lower', aspect='auto', extent=[0, r.dur, 500, 5000])
plt.tight_layout()
plt.savefig(f'gibbon_calls/cao_vit_cut/{i}')
plt.close()
Scripts to run the experiments described in the published paper and plot figures are gathered in this folder.
Specifically :
- train_AE.py to train an auto-encoder for a given dataset
- compute_embeddings.py to use a pretrained auto-encoder to compute vocalisation embeddings
- test_AE.py to cluster given embeddings and compute the NMI with respect to expert labels
- run_XX_baseline.py for baseline feature extraction procedures
- plot_XX.py to plot figures reporting results
use `python myscript.py --help` to get more information on each scripts' usage
required packages can be install using `pip install -r requirements.txt`
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment