wavelet-loss 2.0.0__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.
Files changed (50) hide show
  1. wavelet_loss-2.0.0/.github/workflows/pytest.yml +31 -0
  2. wavelet_loss-2.0.0/.github/workflows/release.yml +69 -0
  3. wavelet_loss-2.0.0/.gitignore +214 -0
  4. wavelet_loss-2.0.0/.python-version +1 -0
  5. wavelet_loss-2.0.0/CHANGELOG.md +58 -0
  6. wavelet_loss-2.0.0/LICENSE +177 -0
  7. wavelet_loss-2.0.0/PKG-INFO +87 -0
  8. wavelet_loss-2.0.0/README.md +63 -0
  9. wavelet_loss-2.0.0/docs/advanced.md +43 -0
  10. wavelet_loss-2.0.0/docs/configurations.md +116 -0
  11. wavelet_loss-2.0.0/docs/index.md +44 -0
  12. wavelet_loss-2.0.0/docs/pywavelets.md +40 -0
  13. wavelet_loss-2.0.0/docs/transform-conventions.md +79 -0
  14. wavelet_loss-2.0.0/docs/transforms.md +85 -0
  15. wavelet_loss-2.0.0/pyproject.toml +51 -0
  16. wavelet_loss-2.0.0/scripts/README.md +146 -0
  17. wavelet_loss-2.0.0/scripts/auxiliary_loss_ab.py +207 -0
  18. wavelet_loss-2.0.0/scripts/overfit_recovery.py +137 -0
  19. wavelet_loss-2.0.0/scripts/utils/__init__.py +1 -0
  20. wavelet_loss-2.0.0/scripts/utils/image_processing.py +72 -0
  21. wavelet_loss-2.0.0/scripts/utils/plotting.py +155 -0
  22. wavelet_loss-2.0.0/scripts/utils/vae_utils.py +230 -0
  23. wavelet_loss-2.0.0/scripts/visualize_vae_latent_transforms.py +397 -0
  24. wavelet_loss-2.0.0/scripts/visualize_wavelet_transforms.py +416 -0
  25. wavelet_loss-2.0.0/scripts/visualize_wavelet_transforms_README.md +53 -0
  26. wavelet_loss-2.0.0/scripts/wavelet_coefficients_analysis.py +343 -0
  27. wavelet_loss-2.0.0/scripts/wavelet_loss_image.py +251 -0
  28. wavelet_loss-2.0.0/scripts/wavelet_loss_landscape.py +155 -0
  29. wavelet_loss-2.0.0/scripts/wavelet_loss_latent.py +429 -0
  30. wavelet_loss-2.0.0/scripts/wavelet_loss_spatial.py +353 -0
  31. wavelet_loss-2.0.0/scripts/wavelet_loss_spatial_unified.py +390 -0
  32. wavelet_loss-2.0.0/src/visualize.py +394 -0
  33. wavelet_loss-2.0.0/src/wavelet_loss/__init__.py +3 -0
  34. wavelet_loss-2.0.0/src/wavelet_loss/loss.py +662 -0
  35. wavelet_loss-2.0.0/src/wavelet_transform/__init__.py +23 -0
  36. wavelet_loss-2.0.0/src/wavelet_transform/backends.py +130 -0
  37. wavelet_loss-2.0.0/src/wavelet_transform/transform.py +429 -0
  38. wavelet_loss-2.0.0/tests/test_backends.py +87 -0
  39. wavelet_loss-2.0.0/tests/test_dwt.py +225 -0
  40. wavelet_loss-2.0.0/tests/test_metrics.py +163 -0
  41. wavelet_loss-2.0.0/tests/test_normalize_bands.py +28 -0
  42. wavelet_loss-2.0.0/tests/test_qwt.py +381 -0
  43. wavelet_loss-2.0.0/tests/test_qwt_forward.py +163 -0
  44. wavelet_loss-2.0.0/tests/test_reduce.py +45 -0
  45. wavelet_loss-2.0.0/tests/test_swt.py +256 -0
  46. wavelet_loss-2.0.0/tests/test_swt_parity.py +37 -0
  47. wavelet_loss-2.0.0/tests/test_timestep.py +84 -0
  48. wavelet_loss-2.0.0/tests/test_wavelet_loss.py +356 -0
  49. wavelet_loss-2.0.0/tests/test_wavelet_loss_backend.py +20 -0
  50. wavelet_loss-2.0.0/uv.lock +1572 -0
@@ -0,0 +1,31 @@
1
+ name: Python Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v6
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+
27
+ - name: Install the project
28
+ run: uv sync --locked --all-extras --dev
29
+
30
+ - name: Run tests
31
+ run: uv run pytest
@@ -0,0 +1,69 @@
1
+ name: Release
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Install uv
15
+ uses: astral-sh/setup-uv@v6
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.10"
21
+
22
+ - name: Install the project
23
+ run: uv sync --locked --all-extras --dev
24
+
25
+ - name: Run tests
26
+ run: uv run pytest
27
+
28
+ - name: Build distributions
29
+ run: uv build
30
+
31
+ - uses: actions/upload-artifact@v4
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+
36
+ publish-pypi:
37
+ needs: build
38
+ runs-on: ubuntu-latest
39
+ environment:
40
+ name: pypi
41
+ url: https://pypi.org/p/wavelet-loss
42
+ permissions:
43
+ # Required for PyPI trusted publishing (OIDC)
44
+ id-token: write
45
+ steps:
46
+ - uses: actions/download-artifact@v4
47
+ with:
48
+ name: dist
49
+ path: dist/
50
+
51
+ - name: Publish to PyPI
52
+ uses: pypa/gh-action-pypi-publish@release/v1
53
+
54
+ attach-to-release:
55
+ needs: build
56
+ if: github.event_name == 'release'
57
+ runs-on: ubuntu-latest
58
+ permissions:
59
+ contents: write
60
+ steps:
61
+ - uses: actions/download-artifact@v4
62
+ with:
63
+ name: dist
64
+ path: dist/
65
+
66
+ - name: Upload artifacts to GitHub release
67
+ run: gh release upload "${{ github.event.release.tag_name }}" dist/* --repo "$GITHUB_REPOSITORY"
68
+ env:
69
+ GH_TOKEN: ${{ github.token }}
@@ -0,0 +1,214 @@
1
+ .mcp.json
2
+ .claude
3
+ CLAUDE.md
4
+
5
+ notes/
6
+ outputs/
7
+ docs/superpowers/specs/
8
+
9
+ *.png
10
+ *.jpg
11
+
12
+ # Byte-compiled / optimized / DLL files
13
+ __pycache__/
14
+ *.py[codz]
15
+ *$py.class
16
+
17
+ # C extensions
18
+ *.so
19
+
20
+ # Distribution / packaging
21
+ .Python
22
+ build/
23
+ develop-eggs/
24
+ dist/
25
+ downloads/
26
+ eggs/
27
+ .eggs/
28
+ lib/
29
+ lib64/
30
+ parts/
31
+ sdist/
32
+ var/
33
+ wheels/
34
+ share/python-wheels/
35
+ *.egg-info/
36
+ .installed.cfg
37
+ *.egg
38
+ MANIFEST
39
+
40
+ # PyInstaller
41
+ # Usually these files are written by a python script from a template
42
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
43
+ *.manifest
44
+ *.spec
45
+
46
+ # Installer logs
47
+ pip-log.txt
48
+ pip-delete-this-directory.txt
49
+
50
+ # Unit test / coverage reports
51
+ htmlcov/
52
+ .tox/
53
+ .nox/
54
+ .coverage
55
+ .coverage.*
56
+ .cache
57
+ nosetests.xml
58
+ coverage.xml
59
+ *.cover
60
+ *.py.cover
61
+ .hypothesis/
62
+ .pytest_cache/
63
+ cover/
64
+
65
+ # Translations
66
+ *.mo
67
+ *.pot
68
+
69
+ # Django stuff:
70
+ *.log
71
+ local_settings.py
72
+ db.sqlite3
73
+ db.sqlite3-journal
74
+
75
+ # Flask stuff:
76
+ instance/
77
+ .webassets-cache
78
+
79
+ # Scrapy stuff:
80
+ .scrapy
81
+
82
+ # Sphinx documentation
83
+ docs/_build/
84
+
85
+ # PyBuilder
86
+ .pybuilder/
87
+ target/
88
+
89
+ # Jupyter Notebook
90
+ .ipynb_checkpoints
91
+
92
+ # IPython
93
+ profile_default/
94
+ ipython_config.py
95
+
96
+ # pyenv
97
+ # For a library or package, you might want to ignore these files since the code is
98
+ # intended to run in multiple environments; otherwise, check them in:
99
+ # .python-version
100
+
101
+ # pipenv
102
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
103
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
104
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
105
+ # install all needed dependencies.
106
+ #Pipfile.lock
107
+
108
+ # UV
109
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
110
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
111
+ # commonly ignored for libraries.
112
+ #uv.lock
113
+
114
+ # poetry
115
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
116
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
117
+ # commonly ignored for libraries.
118
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
119
+ #poetry.lock
120
+ #poetry.toml
121
+
122
+ # pdm
123
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
124
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
125
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
126
+ #pdm.lock
127
+ #pdm.toml
128
+ .pdm-python
129
+ .pdm-build/
130
+
131
+ # pixi
132
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
133
+ #pixi.lock
134
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
135
+ # in the .venv directory. It is recommended not to include this directory in version control.
136
+ .pixi
137
+
138
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
139
+ __pypackages__/
140
+
141
+ # Celery stuff
142
+ celerybeat-schedule
143
+ celerybeat.pid
144
+
145
+ # SageMath parsed files
146
+ *.sage.py
147
+
148
+ # Environments
149
+ .env
150
+ .envrc
151
+ .venv
152
+ env/
153
+ venv/
154
+ ENV/
155
+ env.bak/
156
+ venv.bak/
157
+
158
+ # Spyder project settings
159
+ .spyderproject
160
+ .spyproject
161
+
162
+ # Rope project settings
163
+ .ropeproject
164
+
165
+ # mkdocs documentation
166
+ /site
167
+
168
+ # mypy
169
+ .mypy_cache/
170
+ .dmypy.json
171
+ dmypy.json
172
+
173
+ # Pyre type checker
174
+ .pyre/
175
+
176
+ # pytype static type analyzer
177
+ .pytype/
178
+
179
+ # Cython debug symbols
180
+ cython_debug/
181
+
182
+ # PyCharm
183
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
184
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
185
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
186
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
187
+ #.idea/
188
+
189
+ # Abstra
190
+ # Abstra is an AI-powered process automation framework.
191
+ # Ignore directories containing user credentials, local state, and settings.
192
+ # Learn more at https://abstra.io/docs
193
+ .abstra/
194
+
195
+ # Visual Studio Code
196
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
197
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
198
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
199
+ # you could uncomment the following to ignore the entire vscode folder
200
+ # .vscode/
201
+
202
+ # Ruff stuff:
203
+ .ruff_cache/
204
+
205
+ # PyPI configuration file
206
+ .pypirc
207
+
208
+ # Marimo
209
+ marimo/_static/
210
+ marimo/_lsp/
211
+ __marimo__/
212
+
213
+ # Streamlit
214
+ .streamlit/secrets.toml
@@ -0,0 +1 @@
1
+ 3.10
@@ -0,0 +1,58 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0 (2026-07-01)
4
+
5
+ Correctness-focused major release. Several defaults changed because the old
6
+ behavior was silently wrong for training; upgrading requires reviewing the
7
+ breaking changes below.
8
+
9
+ ### Breaking changes
10
+
11
+ - **`normalize_bands` now defaults to `False`.** The old default (`True`)
12
+ standardized prediction and target bands independently, making the loss
13
+ blind to amplitude and offset errors — a 5×-scaled prediction returned ≈0
14
+ loss. The opt-in `True` path now uses shared normalization (target-derived
15
+ mean/std applied to both), which preserves amplitude error. If you relied on
16
+ the old per-band standardization, there is no equivalent; it was a bug.
17
+ - **`forward` returns a scalar by default (`reduce=True`).** It returns
18
+ `(loss, metrics)` where `loss` is a scalar ready for `backward()`. Callers
19
+ that indexed or took `len()` of the result must pass `reduce=False` to get
20
+ the per-band list.
21
+ - **Metrics are opt-in.** `WaveletLoss(metrics=True)` is required to collect
22
+ metrics; the default returns an empty dict and performs zero `.item()` GPU
23
+ syncs in the hot path. Metric keys were also renamed into a unified
24
+ `wavelet_loss/` namespace, and misleading metrics were replaced (signed-mean
25
+ `avg_hf` → coefficient energy) or dropped (scale-confounded sparsity).
26
+ - **Timesteps are validated against `max_timestep` (default `1.0`).** The
27
+ timestep weighting is now flow-matching-native: sigmas in `[0, 1]` work out
28
+ of the box, and DDPM-style integer timesteps require
29
+ `WaveletLoss(..., max_timestep=1000)`. Timesteps outside
30
+ `[0, max_timestep]` raise `ValueError` instead of silently saturating the
31
+ weight. The fade is configurable via `timestep_cutoff` (default `0.7`) and
32
+ `timestep_transition_width` (default `0.4`).
33
+ - **Inputs must be 4D `[B, C, H, W]`.** `forward` raises `ValueError`
34
+ otherwise.
35
+
36
+ ### Fixed
37
+
38
+ - SWT rewritten to match `pywt.swt2` exactly (vectorized and differentiable);
39
+ previously the à-trous roll shift produced coefficients that disagreed with
40
+ PyWavelets.
41
+ - DWT correctness is now asserted via parity tests against PyWavelets,
42
+ including band mapping and boundary modes.
43
+ - Loss-reporting metrics corrected.
44
+
45
+ ### Added
46
+
47
+ - Backend factory (`make_backend`) selecting between `pytorch_wavelets` and a
48
+ custom zero-mode DWT backend with PyWavelets parity; QWT is flagged
49
+ experimental.
50
+ - Timestep-aware loss weighting for diffusion / flow-matching training (see
51
+ `docs/configurations.md`).
52
+ - Backprop tests for SWT, QWT, and the custom DWT backend; CPU-default test
53
+ suite (`WAVELET_TEST_CUDA=1` for GPU paths).
54
+ - Transform conventions reference (`docs/transform-conventions.md`).
55
+
56
+ ## 0.1.0
57
+
58
+ Initial release.
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.4
2
+ Name: wavelet-loss
3
+ Version: 2.0.0
4
+ Summary: Wavelet-based loss calculations
5
+ Project-URL: Homepage, https://github.com/rockerBOO/wavelet-loss
6
+ Project-URL: Issues, https://github.com/rockerBOO/wavelet-loss/issues
7
+ Project-URL: Repository, https://github.com/rockerBOO/wavelet-loss.git
8
+ Author-email: "Dave Lage (rockerBOO)" <rockerboo@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.10
12
+ Requires-Dist: pytorch-wavelets>=1.3.0
13
+ Requires-Dist: pywavelets>=1.8.0
14
+ Requires-Dist: torch>=2.0.0
15
+ Provides-Extra: image
16
+ Requires-Dist: opencv-python>=4.7.0; extra == 'image'
17
+ Requires-Dist: pillow>=10.0.0; extra == 'image'
18
+ Provides-Extra: vae
19
+ Requires-Dist: accelerate>=1.8.1; extra == 'vae'
20
+ Requires-Dist: diffusers; extra == 'vae'
21
+ Provides-Extra: visualize
22
+ Requires-Dist: matplotlib>=3.10.3; extra == 'visualize'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Wavelet Loss
26
+
27
+ A Python library for wavelet-based loss calculations in machine learning.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ pip install git+https://github.com/rockerBOO/wavelet-loss.git
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ## Quick Start
38
+
39
+ ```python
40
+ import torch
41
+ from wavelet_loss import WaveletLoss
42
+
43
+ # Frequency-aware loss for VAE latents [B, C, H, W]
44
+ loss_fn = WaveletLoss(wavelet="db4", level=2, transform_type="dwt")
45
+
46
+ prediction = torch.randn(2, 4, 32, 32, requires_grad=True)
47
+ target = torch.randn(2, 4, 32, 32)
48
+
49
+ loss, metrics = loss_fn(prediction, target) # scalar loss (reduce=True default)
50
+ loss.backward()
51
+ ```
52
+
53
+ ### Diffusion / flow-matching training
54
+
55
+ Pass the current timestep to fade out high-frequency loss at high noise levels:
56
+
57
+ ```python
58
+ # Flow-matching sigmas in [0, 1] (default convention)
59
+ loss_fn = WaveletLoss(wavelet="db4", level=2)
60
+ loss, metrics = loss_fn(prediction, target, timestep=timesteps)
61
+
62
+ # DDPM-style integer timesteps require max_timestep=1000
63
+ loss_fn = WaveletLoss(wavelet="db4", level=2, max_timestep=1000)
64
+ ```
65
+
66
+ See [docs/configurations.md](docs/configurations.md) for `timestep_cutoff`,
67
+ `timestep_transition_width`, and other options.
68
+
69
+ ## Features
70
+
71
+ - Discrete Wavelet Transform (DWT)
72
+ - Quadrature Wavelet Transform (QWT)
73
+ - Stationary Wavelet Transform (SWT)
74
+ - Wavelet-based loss calculations
75
+ - Timestep-aware loss weighting for diffusion / flow-matching training
76
+
77
+ ## Upgrading to 2.0
78
+
79
+ See [CHANGELOG.md](CHANGELOG.md) for breaking changes: `normalize_bands` now
80
+ defaults to `False`, `forward` returns a scalar by default (`reduce=True`),
81
+ metrics are opt-in (`metrics=True`), and timesteps are validated against
82
+ `max_timestep` (default `1.0`, flow-matching convention).
83
+
84
+ ## Development
85
+
86
+ - Run tests: `uv run pytest`
87
+ - Python 3.10+ required