Spaces:
Sleeping
Sleeping
Commit
·
93a34d1
1
Parent(s):
4c773e2
Allow for specifying max_effects as -1
Browse files- README.md +12 -5
- cfg/config.yaml +2 -2
- remfx/datasets.py +29 -7
README.md
CHANGED
@@ -28,8 +28,8 @@
|
|
28 |
- `reverb`
|
29 |
|
30 |
## Train Main CLI Options
|
31 |
-
- `max_kept_effects={n}` max number of <b> Kept </b> effects to apply to each file (default:
|
32 |
-
- `max_removed_effects={n}` max number of <b> Removed </b> effects to apply to each file (default:
|
33 |
- `model={model}` architecture to use (see 'Models')
|
34 |
- `shuffle_kept_effects=True/False` Shuffle kept effects (default: True)
|
35 |
- `shuffle_removed_effects=True/False` Shuffle removed effects (default: False)
|
@@ -39,11 +39,18 @@
|
|
39 |
- `render_files=True/False` Render files. Disable to skip rendering stage (default: True)
|
40 |
- `render_root={path/to/dir}`. Root directory to render files to (default: DATASET_ROOT)
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
See `cfg/config.yaml` for more options that can be specified on the command line.
|
45 |
|
46 |
## Misc.
|
47 |
By default, files are rendered to `input_dir / processed / {string_of_effects} / {train|val|test}`.
|
48 |
-
|
49 |
-
|
|
|
28 |
- `reverb`
|
29 |
|
30 |
## Train Main CLI Options
|
31 |
+
- `max_kept_effects={n}` max number of <b> Kept </b> effects to apply to each file. Set to -1 to always use all effects (default: -1)
|
32 |
+
- `max_removed_effects={n}` max number of <b> Removed </b> effects to apply to each file. Set to -1 to always use all effects (default: -1)
|
33 |
- `model={model}` architecture to use (see 'Models')
|
34 |
- `shuffle_kept_effects=True/False` Shuffle kept effects (default: True)
|
35 |
- `shuffle_removed_effects=True/False` Shuffle removed effects (default: False)
|
|
|
39 |
- `render_files=True/False` Render files. Disable to skip rendering stage (default: True)
|
40 |
- `render_root={path/to/dir}`. Root directory to render files to (default: DATASET_ROOT)
|
41 |
|
42 |
+
Note that "kept effects" are calculated from the difference between `effects_to_use` and `effects_to_remove`.
|
43 |
+
|
44 |
+
Example: `python scripts/train.py model=demucs "effects_to_use=[distortion, reverb, chorus]" "effects_to_remove=[distortion]" max_kept_effects=2 max_removed_effects=4 shuffle_kept_effects=False shuffle_removed_effects=True accelerator='gpu' render_root=/scratch/VocalSet'`
|
45 |
+
|
46 |
+
Printout:
|
47 |
+
```
|
48 |
+
Effect Summary:
|
49 |
+
Apply kept effects: ['chorus', 'reverb'] (Up to 2, chosen in order) -> Dry
|
50 |
+
Apply remove effects: ['distortion'] (Up to 4, chosen randomly) -> Wet
|
51 |
+
```
|
52 |
|
53 |
See `cfg/config.yaml` for more options that can be specified on the command line.
|
54 |
|
55 |
## Misc.
|
56 |
By default, files are rendered to `input_dir / processed / {string_of_effects} / {train|val|test}`.
|
|
|
|
cfg/config.yaml
CHANGED
@@ -13,8 +13,8 @@ render_files: True
|
|
13 |
render_root: "./data"
|
14 |
accelerator: null
|
15 |
|
16 |
-
max_kept_effects:
|
17 |
-
max_removed_effects:
|
18 |
shuffle_kept_effects: True
|
19 |
shuffle_removed_effects: False
|
20 |
effects_to_use:
|
|
|
13 |
render_root: "./data"
|
14 |
accelerator: null
|
15 |
|
16 |
+
max_kept_effects: -1
|
17 |
+
max_removed_effects: -1
|
18 |
shuffle_kept_effects: True
|
19 |
shuffle_removed_effects: False
|
20 |
effects_to_use:
|
remfx/datasets.py
CHANGED
@@ -10,6 +10,7 @@ from remfx import effects
|
|
10 |
from tqdm import tqdm
|
11 |
from remfx.utils import create_sequential_chunks
|
12 |
import shutil
|
|
|
13 |
|
14 |
|
15 |
# https://zenodo.org/record/1193957 -> VocalSet
|
@@ -22,12 +23,12 @@ class VocalSet(Dataset):
|
|
22 |
self,
|
23 |
root: str,
|
24 |
sample_rate: int,
|
25 |
-
chunk_size: int =
|
26 |
effect_modules: List[Dict[str, torch.nn.Module]] = None,
|
27 |
effects_to_use: List[str] = None,
|
28 |
effects_to_remove: List[str] = None,
|
29 |
-
max_kept_effects: int =
|
30 |
-
max_removed_effects: int =
|
31 |
shuffle_kept_effects: bool = True,
|
32 |
shuffle_removed_effects: bool = False,
|
33 |
render_files: bool = True,
|
@@ -130,14 +131,25 @@ class VocalSet(Dataset):
|
|
130 |
f"Effect {effect} not found in self.effects. "
|
131 |
f"Please choose from {self.effects.keys()}"
|
132 |
)
|
133 |
-
kept_fx = list(
|
|
|
|
|
134 |
kept_str = "randomly" if self.shuffle_kept_effects else "in order"
|
135 |
rem_fx = self.effects_to_remove
|
136 |
rem_str = "randomly" if self.shuffle_removed_effects else "in order"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
print(
|
138 |
f"Effect Summary: \n"
|
139 |
-
f"Apply effects: {kept_fx} (
|
140 |
-
f"Apply effects: {rem_fx} (
|
141 |
)
|
142 |
return kept_fx
|
143 |
|
@@ -151,7 +163,11 @@ class VocalSet(Dataset):
|
|
151 |
else:
|
152 |
effect_indices = torch.arange(len(self.effects_to_keep))
|
153 |
# Up to max_kept_effects
|
154 |
-
|
|
|
|
|
|
|
|
|
155 |
# Index in effect settings
|
156 |
effect_names_to_apply = [self.effects_to_keep[i] for i in effect_indices]
|
157 |
effects_to_apply = [self.effects[i] for i in effect_names_to_apply]
|
@@ -168,6 +184,12 @@ class VocalSet(Dataset):
|
|
168 |
else:
|
169 |
effect_indices = torch.arange(len(self.effects_to_remove))
|
170 |
# Up to max_removed_effects
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
effect_indices = effect_indices[: self.max_removed_effects]
|
172 |
# Index in effect settings
|
173 |
effect_names_to_apply = [self.effects_to_remove[i] for i in effect_indices]
|
|
|
10 |
from tqdm import tqdm
|
11 |
from remfx.utils import create_sequential_chunks
|
12 |
import shutil
|
13 |
+
from collections import OrderedSet
|
14 |
|
15 |
|
16 |
# https://zenodo.org/record/1193957 -> VocalSet
|
|
|
23 |
self,
|
24 |
root: str,
|
25 |
sample_rate: int,
|
26 |
+
chunk_size: int = 262144,
|
27 |
effect_modules: List[Dict[str, torch.nn.Module]] = None,
|
28 |
effects_to_use: List[str] = None,
|
29 |
effects_to_remove: List[str] = None,
|
30 |
+
max_kept_effects: int = -1,
|
31 |
+
max_removed_effects: int = 1,
|
32 |
shuffle_kept_effects: bool = True,
|
33 |
shuffle_removed_effects: bool = False,
|
34 |
render_files: bool = True,
|
|
|
131 |
f"Effect {effect} not found in self.effects. "
|
132 |
f"Please choose from {self.effects.keys()}"
|
133 |
)
|
134 |
+
kept_fx = list(
|
135 |
+
OrderedSet(self.effects_to_use) - OrderedSet(self.effects_to_remove)
|
136 |
+
)
|
137 |
kept_str = "randomly" if self.shuffle_kept_effects else "in order"
|
138 |
rem_fx = self.effects_to_remove
|
139 |
rem_str = "randomly" if self.shuffle_removed_effects else "in order"
|
140 |
+
if self.max_kept_effects == -1:
|
141 |
+
num_kept_str = len(kept_fx)
|
142 |
+
else:
|
143 |
+
num_kept_str = f"Up to {self.max_kept_effects}"
|
144 |
+
if self.max_removed_effects == -1:
|
145 |
+
num_rem_str = len(rem_fx)
|
146 |
+
else:
|
147 |
+
num_rem_str = f"Up to {self.max_removed_effects}"
|
148 |
+
|
149 |
print(
|
150 |
f"Effect Summary: \n"
|
151 |
+
f"Apply kept effects: {kept_fx} ({num_kept_str}, chosen {kept_str}) -> Dry\n"
|
152 |
+
f"Apply remove effects: {rem_fx} ({num_rem_str}, chosen {rem_str}) -> Wet\n"
|
153 |
)
|
154 |
return kept_fx
|
155 |
|
|
|
163 |
else:
|
164 |
effect_indices = torch.arange(len(self.effects_to_keep))
|
165 |
# Up to max_kept_effects
|
166 |
+
if self.max_kept_effects != -1:
|
167 |
+
num_kept_effects = int(torch.rand(1).item() * (self.max_kept_effects)) + 1
|
168 |
+
else:
|
169 |
+
num_kept_effects = len(self.effects_to_keep)
|
170 |
+
effect_indices = effect_indices[:num_kept_effects]
|
171 |
# Index in effect settings
|
172 |
effect_names_to_apply = [self.effects_to_keep[i] for i in effect_indices]
|
173 |
effects_to_apply = [self.effects[i] for i in effect_names_to_apply]
|
|
|
184 |
else:
|
185 |
effect_indices = torch.arange(len(self.effects_to_remove))
|
186 |
# Up to max_removed_effects
|
187 |
+
if self.max_removed_effects != -1:
|
188 |
+
num_kept_effects = (
|
189 |
+
int(torch.rand(1).item() * (self.max_removed_effects)) + 1
|
190 |
+
)
|
191 |
+
else:
|
192 |
+
num_kept_effects = len(self.effects_to_remove)
|
193 |
effect_indices = effect_indices[: self.max_removed_effects]
|
194 |
# Index in effect settings
|
195 |
effect_names_to_apply = [self.effects_to_remove[i] for i in effect_indices]
|