torch-l1-snr 0.0.1__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/LICENSE +1 -1
- {torch_l1_snr-0.0.1/torch_l1_snr.egg-info → torch_l1_snr-0.0.3}/PKG-INFO +28 -17
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/README.md +27 -16
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/setup.cfg +1 -1
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3/torch_l1_snr.egg-info}/PKG-INFO +28 -17
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/pyproject.toml +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/tests/test_losses.py +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1_snr.egg-info/SOURCES.txt +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1_snr.egg-info/dependency_links.txt +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1_snr.egg-info/requires.txt +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1_snr.egg-info/top_level.txt +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1snr/__init__.py +0 -0
- {torch_l1_snr-0.0.1 → torch_l1_snr-0.0.3}/torch_l1snr/l1snr.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: torch-l1-snr
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: L1-SNR loss functions for audio source separation in PyTorch
|
|
5
5
|
Home-page: https://github.com/crlandsc/torch-l1-snr
|
|
6
6
|
Author: Christopher Landscaping
|
|
@@ -26,14 +26,12 @@ Requires-Dist: torchaudio
|
|
|
26
26
|
Requires-Dist: numpy>=1.21.0
|
|
27
27
|
Dynamic: license-file
|
|
28
28
|
|
|
29
|
-

|
|
29
|
+

|
|
30
30
|
|
|
31
31
|
# NOTE: Repo is currently a work-in-progress and not ready for installation & use.
|
|
32
32
|
|
|
33
33
|
[](https://github.com/crlandsc/torch-l1snr/blob/main/LICENSE) [](https://github.com/crlandsc/torch-l1snr/stargazers)
|
|
34
34
|
|
|
35
|
-
# torch-l1-snr
|
|
36
|
-
|
|
37
35
|
A PyTorch implementation of L1-based Signal-to-Noise Ratio (SNR) loss functions for audio source separation. This package provides implementations and novel extensions based on concepts from recent academic papers, offering flexible and robust loss functions that can be easily integrated into any PyTorch-based audio separation pipeline.
|
|
38
36
|
|
|
39
37
|
The core `L1SNRLoss` is based on the loss function described in [1], while `L1SNRDBLoss` and `STFTL1SNRDBLoss` are extensions of the adaptive level-matching regularization technique proposed in [2].
|
|
@@ -48,12 +46,15 @@ The core `L1SNRLoss` is based on the loss function described in [1], while `L1SN
|
|
|
48
46
|
|
|
49
47
|
## Installation
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
[](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/)
|
|
50
|
+
|
|
51
|
+
## Install from PyPI
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install torch-l1-snr
|
|
55
|
+
```
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
## Install from GitHub
|
|
57
58
|
|
|
58
59
|
```bash
|
|
59
60
|
pip install git+https://github.com/crlandsc/torch-l1snr.git
|
|
@@ -90,9 +91,13 @@ from torch_l1snr import L1SNRDBLoss
|
|
|
90
91
|
estimates = torch.randn(4, 32000) # Batch of 4, 32000 samples
|
|
91
92
|
actuals = torch.randn(4, 32000)
|
|
92
93
|
|
|
93
|
-
# Initialize the loss function
|
|
94
|
-
# l1_weight=0.1 blends L1SNR with 10% L1 loss
|
|
95
|
-
loss_fn = L1SNRDBLoss(
|
|
94
|
+
# Initialize the loss function with regularization enabled
|
|
95
|
+
# l1_weight=0.1 blends L1SNR+Regularization with 10% L1 loss
|
|
96
|
+
loss_fn = L1SNRDBLoss(
|
|
97
|
+
name="l1_snr_db_loss",
|
|
98
|
+
use_regularization=True, # Enable adaptive level-matching regularization
|
|
99
|
+
l1_weight=0.1 # 10% L1 loss, 90% L1SNR + regularization
|
|
100
|
+
)
|
|
96
101
|
|
|
97
102
|
# Calculate loss
|
|
98
103
|
loss = loss_fn(estimates, actuals)
|
|
@@ -112,8 +117,11 @@ estimates = torch.randn(4, 32000)
|
|
|
112
117
|
actuals = torch.randn(4, 32000)
|
|
113
118
|
|
|
114
119
|
# Initialize the loss function
|
|
115
|
-
# Uses multiple STFT resolutions by default
|
|
116
|
-
loss_fn = STFTL1SNRDBLoss(
|
|
120
|
+
# Uses multiple STFT resolutions by default: [512, 1024, 2048] FFT sizes
|
|
121
|
+
loss_fn = STFTL1SNRDBLoss(
|
|
122
|
+
name="stft_l1_snr_db_loss",
|
|
123
|
+
l1_weight=0.0 # Pure L1SNR (no regularization, no L1)
|
|
124
|
+
)
|
|
117
125
|
|
|
118
126
|
# Calculate loss
|
|
119
127
|
loss = loss_fn(estimates, actuals)
|
|
@@ -137,9 +145,12 @@ actuals = torch.randn(2, 2, 44100)
|
|
|
137
145
|
|
|
138
146
|
# --- Configuration ---
|
|
139
147
|
loss_fn = MultiL1SNRDBLoss(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
name="multi_l1_snr_db_loss",
|
|
149
|
+
weight=1.0, # Overall weight for this loss
|
|
150
|
+
spec_weight=0.6, # 60% spectrogram loss, 40% time-domain loss
|
|
151
|
+
l1_weight=0.1, # Use 10% L1, 90% L1SNR+Reg in both domains
|
|
152
|
+
use_time_regularization=True, # Enable regularization in time domain
|
|
153
|
+
use_spec_regularization=False # Disable regularization in spec domain
|
|
143
154
|
)
|
|
144
155
|
loss = loss_fn(estimates, actuals)
|
|
145
156
|
print(f"Multi-domain Loss: {loss.item()}")
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-

|
|
1
|
+

|
|
2
2
|
|
|
3
3
|
# NOTE: Repo is currently a work-in-progress and not ready for installation & use.
|
|
4
4
|
|
|
5
5
|
[](https://github.com/crlandsc/torch-l1snr/blob/main/LICENSE) [](https://github.com/crlandsc/torch-l1snr/stargazers)
|
|
6
6
|
|
|
7
|
-
# torch-l1-snr
|
|
8
|
-
|
|
9
7
|
A PyTorch implementation of L1-based Signal-to-Noise Ratio (SNR) loss functions for audio source separation. This package provides implementations and novel extensions based on concepts from recent academic papers, offering flexible and robust loss functions that can be easily integrated into any PyTorch-based audio separation pipeline.
|
|
10
8
|
|
|
11
9
|
The core `L1SNRLoss` is based on the loss function described in [1], while `L1SNRDBLoss` and `STFTL1SNRDBLoss` are extensions of the adaptive level-matching regularization technique proposed in [2].
|
|
@@ -20,12 +18,15 @@ The core `L1SNRLoss` is based on the loss function described in [1], while `L1SN
|
|
|
20
18
|
|
|
21
19
|
## Installation
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
[](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/)
|
|
22
|
+
|
|
23
|
+
## Install from PyPI
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install torch-l1-snr
|
|
27
|
+
```
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
## Install from GitHub
|
|
29
30
|
|
|
30
31
|
```bash
|
|
31
32
|
pip install git+https://github.com/crlandsc/torch-l1snr.git
|
|
@@ -62,9 +63,13 @@ from torch_l1snr import L1SNRDBLoss
|
|
|
62
63
|
estimates = torch.randn(4, 32000) # Batch of 4, 32000 samples
|
|
63
64
|
actuals = torch.randn(4, 32000)
|
|
64
65
|
|
|
65
|
-
# Initialize the loss function
|
|
66
|
-
# l1_weight=0.1 blends L1SNR with 10% L1 loss
|
|
67
|
-
loss_fn = L1SNRDBLoss(
|
|
66
|
+
# Initialize the loss function with regularization enabled
|
|
67
|
+
# l1_weight=0.1 blends L1SNR+Regularization with 10% L1 loss
|
|
68
|
+
loss_fn = L1SNRDBLoss(
|
|
69
|
+
name="l1_snr_db_loss",
|
|
70
|
+
use_regularization=True, # Enable adaptive level-matching regularization
|
|
71
|
+
l1_weight=0.1 # 10% L1 loss, 90% L1SNR + regularization
|
|
72
|
+
)
|
|
68
73
|
|
|
69
74
|
# Calculate loss
|
|
70
75
|
loss = loss_fn(estimates, actuals)
|
|
@@ -84,8 +89,11 @@ estimates = torch.randn(4, 32000)
|
|
|
84
89
|
actuals = torch.randn(4, 32000)
|
|
85
90
|
|
|
86
91
|
# Initialize the loss function
|
|
87
|
-
# Uses multiple STFT resolutions by default
|
|
88
|
-
loss_fn = STFTL1SNRDBLoss(
|
|
92
|
+
# Uses multiple STFT resolutions by default: [512, 1024, 2048] FFT sizes
|
|
93
|
+
loss_fn = STFTL1SNRDBLoss(
|
|
94
|
+
name="stft_l1_snr_db_loss",
|
|
95
|
+
l1_weight=0.0 # Pure L1SNR (no regularization, no L1)
|
|
96
|
+
)
|
|
89
97
|
|
|
90
98
|
# Calculate loss
|
|
91
99
|
loss = loss_fn(estimates, actuals)
|
|
@@ -109,9 +117,12 @@ actuals = torch.randn(2, 2, 44100)
|
|
|
109
117
|
|
|
110
118
|
# --- Configuration ---
|
|
111
119
|
loss_fn = MultiL1SNRDBLoss(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
120
|
+
name="multi_l1_snr_db_loss",
|
|
121
|
+
weight=1.0, # Overall weight for this loss
|
|
122
|
+
spec_weight=0.6, # 60% spectrogram loss, 40% time-domain loss
|
|
123
|
+
l1_weight=0.1, # Use 10% L1, 90% L1SNR+Reg in both domains
|
|
124
|
+
use_time_regularization=True, # Enable regularization in time domain
|
|
125
|
+
use_spec_regularization=False # Disable regularization in spec domain
|
|
115
126
|
)
|
|
116
127
|
loss = loss_fn(estimates, actuals)
|
|
117
128
|
print(f"Multi-domain Loss: {loss.item()}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: torch-l1-snr
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: L1-SNR loss functions for audio source separation in PyTorch
|
|
5
5
|
Home-page: https://github.com/crlandsc/torch-l1-snr
|
|
6
6
|
Author: Christopher Landscaping
|
|
@@ -26,14 +26,12 @@ Requires-Dist: torchaudio
|
|
|
26
26
|
Requires-Dist: numpy>=1.21.0
|
|
27
27
|
Dynamic: license-file
|
|
28
28
|
|
|
29
|
-

|
|
29
|
+

|
|
30
30
|
|
|
31
31
|
# NOTE: Repo is currently a work-in-progress and not ready for installation & use.
|
|
32
32
|
|
|
33
33
|
[](https://github.com/crlandsc/torch-l1snr/blob/main/LICENSE) [](https://github.com/crlandsc/torch-l1snr/stargazers)
|
|
34
34
|
|
|
35
|
-
# torch-l1-snr
|
|
36
|
-
|
|
37
35
|
A PyTorch implementation of L1-based Signal-to-Noise Ratio (SNR) loss functions for audio source separation. This package provides implementations and novel extensions based on concepts from recent academic papers, offering flexible and robust loss functions that can be easily integrated into any PyTorch-based audio separation pipeline.
|
|
38
36
|
|
|
39
37
|
The core `L1SNRLoss` is based on the loss function described in [1], while `L1SNRDBLoss` and `STFTL1SNRDBLoss` are extensions of the adaptive level-matching regularization technique proposed in [2].
|
|
@@ -48,12 +46,15 @@ The core `L1SNRLoss` is based on the loss function described in [1], while `L1SN
|
|
|
48
46
|
|
|
49
47
|
## Installation
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
[](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/) [](https://pypi.org/project/torch-l1-snr/)
|
|
50
|
+
|
|
51
|
+
## Install from PyPI
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install torch-l1-snr
|
|
55
|
+
```
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
## Install from GitHub
|
|
57
58
|
|
|
58
59
|
```bash
|
|
59
60
|
pip install git+https://github.com/crlandsc/torch-l1snr.git
|
|
@@ -90,9 +91,13 @@ from torch_l1snr import L1SNRDBLoss
|
|
|
90
91
|
estimates = torch.randn(4, 32000) # Batch of 4, 32000 samples
|
|
91
92
|
actuals = torch.randn(4, 32000)
|
|
92
93
|
|
|
93
|
-
# Initialize the loss function
|
|
94
|
-
# l1_weight=0.1 blends L1SNR with 10% L1 loss
|
|
95
|
-
loss_fn = L1SNRDBLoss(
|
|
94
|
+
# Initialize the loss function with regularization enabled
|
|
95
|
+
# l1_weight=0.1 blends L1SNR+Regularization with 10% L1 loss
|
|
96
|
+
loss_fn = L1SNRDBLoss(
|
|
97
|
+
name="l1_snr_db_loss",
|
|
98
|
+
use_regularization=True, # Enable adaptive level-matching regularization
|
|
99
|
+
l1_weight=0.1 # 10% L1 loss, 90% L1SNR + regularization
|
|
100
|
+
)
|
|
96
101
|
|
|
97
102
|
# Calculate loss
|
|
98
103
|
loss = loss_fn(estimates, actuals)
|
|
@@ -112,8 +117,11 @@ estimates = torch.randn(4, 32000)
|
|
|
112
117
|
actuals = torch.randn(4, 32000)
|
|
113
118
|
|
|
114
119
|
# Initialize the loss function
|
|
115
|
-
# Uses multiple STFT resolutions by default
|
|
116
|
-
loss_fn = STFTL1SNRDBLoss(
|
|
120
|
+
# Uses multiple STFT resolutions by default: [512, 1024, 2048] FFT sizes
|
|
121
|
+
loss_fn = STFTL1SNRDBLoss(
|
|
122
|
+
name="stft_l1_snr_db_loss",
|
|
123
|
+
l1_weight=0.0 # Pure L1SNR (no regularization, no L1)
|
|
124
|
+
)
|
|
117
125
|
|
|
118
126
|
# Calculate loss
|
|
119
127
|
loss = loss_fn(estimates, actuals)
|
|
@@ -137,9 +145,12 @@ actuals = torch.randn(2, 2, 44100)
|
|
|
137
145
|
|
|
138
146
|
# --- Configuration ---
|
|
139
147
|
loss_fn = MultiL1SNRDBLoss(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
148
|
+
name="multi_l1_snr_db_loss",
|
|
149
|
+
weight=1.0, # Overall weight for this loss
|
|
150
|
+
spec_weight=0.6, # 60% spectrogram loss, 40% time-domain loss
|
|
151
|
+
l1_weight=0.1, # Use 10% L1, 90% L1SNR+Reg in both domains
|
|
152
|
+
use_time_regularization=True, # Enable regularization in time domain
|
|
153
|
+
use_spec_regularization=False # Disable regularization in spec domain
|
|
143
154
|
)
|
|
144
155
|
loss = loss_fn(estimates, actuals)
|
|
145
156
|
print(f"Multi-domain Loss: {loss.item()}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|