Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pesto
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
pesto
Commits
bf678a83
Commit
bf678a83
authored
1 year ago
by
Paul Best
Browse files
Options
Downloads
Patches
Plain Diff
small fixes
parent
beccc9d8
Branches
main
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
pesto/data.py
+8
-0
8 additions, 0 deletions
pesto/data.py
pesto/loader.py
+1
-1
1 addition, 1 deletion
pesto/loader.py
pesto/model.py
+1
-1
1 addition, 1 deletion
pesto/model.py
pesto/utils/hcqt.py
+1
-1
1 addition, 1 deletion
pesto/utils/hcqt.py
with
11 additions
and
3 deletions
pesto/data.py
+
8
−
0
View file @
bf678a83
...
@@ -2,6 +2,7 @@ from typing import Optional
...
@@ -2,6 +2,7 @@ from typing import Optional
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
from
torchaudio
import
functional
as
taudio
from
.utils
import
HarmonicCQT
from
.utils
import
HarmonicCQT
...
@@ -45,6 +46,9 @@ class Preprocessor(nn.Module):
...
@@ -45,6 +46,9 @@ class Preprocessor(nn.Module):
# if the sampling rate is provided, instantiate the CQT kernels
# if the sampling rate is provided, instantiate the CQT kernels
if
sampling_rate
is
not
None
:
if
sampling_rate
is
not
None
:
top_bin
=
hcqt_kwargs
[
'
fmin
'
]
*
2
**
(
hcqt_kwargs
[
'
n_bins
'
]
/
hcqt_kwargs
[
'
bins_per_semitone
'
]
/
12
)
if
sampling_rate
/
2
<
top_bin
:
sampling_rate
=
int
(
round
(
top_bin
*
1e-3
)
*
2e3
)
self
.
hcqt_sr
=
sampling_rate
self
.
hcqt_sr
=
sampling_rate
self
.
_reset_hcqt_kernels
()
self
.
_reset_hcqt_kernels
()
...
@@ -60,6 +64,10 @@ class Preprocessor(nn.Module):
...
@@ -60,6 +64,10 @@ class Preprocessor(nn.Module):
torch.Tensor: log-magnitude CQT of batch of CQTs,
torch.Tensor: log-magnitude CQT of batch of CQTs,
shape (batch_size?, num_timesteps, num_harmonics, num_freqs)
shape (batch_size?, num_timesteps, num_harmonics, num_freqs)
"""
"""
if
sr
<
self
.
hcqt_sr
:
x
,
sr
=
taudio
.
resample
(
x
,
sr
,
self
.
hcqt_sr
),
self
.
hcqt_sr
# compute CQT from input waveform, and invert dims for (time_steps, num_harmonics, freq_bins)
# compute CQT from input waveform, and invert dims for (time_steps, num_harmonics, freq_bins)
# in other words, time becomes the batch dimension, enabling efficient processing for long audios.
# in other words, time becomes the batch dimension, enabling efficient processing for long audios.
complex_cqt
=
torch
.
view_as_complex
(
self
.
hcqt
(
x
,
sr
=
sr
)).
permute
(
0
,
3
,
1
,
2
)
complex_cqt
=
torch
.
view_as_complex
(
self
.
hcqt
(
x
,
sr
=
sr
)).
permute
(
0
,
3
,
1
,
2
)
...
...
This diff is collapsed.
Click to expand it.
pesto/loader.py
+
1
−
1
View file @
bf678a83
...
@@ -44,7 +44,7 @@ def load_model(checkpoint: str,
...
@@ -44,7 +44,7 @@ def load_model(checkpoint: str,
model
=
PESTO
(
encoder
,
model
=
PESTO
(
encoder
,
preprocessor
=
preprocessor
,
preprocessor
=
preprocessor
,
crop_kwargs
=
hparams
[
"
pitch_shift
"
],
crop_kwargs
=
hparams
[
"
pitch_shift
"
],
reduction
=
hparams
[
"
reduction
"
]
)
reduction
=
"
awa
"
)
model
.
load_state_dict
(
state_dict
,
strict
=
False
)
model
.
load_state_dict
(
state_dict
,
strict
=
False
)
model
.
eval
()
model
.
eval
()
...
...
This diff is collapsed.
Click to expand it.
pesto/model.py
+
1
−
1
View file @
bf678a83
...
@@ -138,7 +138,7 @@ class Resnet1d(nn.Module):
...
@@ -138,7 +138,7 @@ class Resnet1d(nn.Module):
Args:
Args:
x (torch.Tensor): shape (batch, channels, freq_bins)
x (torch.Tensor): shape (batch, channels, freq_bins)
"""
"""
x
=
self
.
layernorm
(
x
)
x
=
self
.
layernorm
(
x
.
unsqueeze
(
1
)
)
x
=
self
.
conv1
(
x
)
x
=
self
.
conv1
(
x
)
for
p
in
range
(
0
,
self
.
n_prefilt_layers
-
1
):
for
p
in
range
(
0
,
self
.
n_prefilt_layers
-
1
):
...
...
This diff is collapsed.
Click to expand it.
pesto/utils/hcqt.py
+
1
−
1
View file @
bf678a83
...
@@ -104,7 +104,7 @@ def create_cqt_kernels(
...
@@ -104,7 +104,7 @@ def create_cqt_kernels(
freqs
=
fmin
*
2.0
**
(
np
.
r_
[
0
:
n_bins
]
/
float
(
bins_per_octave
))
freqs
=
fmin
*
2.0
**
(
np
.
r_
[
0
:
n_bins
]
/
float
(
bins_per_octave
))
else
:
else
:
warnings
.
warn
(
"
If fmax is given, n_bins will be ignored
"
,
SyntaxWarning
)
#
warnings.warn("If fmax is given, n_bins will be ignored", SyntaxWarning)
n_bins
=
np
.
ceil
(
n_bins
=
np
.
ceil
(
bins_per_octave
*
np
.
log2
(
fmax
/
fmin
)
bins_per_octave
*
np
.
log2
(
fmax
/
fmin
)
)
# Calculate the number of bins
)
# Calculate the number of bins
...
...
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