HS-TasNet


NameHS-TasNet JSON
Version 0.2.29 PyPI version JSON
download
home_pageNone
SummaryHS TasNet
upload_time2025-09-08 23:39:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2025 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence deep learning music separation real time
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="./fig1.png" width="350px"></img>

## HS-TasNet

Implementation of [HS-TasNet](https://arxiv.org/abs/2402.17701), "Real-time Low-latency Music Source Separation using Hybrid Spectrogram-TasNet", proposed by the research team at L-Acoustics

## Install

```bash
$ pip install HS-TasNet
```

## Usage

```python
import torch
from hs_tasnet import HSTasNet

model = HSTasNet()

audio = torch.randn(1, 2, 204800) # ~5 seconds of stereo

separated_audios, _ = model(audio)

assert separated_audios.shape == (1, 4, 2, 204800) # second dimension is the separated tracks
```

With the `Trainer`

```python
# model

from hs_tasnet import HSTasNet, Trainer

model = HSTasNet()

# trainer

trainer = Trainer(
    model,
    dataset = None,               # add your in-house Dataset
    concat_musdb_dataset = True,  # concat the musdb dataset automatically
    batch_size = 2,
    max_steps = 2,
    cpu = True,
)

trainer()

# after much training
# inferencing

model.sounddevice_stream(
    duration_seconds = 2,
    return_reduced_sources = [0, 2]
)

# or from the exponentially smoothed model (in the trainer)

trainer.ema_model.sounddevice_stream(...)

# or you can load from a specific checkpoint

model.load('./checkpoints/path.to.desired.ckpt.pt')
model.sounddevice_stream(...)

# to load an HS-TasNet from any of the saved checkpoints, without having to save its hyperparameters, just run

model = HSTasNet.init_and_load_from('./checkpoints/path.to.desired.ckpt.pt')

```

## Training script

First make sure dependencies are there by running

```shell
$ sh scripts/install.sh
```

Then make sure `uv` is installed

```shell
$ pip install uv
```

Finally run the following to train a newly initialized model on a small subset of MusDB, and make sure the loss goes down

```shell
$ uv run train.py
```

For distributed training, you just need to run `accelerate config` first, courtesy of [`accelerate` from 🤗](https://huggingface.co/docs/accelerate/en/index) but single machine is fine too

## Experiment tracking

To enable online experiment monitoring / tracking, you need to have `wandb` installed and logged in

```shell
$ pip install wandb && wandb login
```

Then

```shell
$ uv run train.py --use-wandb
```

To wipe the previous checkpoints and evaluated results, append `--clear-folders`

## Test

```shell
$ uv pip install '.[test]' --system
```

Then

```shell
$ pytest tests
```

## Sponsors

This open sourced work is sponsored by [Sweet Spot](https://github.com/sweetspotsoundsystem)

## Citations

```bibtex
@misc{venkatesh2024realtimelowlatencymusicsource,
    title    = {Real-time Low-latency Music Source Separation using Hybrid Spectrogram-TasNet}, 
    author   = {Satvik Venkatesh and Arthur Benilov and Philip Coleman and Frederic Roskam},
    year     = {2024},
    eprint   = {2402.17701},
    archivePrefix = {arXiv},
    primaryClass = {eess.AS},
    url      = {https://arxiv.org/abs/2402.17701}, 
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "HS-TasNet",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, music separation, real time",
    "author": null,
    "author_email": "Phil Wang <lucidrains@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/c8/b8/05f1c1f663b51278bb549ddc263fd3744549fe4449f00cb4b7967bee251e/hs_tasnet-0.2.29.tar.gz",
    "platform": null,
    "description": "<img src=\"./fig1.png\" width=\"350px\"></img>\n\n## HS-TasNet\n\nImplementation of [HS-TasNet](https://arxiv.org/abs/2402.17701), \"Real-time Low-latency Music Source Separation using Hybrid Spectrogram-TasNet\", proposed by the research team at L-Acoustics\n\n## Install\n\n```bash\n$ pip install HS-TasNet\n```\n\n## Usage\n\n```python\nimport torch\nfrom hs_tasnet import HSTasNet\n\nmodel = HSTasNet()\n\naudio = torch.randn(1, 2, 204800) # ~5 seconds of stereo\n\nseparated_audios, _ = model(audio)\n\nassert separated_audios.shape == (1, 4, 2, 204800) # second dimension is the separated tracks\n```\n\nWith the `Trainer`\n\n```python\n# model\n\nfrom hs_tasnet import HSTasNet, Trainer\n\nmodel = HSTasNet()\n\n# trainer\n\ntrainer = Trainer(\n    model,\n    dataset = None,               # add your in-house Dataset\n    concat_musdb_dataset = True,  # concat the musdb dataset automatically\n    batch_size = 2,\n    max_steps = 2,\n    cpu = True,\n)\n\ntrainer()\n\n# after much training\n# inferencing\n\nmodel.sounddevice_stream(\n    duration_seconds = 2,\n    return_reduced_sources = [0, 2]\n)\n\n# or from the exponentially smoothed model (in the trainer)\n\ntrainer.ema_model.sounddevice_stream(...)\n\n# or you can load from a specific checkpoint\n\nmodel.load('./checkpoints/path.to.desired.ckpt.pt')\nmodel.sounddevice_stream(...)\n\n# to load an HS-TasNet from any of the saved checkpoints, without having to save its hyperparameters, just run\n\nmodel = HSTasNet.init_and_load_from('./checkpoints/path.to.desired.ckpt.pt')\n\n```\n\n## Training script\n\nFirst make sure dependencies are there by running\n\n```shell\n$ sh scripts/install.sh\n```\n\nThen make sure `uv` is installed\n\n```shell\n$ pip install uv\n```\n\nFinally run the following to train a newly initialized model on a small subset of MusDB, and make sure the loss goes down\n\n```shell\n$ uv run train.py\n```\n\nFor distributed training, you just need to run `accelerate config` first, courtesy of [`accelerate` from \ud83e\udd17](https://huggingface.co/docs/accelerate/en/index) but single machine is fine too\n\n## Experiment tracking\n\nTo enable online experiment monitoring / tracking, you need to have `wandb` installed and logged in\n\n```shell\n$ pip install wandb && wandb login\n```\n\nThen\n\n```shell\n$ uv run train.py --use-wandb\n```\n\nTo wipe the previous checkpoints and evaluated results, append `--clear-folders`\n\n## Test\n\n```shell\n$ uv pip install '.[test]' --system\n```\n\nThen\n\n```shell\n$ pytest tests\n```\n\n## Sponsors\n\nThis open sourced work is sponsored by [Sweet Spot](https://github.com/sweetspotsoundsystem)\n\n## Citations\n\n```bibtex\n@misc{venkatesh2024realtimelowlatencymusicsource,\n    title    = {Real-time Low-latency Music Source Separation using Hybrid Spectrogram-TasNet}, \n    author   = {Satvik Venkatesh and Arthur Benilov and Philip Coleman and Frederic Roskam},\n    year     = {2024},\n    eprint   = {2402.17701},\n    archivePrefix = {arXiv},\n    primaryClass = {eess.AS},\n    url      = {https://arxiv.org/abs/2402.17701}, \n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 Phil Wang\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "HS TasNet",
    "version": "0.2.29",
    "project_urls": {
        "Homepage": "https://pypi.org/project/hs-tasnet/",
        "Repository": "https://github.com/lucidrains/hs-tasnet"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " music separation",
        " real time"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "9362d8331e341dcc206d6860f02371804c7af5777a460053414383bbe9d26f25",
                "md5": "0418dca772f731d8d06144675a15afa8",
                "sha256": "27570db7220f96632510edeb6207321fb933bfb625d2c6b22f429886cd6c97c5"
            },
            "downloads": -1,
            "filename": "hs_tasnet-0.2.29-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0418dca772f731d8d06144675a15afa8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 18616,
            "upload_time": "2025-09-08T23:39:01",
            "upload_time_iso_8601": "2025-09-08T23:39:01.831399Z",
            "url": "https://files.pythonhosted.org/packages/93/62/d8331e341dcc206d6860f02371804c7af5777a460053414383bbe9d26f25/hs_tasnet-0.2.29-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c8b805f1c1f663b51278bb549ddc263fd3744549fe4449f00cb4b7967bee251e",
                "md5": "9a8ca9508e2f7814e024ad9e0d856bff",
                "sha256": "cbcf823bb249eabcd59c96bd7f61e27d23c6a21b986072e8c5a73c134e043953"
            },
            "downloads": -1,
            "filename": "hs_tasnet-0.2.29.tar.gz",
            "has_sig": false,
            "md5_digest": "9a8ca9508e2f7814e024ad9e0d856bff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 322724,
            "upload_time": "2025-09-08T23:39:02",
            "upload_time_iso_8601": "2025-09-08T23:39:02.788964Z",
            "url": "https://files.pythonhosted.org/packages/c8/b8/05f1c1f663b51278bb549ddc263fd3744549fe4449f00cb4b7967bee251e/hs_tasnet-0.2.29.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-08 23:39:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidrains",
    "github_project": "hs-tasnet",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "hs-tasnet"
}
        
Elapsed time: 2.07212s