{"id":20013303,"url":"https://github.com/tomrunia/pytorchsteerablepyramid","last_synced_at":"2025-05-04T21:32:03.950Z","repository":{"id":40477353,"uuid":"160357957","full_name":"tomrunia/PyTorchSteerablePyramid","owner":"tomrunia","description":"PyTorch implementation of the Complex Steerable Pyramid","archived":false,"fork":false,"pushed_at":"2022-05-05T21:24:40.000Z","size":1036,"stargazers_count":62,"open_issues_count":8,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-08T12:22:45.687Z","etag":null,"topics":["batch","computer-vision","cuda","image-processing","mkl","pyramid","pytorch"],"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-12-04T12:59:53.000Z","updated_at":"2024-03-24T01:52:53.000Z","dependencies_parsed_at":"2022-08-09T21:40:20.279Z","dependency_job_id":null,"html_url":"https://github.com/tomrunia/PyTorchSteerablePyramid","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%2FPyTorchSteerablePyramid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchSteerablePyramid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchSteerablePyramid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tomrunia%2FPyTorchSteerablePyramid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tomrunia","download_url":"https://codeload.github.com/tomrunia/PyTorchSteerablePyramid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252404305,"owners_count":21742523,"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":["batch","computer-vision","cuda","image-processing","mkl","pyramid","pytorch"],"created_at":"2024-11-13T07:36:04.282Z","updated_at":"2025-05-04T21:32:03.342Z","avatar_url":"https://github.com/tomrunia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Complex Steerable Pyramid in PyTorch\n\nThis is a PyTorch implementation of the Complex Steerable Pyramid described in [Portilla and Simoncelli (IJCV, 2000)](http://www.cns.nyu.edu/~lcv/pubs/makeAbs.php?loc=Portilla99). \n\nIt uses PyTorch's efficient spectral decomposition layers `torch.fft` and `torch.ifft`. Just like a normal convolution layer, the complex steerable pyramid expects a batch of images of shape `[N,C,H,W]` with current support only for grayscale images (`C=1`). It returns a `list` structure containing the low-pass, high-pass and intermediate levels of the pyramid for each image in the batch (as `torch.Tensor`). Computing the steerable pyramid is significantly faster on the GPU as can be observed from the runtime benchmark below. \n\n\u003ca href=\"/assets/coeff.png\"\u003e\u003cimg src=\"/assets/coeff.png\" width=\"700px\" \u003e\u003c/a\u003e\n\n## Usage\n\nIn addition to the PyTorch implementation defined in `SCFpyr_PyTorch` the original SciPy version is also included in `SCFpyr` for completeness and comparison. As the GPU implementation highly benefits from parallelization, the `cwt` and `power` methods expect signal batches of shape `[N,H,W]` containing a batch of `N` images of shape `HxW`.\n\n```python\nfrom steerable.SCFpyr_PyTorch import SCFpyr_PyTorch\nimport steerable.utils as utils\n\n# Load batch of images [N,1,H,W]\nim_batch_numpy = utils.load_image_batch(...)\nim_batch_torch = torch.from_numpy(im_batch_numpy).to(device)\n\n# Requires PyTorch with MKL when setting to 'cpu' \ndevice = torch.device('cuda:0')\n\n# Initialize Complex Steerbale Pyramid\npyr = SCFpyr_PyTorch(height=5, nbands=4, scale_factor=2, device=device)\n\n# Decompose entire batch of images \ncoeff = pyr.build(im_batch_torch)\n\n# Reconstruct batch of images again\nim_batch_reconstructed = pyr.reconstruct(coeff)\n\n# Visualization\ncoeff_single = utils.extract_from_batch(coeff, 0)\ncoeff_grid = utils.make_grid_coeff(coeff, normalize=True)\ncv2.imshow('Complex Steerable Pyramid', coeff_grid)\ncv2.waitKey(0)\n```\n\n## Benchmark\n\nPerforming parallel the CSP decomposition on the GPU using PyTorch results in a significant speed-up. Increasing the batch size will give faster runtimes. The plot below shows a comprison 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_benchmark.pdf\"\u003e\u003cimg src=\"/assets/runtime_benchmark.png\" width=\"700px\" \u003e\u003c/a\u003e\n\n## Installation\n\nClone and install:\n\n```sh\ngit clone https://github.com/tomrunia/PyTorchSteerablePyramid.git\ncd PyTorchSteerablePyramid\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.15.4)\n- Scipy (developed with 1.1.0)\n- PyTorch \u003e= 0.4.0 (developed with 1.0.0; see note below)\n\nThe steerable pyramid depends utilizes `torch.fft` and `torch.ifft` to perform operations in the spectral domain. At the moment, PyTorch only implements these operations for the GPU or with the MKL back-end on the CPU. Therefore, if you want to run the code on the CPU you might need to compile PyTorch from source with MKL enabled. Use `torch.backends.mkl.is_available()` to check if MKL is installed.\n\n## References\n\n- [J. Portilla and E.P. Simoncelli, Complex Steerable Pyramid (IJCV, 2000)](http://www.cns.nyu.edu/pub/eero/portilla99-reprint.pdf)\n- [The Steerable Pyramid](http://www.cns.nyu.edu/~eero/steerpyr/)\n- [Official implementation: matPyrTools](http://www.cns.nyu.edu/~lcv/software.php)\n- [perceptual repository by Dzung Nguyen](https://github.com/andreydung/Steerable-filter)\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.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomrunia%2Fpytorchsteerablepyramid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftomrunia%2Fpytorchsteerablepyramid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftomrunia%2Fpytorchsteerablepyramid/lists"}