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
752df3b7
Commit
752df3b7
authored
1 year ago
by
Ben Hayes
Browse files
Options
Downloads
Patches
Plain Diff
Persist CQT device
parent
afa44099
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
pesto/data.py
+11
-4
11 additions, 4 deletions
pesto/data.py
pesto/utils.py
+1
-1
1 addition, 1 deletion
pesto/utils.py
with
12 additions
and
5 deletions
pesto/data.py
+
11
−
4
View file @
752df3b7
from
typing
import
Optional
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
...
@@ -10,10 +12,12 @@ class DataProcessor(nn.Module):
...
@@ -10,10 +12,12 @@ class DataProcessor(nn.Module):
Args:
Args:
step_size (float): step size between consecutive CQT frames (in SECONDS)
step_size (float): step size between consecutive CQT frames (in SECONDS)
"""
"""
_sampling_rate
:
Optional
[
int
]
=
None
def
__init__
(
self
,
def
__init__
(
self
,
step_size
:
float
,
step_size
:
float
,
bins_per_semitone
:
int
=
3
,
bins_per_semitone
:
int
=
3
,
device
:
torch
.
device
=
torch
.
device
(
"
cpu
"
)
,
sampling_rate
:
int
=
44100
,
**
cqt_kwargs
):
**
cqt_kwargs
):
super
(
DataProcessor
,
self
).
__init__
()
super
(
DataProcessor
,
self
).
__init__
()
self
.
bins_per_semitone
=
bins_per_semitone
self
.
bins_per_semitone
=
bins_per_semitone
...
@@ -31,9 +35,8 @@ class DataProcessor(nn.Module):
...
@@ -31,9 +35,8 @@ class DataProcessor(nn.Module):
self
.
highest_bin
=
self
.
lowest_bin
+
88
*
self
.
bins_per_semitone
self
.
highest_bin
=
self
.
lowest_bin
+
88
*
self
.
bins_per_semitone
# handling different sampling rates
# handling different sampling rates
self
.
_sampling_rate
=
None
self
.
step_size
=
step_size
self
.
step_size
=
step_size
self
.
device
=
devic
e
self
.
sampling_rate
=
sampling_rat
e
def
forward
(
self
,
x
:
torch
.
Tensor
):
def
forward
(
self
,
x
:
torch
.
Tensor
):
r
"""
r
"""
...
@@ -58,7 +61,11 @@ class DataProcessor(nn.Module):
...
@@ -58,7 +61,11 @@ class DataProcessor(nn.Module):
return
log_cqt
return
log_cqt
def
_init_cqt_layer
(
self
,
sr
:
int
,
hop_length
:
int
):
def
_init_cqt_layer
(
self
,
sr
:
int
,
hop_length
:
int
):
self
.
cqt
=
CQT
(
sr
=
sr
,
hop_length
=
hop_length
,
**
self
.
cqt_kwargs
).
to
(
self
.
device
)
if
self
.
cqt
is
not
None
:
device
=
self
.
cqt
.
cqt_kernels_real
.
device
else
:
device
=
None
self
.
cqt
=
CQT
(
sr
=
sr
,
hop_length
=
hop_length
,
**
self
.
cqt_kwargs
).
to
(
device
)
@property
@property
def
sampling_rate
(
self
)
->
int
:
def
sampling_rate
(
self
)
->
int
:
...
...
This diff is collapsed.
Click to expand it.
pesto/utils.py
+
1
−
1
View file @
752df3b7
...
@@ -9,7 +9,7 @@ from .model import PESTOEncoder
...
@@ -9,7 +9,7 @@ from .model import PESTOEncoder
def
load_dataprocessor
(
step_size
,
device
:
Optional
[
torch
.
device
]
=
None
):
def
load_dataprocessor
(
step_size
,
device
:
Optional
[
torch
.
device
]
=
None
):
return
DataProcessor
(
step_size
=
step_size
,
device
=
device
,
**
cqt_args
).
to
(
device
)
return
DataProcessor
(
step_size
=
step_size
,
**
cqt_args
).
to
(
device
)
def
load_model
(
model_name
:
str
,
device
:
Optional
[
torch
.
device
]
=
None
)
->
PESTOEncoder
:
def
load_model
(
model_name
:
str
,
device
:
Optional
[
torch
.
device
]
=
None
)
->
PESTOEncoder
:
...
...
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