├── .github └── workflows │ ├── build-mac.yml │ └── build-windows.yml ├── .gitignore ├── README.md └── main.py /.github/workflows/build-mac.yml: -------------------------------------------------------------------------------- 1 | name: build-mac 2 | on: 3 | workflow_dispatch: null 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | build-mac: 9 | name: Build demucs-cxfreeze for macOS 10 | runs-on: macos-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | with: 14 | ref: main 15 | - uses: actions/setup-python@v3 16 | with: 17 | python-version: '3.11' 18 | - run: pip install torch torchvision torchaudio demucs SoundFile cx-Freeze 19 | - run: cxfreeze main.py --target-dir=demucs-cxfreeze-mac --target-name=demucs-cxfreeze --packages=torch --includes=demucs.htdemucs 20 | - run: ditto -c -k --sequesterRsrc --keepParent demucs-cxfreeze-mac demucs-cxfreeze-mac.zip 21 | - uses: softprops/action-gh-release@v1 22 | with: 23 | tag_name: release-${{ github.sha }} 24 | files: demucs-cxfreeze-mac.zip 25 | -------------------------------------------------------------------------------- /.github/workflows/build-windows.yml: -------------------------------------------------------------------------------- 1 | name: build-windows 2 | on: 3 | workflow_dispatch: null 4 | push: 5 | branches: [main] 6 | 7 | jobs: 8 | build-windows: 9 | name: Build demucs-cxfreeze for Windows 10 | runs-on: windows-latest 11 | steps: 12 | - uses: actions/checkout@v3 13 | with: 14 | ref: main 15 | - uses: actions/setup-python@v3 16 | with: 17 | python-version: '3.11' 18 | - run: pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 19 | - run: pip install demucs SoundFile cx-Freeze 20 | - run: cxfreeze main.py --target-dir=demucs-cxfreeze-win-cuda --target-name=demucs-cxfreeze --packages=torch --includes=demucs.htdemucs 21 | - run: Invoke-WebRequest -Uri https://www.7-zip.org/a/7zr.exe -OutFile 7zr.exe 22 | - run: Invoke-WebRequest -Uri https://www.7-zip.org/a/7z2201-x64.exe -OutFile 7zInstaller-x64.exe 23 | - run: .\7zr.exe x "7zInstaller-x64.exe" 24 | - run: .\7z.exe a -m0=lzma2 -mmt=on -mx=9 "demucs-cxfreeze-win-cuda.7z" "demucs-cxfreeze-win-cuda" 25 | - uses: softprops/action-gh-release@v1 26 | with: 27 | tag_name: release-${{ github.sha }} 28 | files: demucs-cxfreeze-win-cuda.7z 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | # Byte-compiled / optimized / DLL files 4 | __pycache__/ 5 | *.py[cod] 6 | *$py.class 7 | 8 | # C extensions 9 | *.so 10 | 11 | # Distribution / packaging 12 | .Python 13 | build/ 14 | develop-eggs/ 15 | dist/ 16 | downloads/ 17 | eggs/ 18 | .eggs/ 19 | lib/ 20 | lib64/ 21 | parts/ 22 | sdist/ 23 | var/ 24 | wheels/ 25 | share/python-wheels/ 26 | *.egg-info/ 27 | .installed.cfg 28 | *.egg 29 | MANIFEST 30 | 31 | # PyInstaller 32 | # Usually these files are written by a python script from a template 33 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 34 | *.manifest 35 | *.spec 36 | 37 | # Installer logs 38 | pip-log.txt 39 | pip-delete-this-directory.txt 40 | 41 | # Unit test / coverage reports 42 | htmlcov/ 43 | .tox/ 44 | .nox/ 45 | .coverage 46 | .coverage.* 47 | .cache 48 | nosetests.xml 49 | coverage.xml 50 | *.cover 51 | *.py,cover 52 | .hypothesis/ 53 | .pytest_cache/ 54 | cover/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | db.sqlite3 64 | db.sqlite3-journal 65 | 66 | # Flask stuff: 67 | instance/ 68 | .webassets-cache 69 | 70 | # Scrapy stuff: 71 | .scrapy 72 | 73 | # Sphinx documentation 74 | docs/_build/ 75 | 76 | # PyBuilder 77 | .pybuilder/ 78 | target/ 79 | 80 | # Jupyter Notebook 81 | .ipynb_checkpoints 82 | 83 | # IPython 84 | profile_default/ 85 | ipython_config.py 86 | 87 | # pyenv 88 | # For a library or package, you might want to ignore these files since the code is 89 | # intended to run in multiple environments; otherwise, check them in: 90 | # .python-version 91 | 92 | # pipenv 93 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 94 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 95 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 96 | # install all needed dependencies. 97 | #Pipfile.lock 98 | 99 | # poetry 100 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 101 | # This is especially recommended for binary packages to ensure reproducibility, and is more 102 | # commonly ignored for libraries. 103 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 104 | #poetry.lock 105 | 106 | # pdm 107 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 108 | #pdm.lock 109 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 110 | # in version control. 111 | # https://pdm.fming.dev/#use-with-ide 112 | .pdm.toml 113 | 114 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 115 | __pypackages__/ 116 | 117 | # Celery stuff 118 | celerybeat-schedule 119 | celerybeat.pid 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | 151 | # pytype static type analyzer 152 | .pytype/ 153 | 154 | # Cython debug symbols 155 | cython_debug/ 156 | 157 | # PyCharm 158 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 159 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 160 | # and can be added to the global gitignore or merged into this file. For a more nuclear 161 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 162 | #.idea/ 163 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # demucs-cxfreeze 2 | 3 | ## Freezing `demucs` 4 | 5 | **With CUDA support (Windows & Linux)** 6 | ``` 7 | pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 demucs SoundFile cx-Freeze 8 | ``` 9 | **CPU only (Any OS)** 10 | ``` 11 | pip3 install torch torchvision torchaudio demucs SoundFile cx-Freeze 12 | ``` 13 | And then: 14 | ``` 15 | cxfreeze main.py --target-dir=dist --target-name=demucs-cxfreeze --packages=torch --includes=demucs.htdemucs 16 | ``` 17 | 18 | Copy `venv/Lib/site-packages/_soundfile_data` to `dist/lib/_soundfile_data` 19 | 20 | ## Additional Dependenices (should be shipped with frozen Demucs; not included with this repository's releases) 21 | 22 | ### `ffmpeg` and `ffprobe` 23 | 24 | The directory containing `ffmpeg` and `ffprobe` binaries should be added to the `PATH` environment variable in the environment in which `demucs` is run. 25 | 26 | #### Windows 27 | 28 | https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip 29 | 30 | #### macOS 31 | 32 | - https://evermeet.cx/ffmpeg/ffmpeg-109428-g10a56363a7.zip 33 | - https://evermeet.cx/ffmpeg/ffprobe-109428-g10a56363a7.zip 34 | 35 | ### Models 36 | 37 | Downloaded models and their corresponding YAML file should be placed in a directory, and that directory should be passed to Demucs via the `--repo` command line argument. 38 | 39 | #### `htdemucs_ft` 40 | 41 | - https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/f7e0c4bc-ba3fe64a.th 42 | - https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/d12395a8-e57c48e6.th 43 | - https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/92cfc3b6-ef3bcb9c.th 44 | - https://dl.fbaipublicfiles.com/demucs/hybrid_transformer/04573f0d-f3cf25b2.th 45 | - https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/htdemucs_ft.yaml 46 | 47 | ### List of all filenames (in case you need a model other than `htdemucs_ft`) 48 | 49 | https://raw.githubusercontent.com/facebookresearch/demucs/main/demucs/remote/files.txt 50 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | from demucs.separate import main 2 | 3 | if __name__ == '__main__': 4 | main() 5 | --------------------------------------------------------------------------------