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.
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Christopher Landschoot
3
+ Copyright (c) 2026 Christopher Landschoot
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torch-l1-snr
3
- Version: 0.0.1
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
- ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png) -->
29
+ ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png)
30
30
 
31
31
  # NOTE: Repo is currently a work-in-progress and not ready for installation & use.
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()}")
@@ -1,11 +1,9 @@
1
- ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png) -->
1
+ ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png)
2
2
 
3
3
  # NOTE: Repo is currently a work-in-progress and not ready for installation & use.
4
4
 
5
5
  [![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)
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
- <!-- Add PyPI badges once the package is published -->
24
- <!-- [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
25
- <!-- [![PyPI - Version](https://img.shields.io/pypi/v/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
26
- <!-- [![Number of downloads from PyPI per month](https://img.shields.io/pypi/dm/torch-l1snr)](https://pypi.org/project/torch-l1snr/) -->
21
+ [![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/)
22
+
23
+ ## Install from PyPI
24
+
25
+ ```bash
26
+ pip install torch-l1-snr
27
+ ```
27
28
 
28
- You can install the package directly from GitHub:
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(l1_weight=0.1)
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(l1_weight=0.0) # Pure L1SNR + Regularization
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
- weight=1.0, # Overall weight for this loss
113
- spec_weight=0.7, # 70% spectrogram loss, 30% time-domain loss
114
- l1_weight=0.1, # Use 10% L1, 90% L1SNR+Reg
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]
2
2
  name = torch-l1-snr
3
- version = 0.0.1
3
+ version = 0.0.3
4
4
  author = Christopher Landscaping
5
5
  author_email = crlandschoot@gmail.com
6
6
  description = L1-SNR loss functions for audio source separation in PyTorch
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torch-l1-snr
3
- Version: 0.0.1
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
- ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png) -->
29
+ ![torch-l1-snr-logo](https://raw.githubusercontent.com/crlandsc/torch-l1-snr/main/images/logo.png)
30
30
 
31
31
  # NOTE: Repo is currently a work-in-progress and not ready for installation & use.
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()}")