Spaces:
Sleeping
Sleeping
Commit
·
64a6fed
1
Parent(s):
c1b80c0
Remove unneeded scripts. Change eval to use table 4 datasets. Clean
Browse files- README.md +65 -48
- cfg/exp/0-0.yaml +29 -0
- cfg/exp/1-1.yaml +1 -1
- cfg/exp/2-2.yaml +1 -1
- cfg/exp/3-3.yaml +1 -1
- cfg/exp/4-4.yaml +1 -1
- cfg/exp/5-5.yaml +1 -1
- cfg/exp/5-5_full.yaml +29 -0
- cfg/exp/{5-5_cls.yaml → 5-5_full_cls.yaml} +0 -0
- cfg/exp/{5-5_cls_dynamic.yaml → 5-5_full_cls_dynamic.yaml} +0 -0
- cfg/exp/remfx_all.yaml +3 -5
- cfg/exp/remfx_detect.yaml +3 -5
- cfg/exp/remfx_oracle.yaml +3 -5
- download_ckpts.sh +2 -0
- download_eval_datasets.sh +25 -0
- eval.sh +38 -3
- remfx/datasets.py +3 -0
- remfx/utils.py +0 -1
- remfx_detect.sh +2 -2
- scripts/remfx_detect.py +7 -3
- shell_vars.sh +0 -3
- train_all.sh +0 -6
README.md
CHANGED
@@ -4,29 +4,29 @@ Removing multiple audio effects from multiple sources using compositional audio
|
|
4 |
This repo contains the code for the paper [General Purpose Audio Effect Removal](https://arxiv.org/abs/2110.00484). (Todo: Link broken, Add video, Add img, citation)
|
5 |
|
6 |
|
7 |
-
|
8 |
# Setup
|
9 |
```
|
10 |
git clone https://github.com/mhrice/RemFx.git
|
|
|
11 |
git submodule update --init --recursive
|
12 |
pip install -e . ./umx
|
13 |
```
|
14 |
# Usage
|
15 |
This repo can be used for many different tasks. Here are some examples.
|
16 |
-
## Run RemFX Detect on a single file
|
|
|
17 |
```
|
18 |
./download_checkpoints.sh
|
19 |
./remfx_detect.sh wet.wav -o dry.wav
|
20 |
```
|
21 |
-
## Download the [General Purpose Audio Effect Removal evaluation
|
22 |
```
|
23 |
-
|
24 |
-
unzip RemFX_eval_dataset.zip
|
25 |
```
|
26 |
|
27 |
-
## Download the starter datasets
|
28 |
```
|
29 |
-
python scripts/download.py vocalset guitarset
|
30 |
```
|
31 |
By default, the starter datasets are downloaded to `./data/remfx-data`. To change this, pass `--output_dir={path/to/datasets}` to `download.py`
|
32 |
|
@@ -35,7 +35,7 @@ Then set the dataset root :
|
|
35 |
export DATASET_ROOT={path/to/datasets}
|
36 |
```
|
37 |
|
38 |
-
## Training
|
39 |
Before training, it is important that you have downloaded the starter datasets (see above) and set DATASET_ROOT.
|
40 |
This project uses the [pytorch-lightning](https://www.pytorchlightning.ai/index.html) framework and [hydra](https://hydra.cc/) for configuration management. All experiments are defined in `cfg/exp/`. To train with an existing experiment run
|
41 |
```
|
@@ -44,13 +44,13 @@ python scripts/train.py +exp={experiment_name}
|
|
44 |
|
45 |
Here are some selected experiment types from the paper, which use different datasets and configurations. See `cfg/exp/` for a full list of experiments and parameters.
|
46 |
|
47 |
-
| Experiment Type | Config Name | Example
|
48 |
-
| ----------------------- | ------------ |
|
49 |
-
| Effect-specific | {effect} | +exp=chorus
|
50 |
-
| Effect-specific + FXAug | {effect}_aug | +exp=chorus_aug
|
51 |
-
| Monolithic (1 FX) | 5-
|
52 |
-
| Monolithic (<=5 FX) | 5-
|
53 |
-
| Classifier | 5-
|
54 |
|
55 |
To change the configuration, simply edit the experiment file, or override the configuration on the command line. A description of some of these variables is in the Misc. section below.
|
56 |
You can also create a custom experiment by creating a new experiment file in `cfg/exp/` and overriding the default parameters in `config.yaml`.
|
@@ -58,7 +58,7 @@ You can also create a custom experiment by creating a new experiment file in `cf
|
|
58 |
At the end of training, the train script will automatically evaluate the test set using the best checkpoint (by validation loss). If epoch 0 is not finished, it will throw an error. To evaluate a specific checkpoint, run
|
59 |
|
60 |
```
|
61 |
-
python test.py +exp={experiment_name} ckpt_path={path/to/checkpoint}
|
62 |
```
|
63 |
|
64 |
The checkpoints will be saved in `./logs/ckpts/{timestamp}`
|
@@ -69,27 +69,43 @@ If you have generated the dataset separately (see Generate datasets used in the
|
|
69 |
|
70 |
Also note that the training assumes you have a GPU. To train on CPU, set `accelerator=null` in the config or command-line.
|
71 |
|
72 |
-
## Evaluate models on the General Purpose Audio Effect Removal evaluation
|
73 |
-
First download the
|
74 |
To use the pretrained RemFX model, download the checkpoints
|
75 |
```
|
76 |
./download_checkpoints.sh
|
77 |
```
|
78 |
-
Then run the evaluation script, select the RemFX configuration, between `remfx_oracle`, `remfx_detect`, and `remfx_all`.
|
79 |
```
|
80 |
-
./eval.sh remfx_detect
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
```
|
82 |
-
To
|
83 |
-
Then run the evaluation script, with config used.
|
84 |
```
|
85 |
-
./eval.sh
|
|
|
|
|
|
|
|
|
|
|
86 |
```
|
87 |
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
90 |
|
|
|
|
|
91 |
|
92 |
-
## Generate datasets
|
93 |
The datasets used in the experiments are customly generated from the starter datasets. In short, for each training/val/testing example, we select a random 5.5s segment from one of the starter datasets and apply a random number of effects to it. The number of effects applied is controlled by the `num_kept_effects` and `num_removed_effects` parameters. The effects applied are controlled by the `effects_to_keep` and `effects_to_remove` parameters.
|
94 |
|
95 |
Before generating datasets, it is important that you have downloaded the starter datasets (see above) and set DATASET_ROOT.
|
@@ -105,28 +121,6 @@ By default, files are rendered to `{render_root} / processed / {string_of_effect
|
|
105 |
|
106 |
If training, this process will be done automatically at the start of training. To disable this, set `render_files=False` in the config or command-line, and set `render_root={path_to_dataset}` if it is in a custom location.
|
107 |
|
108 |
-
## Evaluate with a custom directory
|
109 |
-
Assumes directory is structured as
|
110 |
-
- root
|
111 |
-
- clean
|
112 |
-
- file1.wav
|
113 |
-
- file2.wav
|
114 |
-
- file3.wav
|
115 |
-
- effected
|
116 |
-
- file1.wav
|
117 |
-
- file2.wav
|
118 |
-
- file3.wav
|
119 |
-
|
120 |
-
First set the dataset root:
|
121 |
-
```
|
122 |
-
export DATASET_ROOT={path/to/datasets}
|
123 |
-
```
|
124 |
-
|
125 |
-
Then run
|
126 |
-
```
|
127 |
-
python scripts/chain_inference.py +exp=chain_inference_custom
|
128 |
-
```
|
129 |
-
|
130 |
# Misc.
|
131 |
## Experimental parameters
|
132 |
Some relevant dataset/training parameters descriptions
|
@@ -159,3 +153,26 @@ Some relevant dataset/training parameters descriptions
|
|
159 |
- `distortion`
|
160 |
- `reverb`
|
161 |
- `delay`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
This repo contains the code for the paper [General Purpose Audio Effect Removal](https://arxiv.org/abs/2110.00484). (Todo: Link broken, Add video, Add img, citation)
|
5 |
|
6 |
|
|
|
7 |
# Setup
|
8 |
```
|
9 |
git clone https://github.com/mhrice/RemFx.git
|
10 |
+
cd RemFx
|
11 |
git submodule update --init --recursive
|
12 |
pip install -e . ./umx
|
13 |
```
|
14 |
# Usage
|
15 |
This repo can be used for many different tasks. Here are some examples.
|
16 |
+
## Run RemFX Detect on a single file - []
|
17 |
+
First, need to download the checkpoints from [zenodo](https://zenodo.org/record/8179396)
|
18 |
```
|
19 |
./download_checkpoints.sh
|
20 |
./remfx_detect.sh wet.wav -o dry.wav
|
21 |
```
|
22 |
+
## Download the [General Purpose Audio Effect Removal evaluation datasets](https://zenodo.org/record/8183649/) - [x]
|
23 |
```
|
24 |
+
./download_eval_datasets.sh
|
|
|
25 |
```
|
26 |
|
27 |
+
## Download the starter datasets - [x]
|
28 |
```
|
29 |
+
python scripts/download.py vocalset guitarset dsd100 idmt-smt-drums
|
30 |
```
|
31 |
By default, the starter datasets are downloaded to `./data/remfx-data`. To change this, pass `--output_dir={path/to/datasets}` to `download.py`
|
32 |
|
|
|
35 |
export DATASET_ROOT={path/to/datasets}
|
36 |
```
|
37 |
|
38 |
+
## Training - [x]
|
39 |
Before training, it is important that you have downloaded the starter datasets (see above) and set DATASET_ROOT.
|
40 |
This project uses the [pytorch-lightning](https://www.pytorchlightning.ai/index.html) framework and [hydra](https://hydra.cc/) for configuration management. All experiments are defined in `cfg/exp/`. To train with an existing experiment run
|
41 |
```
|
|
|
44 |
|
45 |
Here are some selected experiment types from the paper, which use different datasets and configurations. See `cfg/exp/` for a full list of experiments and parameters.
|
46 |
|
47 |
+
| Experiment Type | Config Name | Example |
|
48 |
+
| ----------------------- | ------------ | ----------------- |
|
49 |
+
| Effect-specific | {effect} | +exp=chorus |
|
50 |
+
| Effect-specific + FXAug | {effect}_aug | +exp=chorus_aug |
|
51 |
+
| Monolithic (1 FX) | 5-1 | +exp=5-1 |
|
52 |
+
| Monolithic (<=5 FX) | 5-5_full | +exp=5-5_full |
|
53 |
+
| Classifier | 5-5_full_cls | +exp=5-5_full_cls |
|
54 |
|
55 |
To change the configuration, simply edit the experiment file, or override the configuration on the command line. A description of some of these variables is in the Misc. section below.
|
56 |
You can also create a custom experiment by creating a new experiment file in `cfg/exp/` and overriding the default parameters in `config.yaml`.
|
|
|
58 |
At the end of training, the train script will automatically evaluate the test set using the best checkpoint (by validation loss). If epoch 0 is not finished, it will throw an error. To evaluate a specific checkpoint, run
|
59 |
|
60 |
```
|
61 |
+
python scripts/test.py +exp={experiment_name} +ckpt_path={path/to/checkpoint} render_files=False
|
62 |
```
|
63 |
|
64 |
The checkpoints will be saved in `./logs/ckpts/{timestamp}`
|
|
|
69 |
|
70 |
Also note that the training assumes you have a GPU. To train on CPU, set `accelerator=null` in the config or command-line.
|
71 |
|
72 |
+
## Evaluate models on the General Purpose Audio Effect Removal evaluation datasets (Table 4 from the paper) - []
|
73 |
+
First download the General Purpose Audio Effect Removal evaluation datasets (see above).
|
74 |
To use the pretrained RemFX model, download the checkpoints
|
75 |
```
|
76 |
./download_checkpoints.sh
|
77 |
```
|
78 |
+
Then run the evaluation script, select the RemFX configuration, between `remfx_oracle`, `remfx_detect`, and `remfx_all`. Then select N, the number of effects to remove.
|
79 |
```
|
80 |
+
./eval.sh remfx_detect 0-0
|
81 |
+
./eval.sh remfx_detect 1-1
|
82 |
+
./eval.sh remfx_detect 2-2
|
83 |
+
./eval.sh remfx_detect 3-3
|
84 |
+
./eval.sh remfx_detect 4-4
|
85 |
+
./eval.sh remfx_detect 5-5
|
86 |
+
|
87 |
```
|
88 |
+
To eval a custom monolithic model, first train a model (see Training)
|
89 |
+
Then run the evaluation script, with the config used and checkpoint_path.
|
90 |
```
|
91 |
+
./eval.sh distortion_aug 0-0 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
92 |
+
./eval.sh distortion_aug 1-1 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
93 |
+
./eval.sh distortion_aug 2-2 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
94 |
+
./eval.sh distortion_aug 3-3 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
95 |
+
./eval.sh distortion_aug 4-4 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
96 |
+
./eval.sh distortion_aug 5-5 -ckpt "logs/ckpts/2023-07-26-10-10-27/epoch\=05-valid_loss\=8.623.ckpt"
|
97 |
```
|
98 |
|
99 |
+
To eval a custom effect-specific model as part of the inference chain, first train a model (see Training), then edit `cfg/exp/remfx_{desired_configuration}.yaml` -> ckpts -> {effect}.
|
100 |
+
Then run the evaluation script.
|
101 |
+
```
|
102 |
+
./eval.sh remfx_detect 0-0
|
103 |
+
```
|
104 |
|
105 |
+
The script assumes that RemFX_eval_datasets is in the top-level directory.
|
106 |
+
Metrics and hyperparams will be logged in `./lightning_logs/{timestamp}`
|
107 |
|
108 |
+
## Generate other datasets - [x]
|
109 |
The datasets used in the experiments are customly generated from the starter datasets. In short, for each training/val/testing example, we select a random 5.5s segment from one of the starter datasets and apply a random number of effects to it. The number of effects applied is controlled by the `num_kept_effects` and `num_removed_effects` parameters. The effects applied are controlled by the `effects_to_keep` and `effects_to_remove` parameters.
|
110 |
|
111 |
Before generating datasets, it is important that you have downloaded the starter datasets (see above) and set DATASET_ROOT.
|
|
|
121 |
|
122 |
If training, this process will be done automatically at the start of training. To disable this, set `render_files=False` in the config or command-line, and set `render_root={path_to_dataset}` if it is in a custom location.
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
# Misc.
|
125 |
## Experimental parameters
|
126 |
Some relevant dataset/training parameters descriptions
|
|
|
153 |
- `distortion`
|
154 |
- `reverb`
|
155 |
- `delay`
|
156 |
+
|
157 |
+
# DO WE NEED THIS?
|
158 |
+
## Evaluate RemFXwith a custom directory - []
|
159 |
+
Assumes directory is structured as
|
160 |
+
- root
|
161 |
+
- clean
|
162 |
+
- file1.wav
|
163 |
+
- file2.wav
|
164 |
+
- file3.wav
|
165 |
+
- effected
|
166 |
+
- file1.wav
|
167 |
+
- file2.wav
|
168 |
+
- file3.wav
|
169 |
+
|
170 |
+
First set the dataset root:
|
171 |
+
```
|
172 |
+
export DATASET_ROOT={path/to/datasets}
|
173 |
+
```
|
174 |
+
|
175 |
+
Then run
|
176 |
+
```
|
177 |
+
python scripts/chain_inference.py +exp=chain_inference_custom
|
178 |
+
```
|
cfg/exp/0-0.yaml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# @package _global_
|
2 |
+
defaults:
|
3 |
+
- override /model: demucs
|
4 |
+
- override /effects: all
|
5 |
+
seed: 12345
|
6 |
+
sample_rate: 48000
|
7 |
+
chunk_size: 262144 # 5.5s
|
8 |
+
logs_dir: "./logs"
|
9 |
+
render_files: True
|
10 |
+
|
11 |
+
accelerator: "gpu"
|
12 |
+
log_audio: True
|
13 |
+
# Effects
|
14 |
+
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [0,0] # [min, max]
|
16 |
+
shuffle_kept_effects: True
|
17 |
+
shuffle_removed_effects: True
|
18 |
+
num_classes: 5
|
19 |
+
effects_to_keep:
|
20 |
+
effects_to_remove:
|
21 |
+
- distortion
|
22 |
+
- compressor
|
23 |
+
- reverb
|
24 |
+
- chorus
|
25 |
+
- delay
|
26 |
+
datamodule:
|
27 |
+
train_batch_size: 16
|
28 |
+
test_batch_size: 1
|
29 |
+
num_workers: 8
|
cfg/exp/1-1.yaml
CHANGED
@@ -12,7 +12,7 @@ accelerator: "gpu"
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
-
num_removed_effects: [
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [1,1] # [min, max]
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
cfg/exp/2-2.yaml
CHANGED
@@ -12,7 +12,7 @@ accelerator: "gpu"
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
-
num_removed_effects: [
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [2,2] # [min, max]
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
cfg/exp/3-3.yaml
CHANGED
@@ -12,7 +12,7 @@ accelerator: "gpu"
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
-
num_removed_effects: [
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [3,3] # [min, max]
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
cfg/exp/4-4.yaml
CHANGED
@@ -12,7 +12,7 @@ accelerator: "gpu"
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
-
num_removed_effects: [
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [4,4] # [min, max]
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
cfg/exp/5-5.yaml
CHANGED
@@ -12,7 +12,7 @@ accelerator: "gpu"
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
-
num_removed_effects: [
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
|
|
12 |
log_audio: True
|
13 |
# Effects
|
14 |
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [5,5] # [min, max]
|
16 |
shuffle_kept_effects: True
|
17 |
shuffle_removed_effects: True
|
18 |
num_classes: 5
|
cfg/exp/5-5_full.yaml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# @package _global_
|
2 |
+
defaults:
|
3 |
+
- override /model: demucs
|
4 |
+
- override /effects: all
|
5 |
+
seed: 12345
|
6 |
+
sample_rate: 48000
|
7 |
+
chunk_size: 262144 # 5.5s
|
8 |
+
logs_dir: "./logs"
|
9 |
+
render_files: True
|
10 |
+
|
11 |
+
accelerator: "gpu"
|
12 |
+
log_audio: True
|
13 |
+
# Effects
|
14 |
+
num_kept_effects: [0,0] # [min, max]
|
15 |
+
num_removed_effects: [0,5] # [min, max]
|
16 |
+
shuffle_kept_effects: True
|
17 |
+
shuffle_removed_effects: True
|
18 |
+
num_classes: 5
|
19 |
+
effects_to_keep:
|
20 |
+
effects_to_remove:
|
21 |
+
- distortion
|
22 |
+
- compressor
|
23 |
+
- reverb
|
24 |
+
- chorus
|
25 |
+
- delay
|
26 |
+
datamodule:
|
27 |
+
train_batch_size: 16
|
28 |
+
test_batch_size: 1
|
29 |
+
num_workers: 8
|
cfg/exp/{5-5_cls.yaml → 5-5_full_cls.yaml}
RENAMED
File without changes
|
cfg/exp/{5-5_cls_dynamic.yaml → 5-5_full_cls_dynamic.yaml}
RENAMED
File without changes
|
cfg/exp/remfx_all.yaml
CHANGED
@@ -6,7 +6,7 @@ seed: 12345
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
-
accelerator: "
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
@@ -17,11 +17,11 @@ shuffle_removed_effects: True
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
|
|
20 |
- compressor
|
21 |
- reverb
|
22 |
- chorus
|
23 |
- delay
|
24 |
-
- distortion
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
@@ -85,6 +85,4 @@ inference_effects_ordering:
|
|
85 |
- "RandomPedalboardDelay"
|
86 |
num_bins: 1025
|
87 |
inference_effects_shuffle: True
|
88 |
-
inference_use_all_effect_models: True
|
89 |
-
audio_input: ""
|
90 |
-
output_path: "./output.wav"
|
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
+
accelerator: "gpu"
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
20 |
+
- distortion
|
21 |
- compressor
|
22 |
- reverb
|
23 |
- chorus
|
24 |
- delay
|
|
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
|
|
85 |
- "RandomPedalboardDelay"
|
86 |
num_bins: 1025
|
87 |
inference_effects_shuffle: True
|
88 |
+
inference_use_all_effect_models: True
|
|
|
|
cfg/exp/remfx_detect.yaml
CHANGED
@@ -6,7 +6,7 @@ seed: 12345
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
-
accelerator: "
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
@@ -17,11 +17,11 @@ shuffle_removed_effects: True
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
|
|
20 |
- compressor
|
21 |
- reverb
|
22 |
- chorus
|
23 |
- delay
|
24 |
-
- distortion
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
@@ -85,6 +85,4 @@ inference_effects_ordering:
|
|
85 |
- "RandomPedalboardDelay"
|
86 |
num_bins: 1025
|
87 |
inference_effects_shuffle: True
|
88 |
-
inference_use_all_effect_models: False
|
89 |
-
audio_input: ""
|
90 |
-
output_path: "./output.wav"
|
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
+
accelerator: "gpu"
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
20 |
+
- distortion
|
21 |
- compressor
|
22 |
- reverb
|
23 |
- chorus
|
24 |
- delay
|
|
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
|
|
85 |
- "RandomPedalboardDelay"
|
86 |
num_bins: 1025
|
87 |
inference_effects_shuffle: True
|
88 |
+
inference_use_all_effect_models: False
|
|
|
|
cfg/exp/remfx_oracle.yaml
CHANGED
@@ -6,7 +6,7 @@ seed: 12345
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
-
accelerator: "
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
@@ -17,11 +17,11 @@ shuffle_removed_effects: True
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
|
|
20 |
- compressor
|
21 |
- reverb
|
22 |
- chorus
|
23 |
- delay
|
24 |
-
- distortion
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
@@ -69,6 +69,4 @@ inference_effects_ordering:
|
|
69 |
- "RandomPedalboardDelay"
|
70 |
num_bins: 1025
|
71 |
inference_effects_shuffle: True
|
72 |
-
inference_use_all_effect_models: False
|
73 |
-
audio_input: ""
|
74 |
-
output_path: "./output.wav"
|
|
|
6 |
sample_rate: 48000
|
7 |
chunk_size: 262144 # 5.5s
|
8 |
logs_dir: "./logs"
|
9 |
+
accelerator: "gpu"
|
10 |
log_audio: True
|
11 |
|
12 |
# Effects
|
|
|
17 |
num_classes: 5
|
18 |
effects_to_keep:
|
19 |
effects_to_remove:
|
20 |
+
- distortion
|
21 |
- compressor
|
22 |
- reverb
|
23 |
- chorus
|
24 |
- delay
|
|
|
25 |
datamodule:
|
26 |
train_batch_size: 16
|
27 |
test_batch_size: 1
|
|
|
69 |
- "RandomPedalboardDelay"
|
70 |
num_bins: 1025
|
71 |
inference_effects_shuffle: True
|
72 |
+
inference_use_all_effect_models: False
|
|
|
|
download_ckpts.sh
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
# make ckpts directory if not exist
|
2 |
mkdir -p ckpts
|
3 |
|
|
|
1 |
+
#! /bin/bash
|
2 |
+
|
3 |
# make ckpts directory if not exist
|
4 |
mkdir -p ckpts
|
5 |
|
download_eval_datasets.sh
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#! /bin/bash
|
2 |
+
|
3 |
+
mkdir -p RemFX_eval_datasets
|
4 |
+
cd RemFX_eval_datasets
|
5 |
+
mkdir -p processed
|
6 |
+
cd processed
|
7 |
+
wget https://zenodo.org/record/8187288/files/0-0.zip?download=1 -O 0-0.zip
|
8 |
+
wget https://zenodo.org/record/8187288/files/1-1.zip?download=1 -O 1-1.zip
|
9 |
+
wget https://zenodo.org/record/8187288/files/2-2.zip?download=1 -O 2-2.zip
|
10 |
+
wget https://zenodo.org/record/8187288/files/3-3.zip?download=1 -O 3-3.zip
|
11 |
+
wget https://zenodo.org/record/8187288/files/4-4.zip?download=1 -O 4-4.zip
|
12 |
+
wget https://zenodo.org/record/8187288/files/5-5.zip?download=1 -O 5-5.zip
|
13 |
+
unzip 0-0.zip
|
14 |
+
unzip 1-1.zip
|
15 |
+
unzip 2-2.zip
|
16 |
+
unzip 3-3.zip
|
17 |
+
unzip 4-4.zip
|
18 |
+
unzip 5-5.zip
|
19 |
+
rm 0-0.zip
|
20 |
+
rm 1-1.zip
|
21 |
+
rm 2-2.zip
|
22 |
+
rm 3-3.zip
|
23 |
+
rm 4-4.zip
|
24 |
+
rm 5-5.zip
|
25 |
+
|
eval.sh
CHANGED
@@ -1,16 +1,51 @@
|
|
1 |
#! /bin/bash
|
2 |
|
3 |
# Example usage:
|
4 |
-
# ./eval.sh remfx_detect
|
|
|
|
|
5 |
|
6 |
# Check if first argument is empty
|
7 |
if [ -z "$1" ]
|
8 |
then
|
9 |
-
echo "No experiment name
|
10 |
exit 1
|
11 |
fi
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
|
16 |
|
|
|
1 |
#! /bin/bash
|
2 |
|
3 |
# Example usage:
|
4 |
+
# ./eval.sh remfx_detect 0-0
|
5 |
+
# ./eval.sh distortion_aug 0-0 -ckpt logs/ckpts/2023-01-21-12-21-44
|
6 |
+
# First 2 arguments are required, third argument is optional
|
7 |
|
8 |
# Check if first argument is empty
|
9 |
if [ -z "$1" ]
|
10 |
then
|
11 |
+
echo "No experiment name supplied"
|
12 |
exit 1
|
13 |
fi
|
14 |
|
15 |
+
# Check if second argument is empty
|
16 |
+
if [ -z "$2" ]
|
17 |
+
then
|
18 |
+
echo "No dataset name supplied"
|
19 |
+
exit 1
|
20 |
+
fi
|
21 |
+
dataset_name=$2
|
22 |
+
|
23 |
+
# Check if ckpt flag is set using getopts
|
24 |
+
ckpt_flag=0
|
25 |
+
while getopts ":ckpt:" opt; do
|
26 |
+
case $opt in
|
27 |
+
ckpt)
|
28 |
+
ckpt_flag=1
|
29 |
+
ckpt_path=$OPTARG
|
30 |
+
;;
|
31 |
+
\?)
|
32 |
+
echo "Invalid option: -$OPTARG" >&3
|
33 |
+
;;
|
34 |
+
esac
|
35 |
+
done
|
36 |
+
|
37 |
+
# If checkpoint flag is empty, run chain inference
|
38 |
+
if [ $ckpt_flag -eq 0 ]
|
39 |
+
then
|
40 |
+
# Running chain inference
|
41 |
+
echo "Running chain inference"
|
42 |
+
python scripts/chain_inference.py +exp=$1 datamodule.train_dataset=None datamodule.val_dataset=None datamodule.test_dataset.render_root=./RemFX_eval_datasets/ render_files=False num_removed_effects=[${dataset_name:0:1},${dataset_name:2:1}]
|
43 |
+
exit 1
|
44 |
+
fi
|
45 |
+
|
46 |
+
# Otherwise run inference on the specified checkpoint
|
47 |
+
echo "Running monolithic inference on checkpoint $3"
|
48 |
+
python scripts/test.py +exp=$1 datamodule.train_dataset=None datamodule.val_dataset=None datamodule.test_dataset.render_root=./RemFX_eval_datasets/ datamodule.test_dataset.num_kept_effects="[0,0]" num_removed_effects=[${dataset_name:0:1},${dataset_name:2:1}] effects_to_keep=[] effects_to_remove="[compressor,reverb,chorus,delay,distortion]" render_files=False +ckpt_path=$2
|
49 |
|
50 |
|
51 |
|
remfx/datasets.py
CHANGED
@@ -578,6 +578,9 @@ class EffectDataset(Dataset):
|
|
578 |
normalized_wet = self.normalize(wet)
|
579 |
|
580 |
# Check STFT, pick different effects if necessary
|
|
|
|
|
|
|
581 |
stft = self.mrstft(normalized_wet.unsqueeze(0), normalized_dry.unsqueeze(0))
|
582 |
return normalized_dry, normalized_wet, dry_labels_tensor, wet_labels_tensor
|
583 |
|
|
|
578 |
normalized_wet = self.normalize(wet)
|
579 |
|
580 |
# Check STFT, pick different effects if necessary
|
581 |
+
if num_removed_effects == 0:
|
582 |
+
# No need to check if no effects removed
|
583 |
+
break
|
584 |
stft = self.mrstft(normalized_wet.unsqueeze(0), normalized_dry.unsqueeze(0))
|
585 |
return normalized_dry, normalized_wet, dry_labels_tensor, wet_labels_tensor
|
586 |
|
remfx/utils.py
CHANGED
@@ -3,7 +3,6 @@ from typing import List, Tuple
|
|
3 |
import pytorch_lightning as pl
|
4 |
from omegaconf import DictConfig
|
5 |
from pytorch_lightning.utilities import rank_zero_only
|
6 |
-
import numpy as np
|
7 |
import torch
|
8 |
import torchaudio
|
9 |
from torch import nn
|
|
|
3 |
import pytorch_lightning as pl
|
4 |
from omegaconf import DictConfig
|
5 |
from pytorch_lightning.utilities import rank_zero_only
|
|
|
6 |
import torch
|
7 |
import torchaudio
|
8 |
from torch import nn
|
remfx_detect.sh
CHANGED
@@ -33,7 +33,7 @@ done
|
|
33 |
|
34 |
if [ -z "$output_path" ]
|
35 |
then
|
36 |
-
python scripts/remfx_detect.py +exp=remfx_detect audio_input=$
|
37 |
exit 0
|
38 |
fi
|
39 |
-
python scripts/remfx_detect.py +exp=remfx_detect audio_input=$
|
|
|
33 |
|
34 |
if [ -z "$output_path" ]
|
35 |
then
|
36 |
+
python scripts/remfx_detect.py +exp=remfx_detect +audio_input=$audio_input
|
37 |
exit 0
|
38 |
fi
|
39 |
+
python scripts/remfx_detect.py +exp=remfx_detect +audio_input=$audio_input +output_path=$output_path
|
scripts/remfx_detect.py
CHANGED
@@ -39,7 +39,7 @@ def main(cfg: DictConfig):
|
|
39 |
use_all_effect_models=cfg.inference_use_all_effect_models,
|
40 |
)
|
41 |
|
42 |
-
audio_file =
|
43 |
print("Loading", audio_file)
|
44 |
audio, sr = torchaudio.load(audio_file)
|
45 |
# Resample
|
@@ -51,8 +51,12 @@ def main(cfg: DictConfig):
|
|
51 |
batch = [audio, audio, None, None]
|
52 |
|
53 |
_, y = inference_model(batch, 0, verbose=True)
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
|
57 |
|
58 |
if __name__ == "__main__":
|
|
|
39 |
use_all_effect_models=cfg.inference_use_all_effect_models,
|
40 |
)
|
41 |
|
42 |
+
audio_file = cfg.audio_input
|
43 |
print("Loading", audio_file)
|
44 |
audio, sr = torchaudio.load(audio_file)
|
45 |
# Resample
|
|
|
51 |
batch = [audio, audio, None, None]
|
52 |
|
53 |
_, y = inference_model(batch, 0, verbose=True)
|
54 |
+
if "output_path" in cfg:
|
55 |
+
output_path = cfg.output_path
|
56 |
+
else:
|
57 |
+
output_path = "./output.wav"
|
58 |
+
print("Saving output to", output_path)
|
59 |
+
torchaudio.save(output_path, y[0], sample_rate=cfg.sample_rate)
|
60 |
|
61 |
|
62 |
if __name__ == "__main__":
|
shell_vars.sh
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
export DATASET_ROOT="./data/remfx-data"
|
2 |
-
export WANDB_PROJECT="RemFX"
|
3 |
-
export WANDB_ENTITY="mattricesound"
|
|
|
|
|
|
|
|
train_all.sh
DELETED
@@ -1,6 +0,0 @@
|
|
1 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_wav2vec2 render_files=False logs_dir=/scratch/cjs-log
|
2 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_panns_44k render_files=False logs_dir=/scratch/cjs-log
|
3 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_panns_16k render_files=False logs_dir=/scratch/cjs-log
|
4 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_panns_pt render_files=False logs_dir=/scratch/cjs-log
|
5 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_vggish render_files=False logs_dir=/scratch/cjs-log
|
6 |
-
python scripts/train.py +exp=5-5_cls.yaml model=cls_wav2clip render_files=False logs_dir=/scratch/cjs-log
|
|
|
|
|
|
|
|
|
|
|
|
|
|