{"id":20013285,"url":"https://github.com/tomrunia/pytorchwavelets","last_synced_at":"2025-04-09T12:07:40.000Z","repository":{"id":40723551,"uuid":"129645056","full_name":"tomrunia/PyTorchWavelets","owner":"tomrunia","description":"PyTorch implementation of the wavelet analysis from Torrence \u0026 Compo (1998)","archived":false,"fork":false,"pushed_at":"2022-02-03T09:25:39.000Z","size":1097,"stargazers_count":311,"open_issues_count":5,"forks_count":58,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-02T10:14:06.058Z","etag":null,"topics":["filtering","pytorch","signal-processing","wavelets"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tomrunia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-15T19:50:19.000Z","updated_at":"2025-03-21T10:13:54.000Z","dependencies_parsed_at":"2022-07-29T06:18:15.479Z","dependency_job_id":null,"html_url":"https://github.com/tomrunia/PyTorchWavelets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchWavelets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchWavelets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchWavelets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchWavelets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomrunia","download_url":"https://codeload.github.com/tomrunia/PyTorchWavelets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248036067,"owners_count":21037092,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filtering","pytorch","signal-processing","wavelets"],"created_at":"2024-11-13T07:35:53.292Z","updated_at":"2025-04-09T12:07:39.981Z","avatar_url":"https://github.com/tomrunia.png","language":"Python","readme":"# Continuous Wavelet Transforms in PyTorch\n\nThis is a PyTorch implementation for the wavelet analysis outlined in [Torrence\nand Compo (BAMS, 1998)](http://paos.colorado.edu/research/wavelets/). The code builds upon the excellent [implementation](https://github.com/aaren/wavelets/)\nof Aaron O'Leary by adding a PyTorch filter bank wrapper to enable fast convolution on the GPU. Specifically, the code was written to speed-up the CWT computation for a large number of 1D signals and relies on `torch.nn.Conv1d` for convolution. \n\n![PyTorch Wavelets](/assets/scalogram_comparison.png \"Scalogram Comparison\")\n\n## Citation\n\nIf you found this code useful, please cite our paper [Repetition Estimation](https://link.springer.com/article/10.1007/s11263-019-01194-0) (IJCV, 2019):\n\n    @article{runia2019repetition,\n      title={Repetition estimation},\n      author={Runia, Tom FH and Snoek, Cees GM and Smeulders, Arnold WM},\n      journal={International Journal of Computer Vision},\n      volume={127},\n      number={9},\n      pages={1361--1383},\n      year={2019},\n      publisher={Springer}\n    }\n    \n## Usage\n\nIn addition to the PyTorch implementation defined in `WaveletTransformTorch` the original SciPy version is also included in `WaveletTransform` for completeness. As the GPU implementation highly benefits from parallelization, the `cwt` and `power` methods expect signal batches of shape `[num_signals,signal_length]` instead of individual signals. \n\n```python\nimport numpy as np\nfrom wavelets_pytorch.transform import WaveletTransform        # SciPy version\nfrom wavelets_pytorch.transform import WaveletTransformTorch   # PyTorch version\n\ndt = 0.1         # sampling frequency\ndj = 0.125       # scale distribution parameter\nbatch_size = 32  # how many signals to process in parallel\n\n# Batch of signals to process\nbatch = [batch_size x signal_length] \n\n# Initialize wavelet filter banks (scipy and torch implementation)\nwa_scipy = WaveletTransform(dt, dj)\nwa_torch = WaveletTransformTorch(dt, dj, cuda=True)\n\n# Performing wavelet transform (and compute scalogram)\ncwt_scipy = wa_scipy.cwt(batch)\ncwt_torch = wa_torch.cwt(batch)\n\n# For plotting, see the examples/plot.py function.\n# ...\n```\n\n## Supported Wavelets\n\nThe wavelet implementations are taken from [here](https://github.com/aaren/wavelets/blob/master/wavelets/wavelets.py). Default is the Morlet wavelet.\n\n## Benchmark\n\nPerforming parallel CWT computation on the GPU using PyTorch results in a significant speed-up. Increasing the batch size will give faster runtimes. The plot below shows a comaprison between the `scipy` versus `torch` implementation as function of the batch size `N` and input signal length. These results were obtained on a powerful Linux desktop with NVIDIA Titan X GPU.\n\n\u003ca href=\"/assets/runtime_versus_signal_length.png\"\u003e\u003cimg src=\"/assets/runtime_versus_signal_length.png\" width=\"700px\" \u003e\u003c/a\u003e\n\n## Installation\n\nClone and install:\n\n```sh\ngit clone https://github.com/tomrunia/PyTorchWavelets.git\ncd PyTorchWavelets\npip install -r requirements.txt\npython setup.py install\n```\n\n## Requirements\n\n- Python 2.7 or 3.6 (other versions might also work)\n- Numpy (developed with 1.14.1)\n- Scipy (developed with 1.0.0)\n- PyTorch \u003e= 0.4.0\n\nThe core of the PyTorch implementation relies on the `torch.nn.Conv1d` module.\n\n## License\n\nMIT License\n\nCopyright (c) 2018 Tom Runia (tomrunia@gmail.com)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomrunia%2Fpytorchwavelets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomrunia%2Fpytorchwavelets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomrunia%2Fpytorchwavelets/lists"}