From 07a0017060a2cbddc7cf19936285268e46b51cf3 Mon Sep 17 00:00:00 2001
From: lamipaul <paulobest25@gmail.com>
Date: Wed, 24 May 2023 15:21:41 +0200
Subject: [PATCH] update readmes

---
 new_specie/README.md        |  2 +-
 new_specie/print_annot.py   | 55 +++++++++++++++++++++++++++++++++++++
 paper_experiments/README.md | 11 ++++++++
 3 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100755 new_specie/print_annot.py
 create mode 100755 paper_experiments/README.md

diff --git a/new_specie/README.md b/new_specie/README.md
index 7a9c781..19eff3b 100755
--- a/new_specie/README.md
+++ b/new_specie/README.md
@@ -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`
diff --git a/new_specie/print_annot.py b/new_specie/print_annot.py
new file mode 100755
index 0000000..ce5591c
--- /dev/null
+++ b/new_specie/print_annot.py
@@ -0,0 +1,55 @@
+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()
diff --git a/paper_experiments/README.md b/paper_experiments/README.md
new file mode 100755
index 0000000..5340d03
--- /dev/null
+++ b/paper_experiments/README.md
@@ -0,0 +1,11 @@
+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`
-- 
GitLab