EliaFantini / Image-Reconstructor-FISTA-proximal-method-on-wavelets-transform

An Image Reconstructor that applies fast proximal gradient method (FISTA) to the wavelet transform of an image using L1 and Total Variation (TV) regularizations

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

๐Ÿ–ผ๏ธ_Image_Reconstructor GitHub commit activity GitHub last commit GitHub code size GitHub repo size GitHub follow GitHub fork GitHub watchers GitHub star

Implementation of an Image Reconstructor that applies fast proximal gradient method (FISTA) to the wavelet transform of an image using L1 and Total Variation (TV) regularizations.

For a more detailed explanation of the terms mentioned above, please read Exercise instructions.pdf.

The project was part of an assignment for the EPFL course EE-556 Mathematics of data: from theory to computation. The backbone of the code structure to run the experiments was already given by the professor and his assistants, what I had to do was to implement the core of the optimization steps, which are the ISTA and FISTA algorithms and other minor components. Hence, every code file is a combination of my personal code and the code that was given us by the professor.

The following image shows an example of the output of the code. The original image gets ruined by removing pixels randomly, then the model trained with the best lambda hyperparameter and L1 or TV regularizations tries to reconstruct the image. The plot under it shows the PSNR values (it's a denoising metric in dB, the higher the better) related to different lambda values.

Immagine 2022-08-05 155002

Author

How to install and reproduce results

Download this repository as a zip file and extract it into a folder The easiest way to run the code is to install Anaconda 3 distribution (available for Windows, macOS and Linux). To do so, follow the guidelines from the official website (select python of version 3): https://www.anaconda.com/download/

Additional package required are:

  • matplotlib
  • skimage
  • pytorch
  • pywt
  • PIL

To install them write the following command on Anaconda Prompt (anaconda3):

cd *THE_FOLDER_PATH_WHERE_YOU_DOWNLOADED_AND_EXTRACTED_THIS_REPOSITORY*

Then write for each of the mentioned packages:

conda install *PACKAGE_NAME*

Some packages might require more complex installation procedures (especially pytorch). If the above command doesn't work for a package, just google "How to install PACKAGE_NAME on YOUR_MACHINE'S_OS" and follow those guides.

Finally, run inpainting_template.py to tune the lambda hyperparameter with both ISTA and FISTA and denoise an image (by default is lauterbrunnen.jpg, to change it you have to change the image path in the code) with the best model obtained:

python inpainting_template.py

Files description

  • code/common/ : folder containing utils and other modular code to be used in the training

  • code/data/: folder containing the images to denoise

  • code/examples: folder containing code to test and visualize the wavelet transform and the TV norm

  • inpainting_template.py: main code to run the training and testing

  • Answers.pdf: pdf with the answers and plots to the assignment of the course

  • Exercise instructions.pdf: pdf with the questions of the assignment of the course

๐Ÿ›  Skills

Python, PyTorch, Matplotlib. Machine learning, proximal methods, hyperparameter tuning, denoising, wavelets transform, total variation and L1 regularization.

๐Ÿ”— Links

portfolio linkedin

About

An Image Reconstructor that applies fast proximal gradient method (FISTA) to the wavelet transform of an image using L1 and Total Variation (TV) regularizations


Languages

Language:Python 100.0%