Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
Vocal Repertoire Embedder
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Paul Best
Vocal Repertoire Embedder
Commits
15bb7524
Commit
15bb7524
authored
2 years ago
by
Paul Best
Browse files
Options
Downloads
Patches
Plain Diff
fix Mel and humpback
parent
27d0829a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
plot_results_hdbcsan.py
+29
-0
29 additions, 0 deletions
plot_results_hdbcsan.py
plot_results_kmeans.py
+35
-0
35 additions, 0 deletions
plot_results_kmeans.py
run_baseline.py
+36
-0
36 additions, 0 deletions
run_baseline.py
with
100 additions
and
0 deletions
plot_results_hdbcsan.py
0 → 100644
+
29
−
0
View file @
15bb7524
import
hdbscan
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
sklearn
import
metrics
species
=
np
.
loadtxt
(
'
good_species.txt
'
,
dtype
=
str
)
frontends
=
[
'
16_pcenMel128
'
,
'
16_logMel128
'
,
'
16_logSTFT
'
,
'
16_Mel128
'
,
'
8_pcen64
'
,
'
32_pcenMel128
'
]
plt
.
figure
()
for
specie
in
species
:
df
=
pd
.
read_csv
(
f
'
{
specie
}
/
{
specie
}
.csv
'
)
for
i
,
frontend
in
enumerate
(
frontends
):
print
(
specie
,
frontend
)
dic
=
np
.
load
(
f
'
{
specie
}
/encodings_
{
specie
}
_
{
frontend
}
_sparrow_encoder_decod2_BN_nomaxPool.npy
'
,
allow_pickle
=
True
).
item
()
idxs
,
encodings
,
X
=
dic
[
'
idxs
'
],
dic
[
'
encodings
'
],
dic
[
'
umap
'
]
clusters
=
hdbscan
.
HDBSCAN
(
min_cluster_size
=
5
,
min_samples
=
None
,
cluster_selection_epsilon
=
0.0
,
core_dist_n_jobs
=-
1
,
cluster_selection_method
=
'
best
'
).
fit_predict
(
X
)
df
.
loc
[
idxs
,
'
cluster
'
]
=
clusters
.
astype
(
int
)
mask
=
~
df
.
loc
[
idxs
].
label
.
isna
()
clusters
,
labels
=
clusters
[
mask
],
df
.
loc
[
idxs
[
mask
]].
label
plt
.
scatter
(
metrics
.
normalized_mutual_info_score
(
labels
,
clusters
),
i
,
label
=
specie
)
df
.
drop
(
'
cluster
'
,
inplace
=
True
)
plt
.
ytick_labels
(
range
(
len
(
frontends
)),
frontends
)
plt
.
ylabel
(
'
archi
'
)
plt
.
xlabel
(
'
NMI with expert labels
'
)
plt
.
grid
()
plt
.
legend
()
plt
.
savefig
(
'
NMIs_hdbscan.pdf
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plot_results_kmeans.py
0 → 100644
+
35
−
0
View file @
15bb7524
import
hdbscan
import
pandas
as
pd
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
sklearn
import
metrics
,
cluster
from
scipy.stats
import
linregress
species
=
np
.
loadtxt
(
'
good_species.txt
'
,
dtype
=
str
)
frontends
=
[
'
16_pcenMel128
'
,
'
16_logMel128
'
,
'
16_logSTFT
'
,
'
16_Mel128
'
,
'
8_pcen64
'
,
'
32_pcenMel128
'
]
plt
.
figure
()
for
specie
in
species
:
df
=
pd
.
read_csv
(
f
'
{
specie
}
/
{
specie
}
.csv
'
)
for
i
,
frontend
in
enumerate
(
frontends
):
print
(
specie
,
frontend
)
dic
=
np
.
load
(
f
'
{
specie
}
/encodings_
{
specie
}
_
{
frontend
}
_sparrow_encoder_decod2_BN_nomaxPool.npy
'
,
allow_pickle
=
True
).
item
()
idxs
,
encodings
,
X
=
dic
[
'
idxs
'
],
dic
[
'
encodings
'
],
dic
[
'
umap
'
]
ks
=
(
5
*
1.2
**
np
.
arange
(
20
)).
astype
(
int
)
distorsions
=
[
cluster
.
KMeans
(
n_clusters
=
k
).
fit
(
encodings
).
inertia_
for
k
in
ks
]
errors
=
[
linregress
(
ks
[:
i
],
distorsions
[:
i
]).
stderr
+
linregress
(
ks
[
i
+
1
:],
distorsions
[
i
+
1
:]).
stderr
for
i
in
range
(
2
,
len
(
ks
)
-
2
)]
k
=
ks
[
np
.
argmin
(
errors
)]
clusters
=
cluster
.
KMeans
(
n_clusters
=
k
).
fit_predict
(
encodings
)
df
.
loc
[
idxs
,
'
cluster
'
]
=
clusters
.
astype
(
int
)
mask
=
~
df
.
loc
[
idxs
].
label
.
isna
()
clusters
,
labels
=
clusters
[
mask
],
df
.
loc
[
idxs
[
mask
]].
label
plt
.
scatter
(
metrics
.
normalized_mutual_info_score
(
labels
,
clusters
),
i
,
label
=
specie
)
df
.
drop
(
'
cluster
'
,
inplace
=
True
)
plt
.
ytick_labels
(
range
(
len
(
frontends
)),
frontends
)
plt
.
ylabel
(
'
archi
'
)
plt
.
xlabel
(
'
NMI with expert labels
'
)
plt
.
grid
()
plt
.
legend
()
plt
.
savefig
(
'
NMIs_kmeans.pdf
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
run_baseline.py
0 → 100644
+
36
−
0
View file @
15bb7524
from
tqdm
import
tqdm
from
soundsig.sound
import
Biosound
import
soundfile
as
sf
import
argparse
import
pandas
as
pd
import
models
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
"
specie
"
,
type
=
str
)
args
=
parser
.
parse_args
()
df
=
pd
.
read_csv
(
f
'
{
args
.
specie
}
/
{
args
.
specie
}
.csv
'
)
def
norm
(
arr
):
return
(
arr
-
np
.
mean
(
arr
)
)
/
np
.
std
(
arr
)
meta
=
models
.
meta
[
args
.
specie
]
for
idx
,
row
in
tqdm
(
df
.
iterrows
(),
total
=
len
(
df
)):
info
=
sf
.
info
(
self
.
audiopath
+
row
.
fn
)
dur
,
fs
=
info
.
duration
,
info
.
samplerate
start
=
int
(
np
.
clip
(
row
.
pos
-
meta
[
'
sampleDur
'
]
/
2
,
0
,
max
(
0
,
dur
-
meta
[
'
sampleDur
'
]))
*
fs
)
sig
,
fs
=
sf
.
read
(
self
.
audiopath
+
row
.
fn
,
start
=
start
,
stop
=
start
+
int
(
meta
[
'
sampleDur
'
]
*
fs
))
if
sig
.
ndim
==
2
:
sig
=
sig
[:,
0
]
if
len
(
sig
)
<
meta
[
'
sampleDur
'
]
*
fs
:
sig
=
np
.
concatenate
([
sig
,
np
.
zeros
(
int
(
self
.
sampleDur
*
fs
)
-
len
(
sig
))])
sound
=
BioSound
(
soundWave
=
norm
(
sig
),
fs
=
fs
)
sound
.
spectroCalc
(
max_freq
=
meta
[
'
sr
'
]
//
2
)
sound
.
rms
=
myBioSound
.
sound
.
std
()
sound
.
ampenv
(
cutoff_freq
=
20
,
amp_sample_rate
=
1000
)
sound
.
spectrum
(
f_high
=
10000
)
sound
.
fundest
(
maxFund
=
1500
,
minFund
=
300
,
lowFc
=
200
,
highFc
=
6000
,
minSaliency
=
0.5
,
debugFig
=
0
,
minFormantFreq
=
500
,
maxFormantBW
=
500
,
windowFormant
=
0.1
,
method
=
'
Stack
'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment