splifft 0.0.2__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 (47) hide show
  1. splifft-0.0.2/.github/workflows/ci.yml +61 -0
  2. splifft-0.0.2/.github/workflows/docs.yml +43 -0
  3. splifft-0.0.2/.github/workflows/pypi.yml +92 -0
  4. splifft-0.0.2/.gitignore +194 -0
  5. splifft-0.0.2/LICENSE +21 -0
  6. splifft-0.0.2/PKG-INFO +266 -0
  7. splifft-0.0.2/README.md +197 -0
  8. splifft-0.0.2/data/audio/input/.gitignore +2 -0
  9. splifft-0.0.2/data/audio/output/.gitignore +2 -0
  10. splifft-0.0.2/data/config/bs_roformer.json +56 -0
  11. splifft-0.0.2/data/models/.gitignore +2 -0
  12. splifft-0.0.2/data/models/roformer.mlmodelc/.gitignore +2 -0
  13. splifft-0.0.2/data/mvsep/.gitignore +3 -0
  14. splifft-0.0.2/data/mvsep/plots/correlations_instrum.png +0 -0
  15. splifft-0.0.2/data/mvsep/plots/correlations_vocals.png +0 -0
  16. splifft-0.0.2/docs/api/config.md +1 -0
  17. splifft-0.0.2/docs/api/core.md +1 -0
  18. splifft-0.0.2/docs/api/index.md +1 -0
  19. splifft-0.0.2/docs/api/inference.md +1 -0
  20. splifft-0.0.2/docs/api/io.md +1 -0
  21. splifft-0.0.2/docs/api/models.md +3 -0
  22. splifft-0.0.2/docs/api/training.md +1 -0
  23. splifft-0.0.2/docs/assets/js/katex.js +10 -0
  24. splifft-0.0.2/docs/concepts.md +25 -0
  25. splifft-0.0.2/docs/config.md +7 -0
  26. splifft-0.0.2/docs/examples.md +5 -0
  27. splifft-0.0.2/docs/index.md +1 -0
  28. splifft-0.0.2/mkdocs.yml +96 -0
  29. splifft-0.0.2/pyproject.toml +85 -0
  30. splifft-0.0.2/scripts/mvsep.py +377 -0
  31. splifft-0.0.2/scripts/parse_weights.py +168 -0
  32. splifft-0.0.2/src/splifft/__init__.py +12 -0
  33. splifft-0.0.2/src/splifft/__main__.py +197 -0
  34. splifft-0.0.2/src/splifft/config.py +265 -0
  35. splifft-0.0.2/src/splifft/core.py +551 -0
  36. splifft-0.0.2/src/splifft/inference.py +137 -0
  37. splifft-0.0.2/src/splifft/io.py +70 -0
  38. splifft-0.0.2/src/splifft/models/__init__.py +140 -0
  39. splifft-0.0.2/src/splifft/models/bs_roformer.py +718 -0
  40. splifft-0.0.2/src/splifft/models/utils/__init__.py +13 -0
  41. splifft-0.0.2/src/splifft/models/utils/attend.py +107 -0
  42. splifft-0.0.2/src/splifft/models/utils/attend_sage.py +136 -0
  43. splifft-0.0.2/src/splifft/training.py +68 -0
  44. splifft-0.0.2/src/splifft/utils/mil.py +608 -0
  45. splifft-0.0.2/tests/test_config.py +184 -0
  46. splifft-0.0.2/tests/test_model_metadata.py +17 -0
  47. splifft-0.0.2/uv.lock +2731 -0
@@ -0,0 +1,61 @@
1
+ name: tests
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+ pull_request_target:
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ linting:
13
+ name: linting/formatting
14
+
15
+ runs-on: ubuntu-latest
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Install uv
21
+ uses: astral-sh/setup-uv@v6
22
+ with:
23
+ enable-cache: true
24
+
25
+ - name: Set up Python
26
+ uses: actions/setup-python@v5
27
+ with:
28
+ python-version: 3.12
29
+
30
+ - name: Install the project
31
+ run: |
32
+ uv sync --dev --all-extras
33
+
34
+ - name: Style checking
35
+ run: |
36
+ uv run ruff check src tests
37
+ uv run ruff format --check src tests
38
+
39
+ # - name: Type checking
40
+ # run: uv run mypy src tests
41
+
42
+ test:
43
+ name: "tests"
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+
48
+ - name: Install uv
49
+ uses: astral-sh/setup-uv@v6
50
+ with:
51
+ enable-cache: true
52
+
53
+ - uses: actions/setup-python@v5
54
+ with:
55
+ python-version: "3.13"
56
+
57
+ - name: Install the project
58
+ run: uv sync --all-groups --all-extras
59
+
60
+ - name: Run tests
61
+ run: uv run pytest
@@ -0,0 +1,43 @@
1
+ name: build docs
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ permissions:
10
+ contents: write
11
+ jobs:
12
+ deploy:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v6
19
+ with:
20
+ enable-cache: true
21
+
22
+ - name: Set up Python
23
+ uses: actions/setup-python@v5
24
+ with:
25
+ python-version: "3.13"
26
+
27
+ - name: Configure Git Credentials
28
+ run: |
29
+ git config user.name github-actions[bot]
30
+ git config user.email 41898282+github-actions[bot]@users.noreply.github.com
31
+
32
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
33
+ - uses: actions/cache@v4
34
+ with:
35
+ key: mkdocs-material-${{ env.cache_id }}
36
+ path: .cache
37
+ restore-keys: |
38
+ mkdocs-material-
39
+
40
+ - name: Install the project
41
+ run: uv sync --all-groups --all-extras
42
+
43
+ - run: uv run mkdocs gh-deploy --force
@@ -0,0 +1,92 @@
1
+ name: build wheel and publish to pypi
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ name: Build distribution
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+
13
+ - name: Install uv
14
+ uses: astral-sh/setup-uv@v6
15
+ with:
16
+ enable-cache: true
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.13"
22
+
23
+ - name: Build packages
24
+ run: |
25
+ uvx hatchling build
26
+
27
+ - name: Store the distribution packages
28
+ uses: actions/upload-artifact@v4
29
+ with:
30
+ name: python-package-distributions
31
+ path: dist/
32
+
33
+ publish-to-pypi:
34
+ name: >-
35
+ Publish Python distribution to PyPI
36
+ if: startsWith(github.ref, 'refs/tags/')
37
+ needs:
38
+ - build
39
+ runs-on: ubuntu-latest
40
+ environment:
41
+ name: pypi
42
+ url: https://pypi.org/p/splifft
43
+ permissions:
44
+ id-token: write
45
+ steps:
46
+ - name: Download all the dists
47
+ uses: actions/download-artifact@v4
48
+ with:
49
+ name: python-package-distributions
50
+ path: dist/
51
+ - name: Publish distribution to PyPI
52
+ uses: pypa/gh-action-pypi-publish@release/v1
53
+
54
+ github-release:
55
+ name: >-
56
+ Sign the Python distribution with Sigstore
57
+ and upload them to GitHub Release
58
+ needs:
59
+ - publish-to-pypi
60
+ runs-on: ubuntu-latest
61
+
62
+ permissions:
63
+ contents: write
64
+ id-token: write
65
+
66
+ steps:
67
+ - name: Download all the dists
68
+ uses: actions/download-artifact@v4
69
+ with:
70
+ name: python-package-distributions
71
+ path: dist/
72
+ - name: Sign the dists with Sigstore
73
+ uses: sigstore/gh-action-sigstore-python@v3.0.0
74
+ with:
75
+ inputs: >-
76
+ ./dist/*.tar.gz
77
+ ./dist/*.whl
78
+ - name: Create GitHub Release
79
+ env:
80
+ GITHUB_TOKEN: ${{ github.token }}
81
+ run: >-
82
+ gh release create
83
+ '${{ github.ref_name }}'
84
+ --repo '${{ github.repository }}'
85
+ --notes ""
86
+ - name: Upload artifact signatures to GitHub Release
87
+ env:
88
+ GITHUB_TOKEN: ${{ github.token }}
89
+ run: >-
90
+ gh release upload
91
+ '${{ github.ref_name }}' dist/**
92
+ --repo '${{ github.repository }}'
@@ -0,0 +1,194 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Abstra
171
+ # Abstra is an AI-powered process automation framework.
172
+ # Ignore directories containing user credentials, local state, and settings.
173
+ # Learn more at https://abstra.io/docs
174
+ .abstra/
175
+
176
+ # Visual Studio Code
177
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
178
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
179
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
180
+ # you could uncomment the following to ignore the enitre vscode folder
181
+ # .vscode/
182
+
183
+ # Ruff stuff:
184
+ .ruff_cache/
185
+
186
+ # PyPI configuration file
187
+ .pypirc
188
+
189
+ # Cursor
190
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
191
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
192
+ # refer to https://docs.cursor.com/context/ignore-files
193
+ .cursorignore
194
+ .cursorindexingignore
splifft-0.0.2/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 undef13
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
splifft-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,266 @@
1
+ Metadata-Version: 2.4
2
+ Name: splifft
3
+ Version: 0.0.2
4
+ Summary: Lightweight utilities for music source separation.
5
+ Project-URL: Documentation, https://undef13.github.io/splifft/
6
+ Project-URL: Repository, https://github.com/undef13/splifft
7
+ Project-URL: Releases, https://github.com/undef13/splifft/releases
8
+ Author: undef13
9
+ License: MIT License
10
+
11
+ Copyright (c) 2025 undef13
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: artificial intelligence,audio,deep learning,music,source separation
32
+ Classifier: Development Status :: 3 - Alpha
33
+ Classifier: Environment :: Console
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: Intended Audience :: Science/Research
36
+ Classifier: License :: OSI Approved :: MIT License
37
+ Classifier: Operating System :: OS Independent
38
+ Classifier: Programming Language :: Python :: 3
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Classifier: Programming Language :: Python :: 3.13
43
+ Classifier: Topic :: Multimedia :: Sound/Audio :: Analysis
44
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
45
+ Requires-Python: >=3.10
46
+ Requires-Dist: beartype>=0.21.0
47
+ Requires-Dist: einops>=0.8.1
48
+ Requires-Dist: hyper-connections>=0.1.15
49
+ Requires-Dist: numpy>=2.2.6
50
+ Requires-Dist: torch>=2.7.1
51
+ Provides-Extra: analysis
52
+ Requires-Dist: matplotlib>=3.10.3; extra == 'analysis'
53
+ Requires-Dist: polars>=1.30.0; extra == 'analysis'
54
+ Provides-Extra: cli
55
+ Requires-Dist: typer>=0.16.0; extra == 'cli'
56
+ Provides-Extra: config
57
+ Requires-Dist: pydantic>=2.11.5; extra == 'config'
58
+ Provides-Extra: inference
59
+ Requires-Dist: soundfile>=0.13.1; (sys_platform == 'Windows') and extra == 'inference'
60
+ Requires-Dist: torchaudio>=2.7.1; extra == 'inference'
61
+ Requires-Dist: tqdm>=4.67.1; extra == 'inference'
62
+ Provides-Extra: networking
63
+ Requires-Dist: aiolimiter>=1.2.1; extra == 'networking'
64
+ Requires-Dist: httpx[http2,socks,zstd]>=0.28.1; extra == 'networking'
65
+ Requires-Dist: orjson>=3.10.18; extra == 'networking'
66
+ Provides-Extra: sageattention
67
+ Requires-Dist: sageattention>=1.0.6; extra == 'sageattention'
68
+ Description-Content-Type: text/markdown
69
+
70
+ # SpliFFT
71
+
72
+ [![image](https://img.shields.io/pypi/v/splifft.svg)](https://pypi.python.org/pypi/splifft)
73
+ [![image](https://img.shields.io/pypi/l/splifft.svg)](https://pypi.python.org/pypi/splifft)
74
+ [![image](https://img.shields.io/pypi/pyversions/splifft.svg)](https://pypi.python.org/pypi/splifft)
75
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
76
+ [![MIT Licence](https://img.shields.io/badge/license-MIT-blue)](https://github.com/undef13/splifft/blob/main/LICENSE)
77
+
78
+ Lightweight utilities for music source separation.
79
+
80
+ This library is a ground-up rewrite of the [zfturbo's MSST repo](https://github.com/ZFTurbo/Music-Source-Separation-Training), with a strong focus on robustness, simplicity and extensibility. While it is a fantastic collection of models and training scripts, this rewrite adopts a different architecture to address common pain points in research code.
81
+
82
+ Key principles:
83
+
84
+ - **Configuration as code**: we replace untyped dictionaries and `ConfigDict` with pydantic models. This provides static type safety, runtime data validation, IDE autocompletion, and a single, clear source of truth for all parameters.
85
+ - **Data-oriented and functional core**: we avoid complex class hierarchies and inheritance. The codebase is built on plain data structures (like `dataclasses`) and pure, stateless functions.
86
+ - **Semantic typing as documentation**: we leverage Python's type system to convey intent. Types like `RawAudioTensor` vs. `NormalizedAudioTensor` make function signatures self-documenting, reducing the need for verbose comments and ensuring correctness.
87
+ - **Extensibility without modification**: new models can be integrated from external packages without altering the core library. The dynamic model loading system allows easy plug-and-play adhering to the open/closed principle.
88
+
89
+ ⚠️ This is pre-alpha software, expect significant breaking changes.
90
+
91
+ ## Features and Roadmap
92
+
93
+ Short term (high priority)
94
+
95
+ - [x] a robust, typed JSON configuration system powered by `pydantic`
96
+ - [x] inferencing:
97
+ - [x] normalization and denormalization
98
+ - [x] chunk generation: vectorized with `unfold`
99
+ - [x] chunk stitching: vectorized overlap-add with `fold`
100
+ - [x] flexible ruleset for stem deriving: add/subtract model outputs or any intermediate output (e.g., creating an `instrumental` track by subtracting `vocals` from the `mixture`).
101
+ - [x] web-based docs: generated with `mkdocs` with excellent crossrefs.
102
+ - [x] simple CLI for inferencing on a directory of audio files
103
+ - [ ] `BS-Roformer`: ensure bit-for-bit equivalence in pytorch and strive for max perf.
104
+ - [x] initial fp16 support
105
+ - [ ] support `coremltools` and `torch.compile`
106
+ - [ ] handroll complex multiplication implementation
107
+ - [ ] isolate/handroll istft in forward pass
108
+ - [ ] proper benchmarking (MFU, memory...)
109
+ - [ ] implement evals: SDR, bleedless, fullness, etc.
110
+ - [ ] simple file-based cache for model registry
111
+
112
+ Long term (low priority)
113
+
114
+ - [ ] data augmentation
115
+ - [ ] implement a complete, configurable training loop
116
+ - [ ] port additional SOTA models from MSST (Mel Roformer, SCNet, etc.).
117
+ - [ ] implement [`max` kernels](#mojo)
118
+ - [ ] simple web-based GUI with FastAPI and Svelte.
119
+
120
+ **Contributing**: PRs are very welcome!
121
+
122
+ ## Installation & Usage
123
+
124
+ - [I just want to run it](#cli)
125
+ - [I want to add it as a library to my Python project](#library)
126
+ - [I want to hack around](#development)
127
+
128
+ Documentation on the config (amongst other details) can be found [here](https://undef13.github.io/splifft/api/config/)
129
+
130
+ ### CLI
131
+
132
+ There are three steps. You do not need to have Python installed.
133
+
134
+ 1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/) if you haven't already. It is an awesome Python package and library manager with pip comptability.
135
+ ```sh
136
+ # Linux / MacOS
137
+ wget -qO- https://astral.sh/uv/install.sh | sh
138
+ # Windows
139
+ powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
140
+ ```
141
+
142
+ 2. Open a new terminal and install the current project as a tool. It will install the Python interpreter and all necessary packages if you haven't already:
143
+ ```sh
144
+ uv tool install "git+https://github.com/undef13/splifft.git[config,inference,cli]"
145
+ ```
146
+
147
+ 3. Go into a new directory and place the [model checkpoint](https://github.com/undef13/splifft/releases/download/v0.0.1/roformer-fp16.pt) and [configuration](https://raw.githubusercontent.com/undef13/splifft/refs/heads/main/data/config/bs_roformer.json) inside it. Assuming your current directory has this structure (doesn't have to be exactly this):
148
+
149
+ <details>
150
+ <summary>Grab an example audio from YouTube</summary>
151
+
152
+ ```sh
153
+ uv tool install yt-dlp
154
+ yt-dlp -f bestaudio -o data/audio/input/3BFTio5296w.flac 3BFTio5296w
155
+ ```
156
+ </details>
157
+
158
+ ```
159
+ .
160
+ └── data
161
+ ├── audio
162
+ │   ├── input
163
+ │   │   └── 3BFTio5296w.flac
164
+ │   └── output
165
+ ├── config
166
+ │   └── bs_roformer.json
167
+ └── models
168
+ └── roformer-fp16.pt
169
+ ```
170
+
171
+ Run:
172
+ ```sh
173
+ splifft separate data/audio/input/3BFTio5296w.flac --config data/config/bs_roformer.json --checkpoint data/models/roformer-fp16.pt
174
+ ```
175
+ <details>
176
+ <summary>Console output</summary>
177
+
178
+ ```php
179
+ [00:00:41] INFO using device=device(type='cuda') __main__.py:117
180
+ INFO loading configuration from __main__.py:119
181
+ config_path=PosixPath('data/config/bs_roformer.json')
182
+ INFO loading model metadata `BSRoformer` from module `splifft.models.bs_roformer` __main__.py:122
183
+ [00:00:42] INFO loading weights from checkpoint_path=PosixPath('data/models/roformer-fp16.pt') __main__.py:131
184
+ INFO processing audio file: __main__.py:138
185
+ mixture_path=PosixPath('data/audio/input/3BFTio5296w.flac')
186
+ [00:00:56] INFO wrote stem `bass` to data/audio/output/3BFTio5296w/bass.flac __main__.py:168
187
+ INFO wrote stem `drums` to data/audio/output/3BFTio5296w/drums.flac __main__.py:168
188
+ INFO wrote stem `other` to data/audio/output/3BFTio5296w/other.flac __main__.py:168
189
+ [00:00:57] INFO wrote stem `vocals` to data/audio/output/3BFTio5296w/vocals.flac __main__.py:168
190
+ INFO wrote stem `guitar` to data/audio/output/3BFTio5296w/guitar.flac __main__.py:168
191
+ INFO wrote stem `piano` to data/audio/output/3BFTio5296w/piano.flac __main__.py:168
192
+ [00:00:58] INFO wrote stem `instrumental` to data/audio/output/3BFTio5296w/instrumental.flac __main__.py:168
193
+ INFO wrote stem `drums_and_bass` to data/audio/output/3BFTio5296w/drums_and_bass.flac __main__.py:168
194
+ ```
195
+ </details>
196
+
197
+ To update the tool:
198
+
199
+ ```sh
200
+ uv tool upgrade splifft --force-reinstall
201
+ ```
202
+
203
+ ### Library
204
+
205
+ Add the latest bleeding edge to your project:
206
+
207
+ ```sh
208
+ uv add git+https://github.com/undef13/splifft.git
209
+ ```
210
+
211
+ This only installs absolutely minimal core dependencies for the `src/splifft/models/` directory. It does not enable inference, training or CLI components. You must install the optional dependencies defined in `pyproject.toml`, for example:
212
+
213
+ ```sh
214
+ # enable the built-in configuration, inference and CLI
215
+ uv add "git+https://github.com/undef13/splifft.git[config,inference,cli]"
216
+ ```
217
+
218
+ ### Development
219
+
220
+ For a local dev build enabling all optional and developer dependencies:
221
+
222
+ ```sh
223
+ git clone https://github.com/undef13/splifft.git
224
+ cd splifft
225
+ uv venv
226
+ uv sync --all-extras --all-groups
227
+ ```
228
+
229
+ If you're using `splifft` from another project, you may also want to use `--editable`.
230
+
231
+ ```sh
232
+ # lint
233
+ uv run ruff check src tests
234
+ # format
235
+ uv run ruff format --check src tests
236
+ # build & host documentation
237
+ uv run mkdocs serve
238
+ # type check
239
+ uv run mypy src tests
240
+ ```
241
+
242
+ This repo is no longer compatible with zfturbo's repo. The last version that does so is [`v0.0.1`](https://github.com/undef13/splifft/tree/v0.0.1). To pin a specific version in `uv`, change your `pyproject.toml`:
243
+
244
+ ```toml
245
+ [tool.uv.sources]
246
+ splifft = { git = "https://github.com/undef13/splifft.git", rev = "287235e520f3bb927b58f9f53749fe3ccc248fac" }
247
+ ```
248
+
249
+ ## Mojo
250
+
251
+ While the primary goal is just to have minimalist PyTorch-based inference engine, I may be using this project as an opportunity to learn more about heterogenous computing, particularly with the [Mojo language](https://docs.modular.com/mojo/why-mojo/). The ultimate goal will be to understand to what extent can its compile-time metaprogramming and explicit memory layout control be used in `BSRoformer`.
252
+
253
+ My approach will be incremental and bottom-up: I'll develop, test benchmark against their PyTorch counterparts. The PyTorch implementation will **always** remain the "source of truth", fully functional baseline and not be removed.
254
+
255
+ TODO:
256
+
257
+ - [ ] evaluate `pixi` in `pyproject.toml`.
258
+ - [ ] use `max.torch.CustomOpLibrary` to provide a callable from the pytorch side
259
+ - [ ] use [`DeviceContext`](https://github.com/modular/modular/blob/main/mojo/stdlib/stdlib/gpu/host/device_context.mojo) to interact with the GPU
260
+ - [ ] [attention](https://github.com/modular/modular/blob/main/examples/custom_ops/kernels/fused_attention.mojo)
261
+ - [ ] use [`LayoutTensor`](https://github.com/modular/modular/blob/main/max/kernels/src/layout/layout_tensor.mojo) for QKV
262
+ - [ ] rotary embedding
263
+ - [ ] feedforward
264
+ - [ ] transformer
265
+ - [ ] `BandSplit` & `MaskEstimator`
266
+ - [ ] full graph compilation