{"id":27317,"library":"pytorch-wavelets","title":"PyTorch Wavelets (DTCWT)","description":"A port of the Dual-Tree Complex Wavelet Transform (DTCWT) toolbox to run on PyTorch, enabling wavelet-based image processing, denoising, and feature extraction with GPU support. Current version 1.3.0 (released 2021), with no recent releases since June 2021.","status":"maintenance","version":"1.3.0","language":"python","source_language":"en","source_url":"https://github.com/fbcotter/pytorch_wavelets","tags":["wavelets","dwt","dtcwt","pytorch","image-processing","signal-processing"],"install":[{"cmd":"pip install pytorch-wavelets","lang":"bash","label":"Standard pip install"}],"dependencies":[{"reason":"Core dependency; package wraps PyTorch tensors and functions","package":"torch","optional":false},{"reason":"Used for array conversions and scipy integration","package":"numpy","optional":false}],"imports":[{"note":"DWTForward is exported at the package level","wrong":"from pytorch_wavelets.dwt import DWTForward","symbol":"DWTForward","correct":"from pytorch_wavelets import DWTForward"},{"note":"DWTInverse is also at package level","wrong":"from pytorch_wavelets.idwt import DWTInverse","symbol":"DWTInverse","correct":"from pytorch_wavelets import DWTInverse"},{"note":"DTCWT is the complex dual-tree transform; directly importable","wrong":"from pytorch_wavelets.dtcwt import DTCWTForward","symbol":"DTCWTForward","correct":"from pytorch_wavelets import DTCWTForward"}],"quickstart":{"code":"import torch\nfrom pytorch_wavelets import DWTForward, DWTInverse\n\n# Create a random image batch (B, C, H, W)\nx = torch.randn(2, 3, 64, 64)\n\n# Forward DWT with wavelet 'db1' (Haar) and 3 levels\nxfm = DWTForward(J=3, wave='db1', mode='zero')\nyl, yh = xfm(x)  # yl: lowpass, yh: list of highpass components\n\n# Inverse DWT\nifm = DWTInverse(wave='db1', mode='zero')\nrecon = ifm((yl, yh))\n\n# Check reconstruction error\nprint(torch.abs(x - recon).max().item())","lang":"python","description":"Basic DWT forward and inverse on a random image batch"},"warnings":[{"fix":"Install PyWavelets: pip install PyWavelets. Alternatively, use built-in wavelets like 'haar' (which always works).","message":"Wavelet name 'db1' may not be recognized on some installations if PyWavelets is not installed. This package uses PyWavelets for wavelet filter banks.","severity":"breaking","affected_versions":"all"},{"fix":"Install scipy: pip install scipy. The dtcwt backend uses scipy for some operations.","message":"The DTCWT functions (DTCWTForward, DTCWTInverse) require the 'dtcwt' backend (not always installed by default). Ensure you have the scipy dependency.","severity":"gotcha","affected_versions":"all"},{"fix":"Remove require_grad=True from calls; gradients are automatically handled via torch tensors.","message":"The 'require_grad' argument in DWTForward/DTCWTForward is deprecated and may be removed. Use the default behavior instead.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Access highpass bands as yh[j] for level j, where j=0 corresponds to finest scale.","message":"The output of DWTForward is a tuple (yl, yh). yh is a list of highpass subbands per level. Many users mistakenly treat yh as a single tensor.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"pip install pytorch-wavelets","cause":"Package not installed or installed under a different name.","error":"ModuleNotFoundError: No module named 'pytorch_wavelets'"},{"fix":"Ensure you use 'from pytorch_wavelets import DWTForward' and pip install --upgrade pytorch-wavelets","cause":"Incorrect import path or outdated version.","error":"AttributeError: module 'pytorch_wavelets' has no attribute 'DWTForward'"},{"fix":"Pad or resize input so that height and width are multiples of 2**J.","cause":"Input dimensions not compatible with the number of wavelet decomposition levels J.","error":"RuntimeError: Input tensor must be of shape (B, C, H, W) and H, W must be multiples of 2^J"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}