Coder Social home page Coder Social logo

image-restoration's Introduction

Image Restoration

This project focuses on image restoration tasks using various models and techniques. It includes colorizing black and white images and enhancing image quality.

Prerequisites

Before running the code, ensure that you have the following libraries and modules installed:

  • OpenCV (cv2)
  • Gradio (gr)
  • Torch
  • GFPGAN (gfpgan)
  • PaddleHub (hub)
  • PIL (Python Imaging Library)
  • Pathlib
  • Datetime
  • Warnings

You can install the required libraries using the following command:

pip install opencv-python gradio torch paddlepaddle paddlehub Pillow pathlib datetime

Colorizing Images

The code provides functionality to colorize black and white or grayscale images using the DeOldify model. It employs the following steps:

  1. Load the DeOldify model using PaddleHub.
  2. Read the input image.
  3. Predict the colorized version of the image using the DeOldify model.
  4. Save the colorized image.
  5. Return the colorized image and the file path.

To colorize an image, call the colorize_image(image) function and provide the input image path.

Image Upscaling and Enhancement

The code also includes an image enhancement feature that upscales and enhances images. It utilizes the GFPGAN model for image enhancement. The steps involved are as follows:

  1. Read the input image.
  2. Check the image format and convert grayscale images to BGR format if necessary.
  3. Perform image enhancement using the GFPGAN model.
  4. Resize the enhanced image based on the provided rescaling factor.
  5. Save the output image.
  6. Return the enhanced image and the file path.

To enhance an image, call the inference(img, scale) function and provide the input image path and the rescaling factor.

User Interface

The code also provides a user interface for both colorization and enhancement tasks. It utilizes the Gradio library to create a web-based interface for easy interaction. Users can upload an image and view the colorized or enhanced output. The interface also allows downloading the output image.

To launch the interface, run the final_interface.launch(inbrowser=True) command.

Please note that the interface requires an internet connection to load the necessary models.

Enjoy image restoration with the provided code!

python <filename>.py

image-restoration's People

Contributors

ja-crispy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.