torch-l1-snr 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torch-l1-snr
3
- Version: 0.0.2
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
@@ -32,8 +32,6 @@ Dynamic: license-file
32
32
 
33
33
  [![LICENSE](https://img.shields.io/github/license/crlandsc/torch-l1snr)](https://github.com/crlandsc/torch-l1snr/blob/main/LICENSE) [![GitHub Repo stars](https://img.shields.io/github/stars/crlandsc/torch-l1snr)](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
- <!-- Add PyPI badges once the package is published -->
52
- <!-- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
53
- <!-- [![PyPI - Version](https://img.shields.io/pypi/v/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
54
- <!-- [![Number of downloads from PyPI per month](https://img.shields.io/pypi/dm/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
49
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/torch-l1-snr)](https://pypi.org/project/torch-l1-snr/) [![PyPI - Version](https://img.shields.io/pypi/v/torch-l1-snr)](https://pypi.org/project/torch-l1-snr/) [![Number of downloads from PyPI per month](https://img.shields.io/pypi/dm/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
- You can install the package directly from GitHub:
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(l1_weight=0.1)
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(l1_weight=0.0) # Pure L1SNR + Regularization
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
- weight=1.0, # Overall weight for this loss
141
- spec_weight=0.7, # 70% spectrogram loss, 30% time-domain loss
142
- l1_weight=0.1, # Use 10% L1, 90% L1SNR+Reg
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()}")
@@ -0,0 +1,7 @@
1
+ torch_l1_snr-0.0.3.dist-info/licenses/LICENSE,sha256=JdS2Pv6DDs3jvXHACGdcHYdiFMe9EO1XGeHkEHLTr8Y,1079
2
+ torch_l1snr/__init__.py,sha256=pR9jg3fjTKt_suZoVDC67tqB7EWRkbfaXaPP7pYQrlQ,220
3
+ torch_l1snr/l1snr.py,sha256=aqmtNfT_8A0IRI9jiVGwNse3igBvelQGKnjfe23Xh7w,35304
4
+ torch_l1_snr-0.0.3.dist-info/METADATA,sha256=mEcAB0insIw0SfvgF5i3AtLeWXP-pBMQJhNoQRAT6KA,10823
5
+ torch_l1_snr-0.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
+ torch_l1_snr-0.0.3.dist-info/top_level.txt,sha256=NfaRND6pcjZ7-035d4XAg8xJuz31EEU210Y9xWeFOxc,12
7
+ torch_l1_snr-0.0.3.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- torch_l1_snr-0.0.2.dist-info/licenses/LICENSE,sha256=JdS2Pv6DDs3jvXHACGdcHYdiFMe9EO1XGeHkEHLTr8Y,1079
2
- torch_l1snr/__init__.py,sha256=pR9jg3fjTKt_suZoVDC67tqB7EWRkbfaXaPP7pYQrlQ,220
3
- torch_l1snr/l1snr.py,sha256=aqmtNfT_8A0IRI9jiVGwNse3igBvelQGKnjfe23Xh7w,35304
4
- torch_l1_snr-0.0.2.dist-info/METADATA,sha256=C8sH_v1T2LYRCwCiLMMJkrnh4l-chYzjZYbD2xyI8gg,10370
5
- torch_l1_snr-0.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
6
- torch_l1_snr-0.0.2.dist-info/top_level.txt,sha256=NfaRND6pcjZ7-035d4XAg8xJuz31EEU210Y9xWeFOxc,12
7
- torch_l1_snr-0.0.2.dist-info/RECORD,,