Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sgmse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Svajda, Till
sgmse
Commits
b5015c27
Commit
b5015c27
authored
11 months ago
by
Julius Richter
Browse files
Options
Downloads
Patches
Plain Diff
add --device argument for running on cpu
parent
a18cdb7b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
enhancement.py
+10
-10
10 additions, 10 deletions
enhancement.py
with
10 additions
and
10 deletions
enhancement.py
+
10
−
10
View file @
b5015c27
import
glob
import
glob
import
torch
import
torch
from
tqdm
import
tqdm
from
os
import
makedirs
from
os
import
makedirs
from
os.path
import
join
,
dirname
from
argparse
import
ArgumentParser
from
soundfile
import
write
from
soundfile
import
write
from
torchaudio
import
load
from
torchaudio
import
load
from
tqdm
import
tqdm
from
os.path
import
join
,
dirname
from
argparse
import
ArgumentParser
# Set CUDA architecture list
# Set CUDA architecture list
from
sgmse.util.other
import
set_torch_cuda_arch_list
from
sgmse.util.other
import
set_torch_cuda_arch_list
...
@@ -19,17 +19,17 @@ if __name__ == '__main__':
...
@@ -19,17 +19,17 @@ if __name__ == '__main__':
parser
=
ArgumentParser
()
parser
=
ArgumentParser
()
parser
.
add_argument
(
"
--test_dir
"
,
type
=
str
,
required
=
True
,
help
=
'
Directory containing the test data
'
)
parser
.
add_argument
(
"
--test_dir
"
,
type
=
str
,
required
=
True
,
help
=
'
Directory containing the test data
'
)
parser
.
add_argument
(
"
--enhanced_dir
"
,
type
=
str
,
required
=
True
,
help
=
'
Directory containing the enhanced data
'
)
parser
.
add_argument
(
"
--enhanced_dir
"
,
type
=
str
,
required
=
True
,
help
=
'
Directory containing the enhanced data
'
)
parser
.
add_argument
(
"
--ckpt
"
,
type
=
str
,
help
=
'
Path to model checkpoint
.
'
)
parser
.
add_argument
(
"
--ckpt
"
,
type
=
str
,
help
=
'
Path to model checkpoint
'
)
parser
.
add_argument
(
"
--corrector
"
,
type
=
str
,
choices
=
(
"
ald
"
,
"
langevin
"
,
"
none
"
),
default
=
"
ald
"
,
help
=
"
Corrector class for the PC sampler.
"
)
parser
.
add_argument
(
"
--corrector
"
,
type
=
str
,
choices
=
(
"
ald
"
,
"
langevin
"
,
"
none
"
),
default
=
"
ald
"
,
help
=
"
Corrector class for the PC sampler.
"
)
parser
.
add_argument
(
"
--corrector_steps
"
,
type
=
int
,
default
=
1
,
help
=
"
Number of corrector steps
"
)
parser
.
add_argument
(
"
--corrector_steps
"
,
type
=
int
,
default
=
1
,
help
=
"
Number of corrector steps
"
)
parser
.
add_argument
(
"
--snr
"
,
type
=
float
,
default
=
0.5
,
help
=
"
SNR value for (annealed) Langevin dynmaics
.
"
)
parser
.
add_argument
(
"
--snr
"
,
type
=
float
,
default
=
0.5
,
help
=
"
SNR value for (annealed) Langevin dynmaics
"
)
parser
.
add_argument
(
"
--N
"
,
type
=
int
,
default
=
30
,
help
=
"
Number of reverse steps
"
)
parser
.
add_argument
(
"
--N
"
,
type
=
int
,
default
=
30
,
help
=
"
Number of reverse steps
"
)
parser
.
add_argument
(
"
--device
"
,
type
=
str
,
default
=
"
cuda
"
,
help
=
"
Device to use for inference
"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
# Load score model
# Load score model
model
=
ScoreModel
.
load_from_checkpoint
(
args
.
ckpt
,
base_dir
=
''
,
batch_size
=
16
,
num_workers
=
0
,
kwargs
=
dict
(
gpu
=
False
))
model
=
ScoreModel
.
load_from_checkpoint
(
args
.
ckpt
,
map_location
=
args
.
device
)
model
.
eval
(
no_ema
=
False
)
model
.
eval
()
model
.
cuda
()
# Get list of noisy files
# Get list of noisy files
noisy_files
=
[]
noisy_files
=
[]
...
@@ -58,12 +58,12 @@ if __name__ == '__main__':
...
@@ -58,12 +58,12 @@ if __name__ == '__main__':
y
=
y
/
norm_factor
y
=
y
/
norm_factor
# Prepare DNN input
# Prepare DNN input
Y
=
torch
.
unsqueeze
(
model
.
_forward_transform
(
model
.
_stft
(
y
.
cuda
(
))),
0
)
Y
=
torch
.
unsqueeze
(
model
.
_forward_transform
(
model
.
_stft
(
y
.
to
(
args
.
device
))),
0
)
Y
=
pad_spec
(
Y
,
mode
=
pad_mode
)
Y
=
pad_spec
(
Y
,
mode
=
pad_mode
)
# Reverse sampling
# Reverse sampling
sampler
=
model
.
get_pc_sampler
(
sampler
=
model
.
get_pc_sampler
(
'
reverse_diffusion
'
,
args
.
corrector
,
Y
.
cuda
(
),
N
=
args
.
N
,
'
reverse_diffusion
'
,
args
.
corrector
,
Y
.
to
(
args
.
device
),
N
=
args
.
N
,
corrector_steps
=
args
.
corrector_steps
,
snr
=
args
.
snr
)
corrector_steps
=
args
.
corrector_steps
,
snr
=
args
.
snr
)
sample
,
_
=
sampler
()
sample
,
_
=
sampler
()
...
...
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