Skip to content

Final project for the Computational Learning class of Univesity of Florence

License

Notifications You must be signed in to change notification settings

cMancio00/Super-Resolution

Repository files navigation

Super-Resolution

The goal of this project is to reconstruct a high-resolution image from a single low-resolution image.

We will utilize the architecture presented in the paper: Enhanced Deep Residual Networks for Single Image Super-Resolution (Lim et al. 2017).

Project structure

  • checkpoint Here you will find the state of the model.

Note

SR_c64_rb8_e50_202408051714.pth indicates that the SuperResolution model has 64 channels, 8 Residual Blocks, and has been trained for 50 epochs. This represents the state of the best model during the model selection phase. The other numbers are simply the timestamp of when the model was saved.

  • data This folder will be automatically created when you start the project. The dataset will be downloaded here.
  • dataset This package contains the module data_preparation for downloading and splitting the dataset, as well as the module super_resolution_dataset, which contains the extended Dataset class used for the model.
  • SRM This package contains the module modules, which includes the building block layers (ResidualBlocks and Upsample) for the module network, where the SuperResolutionNetwork is defined.
  • utils This package contains some useful methods for training and the model_selection method.
  • output This folder contains the output images obtained during validation and testing.
  • training_logs contains the CSV files of loss and PSNR for the training, both before and after validation of the best model.
  • notebook This notebook displays the main results of the model.
  • main This is what needs to be run to perform all the tasks, from downloading the dataset to testing the model. A seed has been set, i.e., 777, to ensure consistent results.

Run the code

Once the steps described in Installation of Requirements and Kernel is completed, you can run the code with the following command

python3 main.py

Warning

If you have an Nvidia card on Xorg and you have suspended the pc it is common that the GPU will not turn on again properly and will appear busy, so unusable for computation.

Export the notebook as pdf

jupyter nbconvert --to pdf notebook.ipynb --output "ModelDemonstration" --LatexPreprocessor.title "Super Resolution Demonstration" --LatexPreprocessor.date "September, 2024" --LatexPreprocessor.author_names "Christian Mancini"

Installation of Requirements and Kernel

In the project directory, execute the following commands:

python3 -m venv .venv

Note

The name of the virtual environment will match the name of the hidden folder, in this case, .venv.

To activate the virtual environment, run:

source .venv/bin/activate

Next, install the required packages with:

pip install --upgrade pip & pip install -r requirements.txt

Now, we need to set up the virtual environment as a Jupyter kernel:

python -Xfrozen_modules=off -m ipykernel install --user --name=super-resolution

You can now select super-resolution as your kernel.

To view the installed kernels, use:

jupyter kernelspec list

The output should resemble the following:

Available kernels:
  python3      /home/mancio/PycharmProjects/super-resolution/.venv/share/jupyter/kernels/python3
  super-resolution    /home/mancio/.local/share/jupyter/kernels/super-resolution

Tip

To remove a kernel, you can use the following command:

jupyter kernelspec uninstall super-resolution -y