This project demonstrates how to enhance the resolution of an image using a pre-trained model from TensorFlow Hub. The code downloads a low-resolution image, processes it, and improves its quality using Super Resolution techniques.
- Downloads an image from a URL.
- Preprocesses the image to make it compatible with the Super Resolution model.
- Upscales the image using a pre-trained ESRGAN model.
- Displays the original, low-resolution, and super-resolution images.
- Calculates PSNR (Peak Signal-to-Noise Ratio) to measure the quality of the enhanced image.
- TensorFlow 2.x
- TensorFlow Hub
- NumPy
- Matplotlib
- PIL (Python Imaging Library)
- Requests (for downloading the image)
Install the necessary libraries:
pip install tensorflow tensorflow_hub numpy matplotlib pillow requests
- Clone the repository.
- Run the script to download the image and process it using Super Resolution.
- The script will display the original image, downscaled version, and the enhanced super-resolution image.
preprocess_image(image_path)
: Prepares the image for model input.save_image(image, filename)
: Saves the image tensor as a file.plot_image(image, title)
: Displays the image.downscale_image(image)
: Scales down the image to create a low-resolution version.- The model used for Super Resolution is loaded from TensorFlow Hub.
- The PSNR is calculated to evaluate the quality of the super-resolution output.
The code will print out the time taken for processing and display both low-resolution and high-resolution images.