Skip to content
/ TFDWT Public

Fast Discrete Wavelet Transform TensorFlow Layers

License

Notifications You must be signed in to change notification settings

kkt-ee/TFDWT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TFDWT: Fast Discrete Wavelet Transform TensorFlow Layers

PyPI Version PyPI Version TensorFlow Version Keras Version CUDA Version NumPy Version MIT

Fast $1\text{D}$, $2\text{D}$ and $3\text{D}$ Discrete Wavelet Transform ($\text{DWT}$) and Inverse Discrete Wavelet Transform ($\text{IDWT}$) layers for backpropagation networks.

Available wavelet families ―

        Haar (haar)
        Daubechies (db)
        Symlets (sym)
        Coiflets (coif)
        Biorthogonal (bior)
        Reverse biorthogonal (rbio)

Note ― The permissible input shapes are $2^m$, where $m$ is a Natural number. Additionally, for 2D and 3D transforms, the shape of the input must be square and cube, i.e., equal sides.





Installation guide

The installation of the TFDWT package is recommended inside a virtual environment with tensorflow[and-cuda] installed at first.


Pre-installation checks (Tested in Gentoo and Debian bookworm)

  • Create a new virtual enironment with a specific Python version (use the Python version supported by TensorFlow)
conda info --envs
env_name='tf219'
conda create -n $env_name python=3.12 ipykernel

# activate virtual environment
conda activate tf219
# For GPU users
pip install tensorflow[and-cuda]
# Verify setup
python3 -c "import tensorflow as tf; print(f'{tf.config.list_physical_devices('GPU')}, \nTF version {tf.__version__}')"



Install TFDWT from PyPI (Option $1$)

pip install TFDWT



Install TFDWT from Github (Option $2$)

Download the package

git clone https://github.com/kkt-ee/TFDWT.git

Change directory to the downloaded TFDWT 

cd TFDWT

Run the following command to install the TFDWT package

pip install .





Verify installation

Compute $\text{DWT}$ $1\text{D}$ and $\text{IDWT}$ $1\text{D}$ of batched, multichannel $x$ of shape $(\text{batch, length, channels})$

"""Perfect Reconstruction 1D DWT level-1 Filter bank"""
from TFDWT.DWTIDWT1Dv1 import DWT1D, IDWT1D

LH = DWT1D(wave='bior3.1')(x)       # Analysis
x_hat = IDWT1D(wave='bior3.1')(LH)  # Synthesis



Compute $\text{DWT}$ $2\text{D}$ and $\text{IDWT}$ $2\text{D}$ of batched, multichannel $x$ of shape $(\text{batch, height, width, channels})$

"""Perfect Reconstruction 2D DWT level-1 Filter bank"""
from TFDWT.DWTIDWT2Dv1 import DWT2D, IDWT2D

LLLHHLHH = DWT2D(wave=wave)(x)      # Analysis
x_hat = IDWT2D(wave=wave)(LLLHHLHH) # Synthesis



Compute $\text{DWT}$ $3\text{D}$ and $\text{IDWT}$ $3\text{D}$ of batched, multichannel $x$ of shape $(\text{batch, height, width, depth, channels})$

"""Perfect Reconstruction 3D DWT level-1 Filter bank"""
from TFDWT.DWTIDWT3Dv1 import DWT3D, IDWT3D

LLLLLHLHLLHHHLLHLHHHLHHH = DWT3D(wave=wave)(x)      # Analysis
x_hat = IDWT3D(wave=wave)(LLLLLHLHLLHHHLLHLHHHLHHH) # Synthesis




NOTE ― Using the above forward and inverse transforms the above $\text{DWT}$ and $\text{IDWT}$ layers can be used to construct multilevel $\text{DWT}$ filter banks and $\text{Wave Packet Transform}$ filter banks.





Package is tested with dependency versions

        Python 3.12.7
        TensorFlow 2.15 to 2.19
        Keras 2 and 3
        Numpy 2.0.2
        CUDA 12.5.1





Uninstall TFDWT

pip uninstall TFDWT







TFDWT (C) 2025 Kishore Kumar Tarafdar, Prime Minister's Research Fellow, EE, IIT Bombay, भारत 🇮🇳

About

Fast Discrete Wavelet Transform TensorFlow Layers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published