This project aims to achieve superresolution using machine learning models. Superresolution is a technique to enhance image resolution by combining information from multiple images of the same scene. In this project, we use RGB images with high spatial resolution and hyperspectral images with high spectral resolution to create images with both high spatial and spectral resolution.
The dataset used in this project is the CAVE multispectral image dataset by Columbia University. The dataset can be downloaded from this link.
data_utils.py
: Functions related to data downloading, loading, and preprocessing.model_utils.py
: Functions related to model creation and training.plot_utils.py
: Functions related to plotting and visualizations.main.py
: The main script that orchestrates the workflow.
-
Clone the repository:
git clone https://github.com/itsitgroup/HyperResNet.git cd HyperResNet
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required dependencies:
pip install -r requirements.txt
You can customize the training process by using the following command-line arguments:
--model_path
: Path to save or load the model (default:my_model.h5
).--batch_size
: Batch size for training (default:32
).--epochs
: Number of epochs for training (default:10
).--learning_rate
: Learning rate for the optimizer (default:0.0001
).--filters
: Number of filters for the convolutional layers (default:64
).--blocks
: Number of residual blocks in the encoder and decoder (default:3
).--save_every
: Save the model every specified number of epochs. If0
, save only at the end (default:0
).
-
Run the script with default values:
python main.py --model_path my_model.h5
-
Specify custom hyperparameters and save the model every 5 epochs:
python main.py --model_path my_model.h5 --batch_size 64 --epochs 20 --learning_rate 0.001 --filters 128 --blocks 4 --save_every 5
download_and_extract_data(url, dest_folder, zip_name='complete_ms_data.zip')
: Downloads and extracts the dataset.load_and_preprocess_images(root_folder, target_size)
: Loads and preprocesses images.generate_low_res_hsi_and_high_res_rgb(cropped_images)
: Generates low-resolution HSI and high-resolution RGB images.normalize_data(...)
: Normalizes the data.
create_model()
: Creates the superresolution model using residual and attention blocks.
plot_history(history)
: Plots training and validation loss.plot_predictions(predictions, y_test)
: Plots ground truth and predicted images.
The model will output high-resolution hyperspectral images. Training and validation loss, as well as accuracy, will be plotted. Predictions will be compared to the ground truth images.
numpy
opencv-python
keras
tensorflow
matplotlib
Your project directory should look like this:
superresolution-ml/
│
├── data_utils.py
├── model_utils.py
├── plot_utils.py
├── main.py
├── README.md
└── requirements.txt