Skip to content

AndreRab/Photo-colorizing-GAN

Repository files navigation

Photo-colorizing-GAN

Java Spring Python Flask PyTorch Torchvision Issues

Photo-colorizing GAN is a deep learning model designed to add color to black-and-white photos, providing a vivid and realistic resul

Description

This is my first project involving machine learning, where I decided to train a GAN for photo colorization. The model architecture and the datasets used for training can be found in the Model Specification section. To enhance the user experience, I’ve integrated some front-end features as well.

The application is divided into two main components:

  1. A Java Spring server, which handles the core of the web page.
  2. A Python Flask application, responsible for processing images through the GAN.

Feel free to try it out and add vibrant colors to your old black-and-white photos!

Table of Contents

Section Description
Installation using Gradle Instructions for installing the project using Gradle
Installation using Docker Instructions for installing the project using Docker
Training Datasets Information about the datasets used for training the GAN model
Model Specification A detailed breakdown of the model's architecture and training process
Examples of Colorizing Sample images demonstrating the results of colorizing black-and-white photos

Installation using Gradle

First of all install docker (https://www.docker.com/) and gradle (https://gradle.org/) on your machine. Then run your docker-engine.

  1. Clone the Repository: Open a terminal and clone the repository:

    git clone https://github.com/AndreRab/Photo-colorizing-GAN.git

    Don't forget to clone the model with the help of Git LFS

  2. Navigate to the Project Directory: Change your directory to the project folder:

    cd Photo-colorizing-GAN
  3. Build the Project: Use Docker-compose to build the project:

    docker-compose up --build -d
  4. Access the Application: Open your web browser and navigate to http://localhost:8082 to access the application.

Installation using Docker

First of all install docker (https://www.docker.com/) and gradle (https://gradle.org/) on your machine. Then run your docker-engine.

  1. Clone the Repository: Open a terminal and clone the repository:

    git clone https://github.com/AndreRab/Photo-colorizing-GAN.git

    Don't forget to clone the model with the help of Git LFS

  2. Navigate to the Project Directory: Change your directory to the project folder:

    cd Photo-colorizing-GAN
  3. Build the Project: Use Gradle to build the project:

    ./gradlew deploy
  4. Access the Application: Open your web browser and navigate to http://localhost:8082 to access the application.

Training Datasets

For training datasets, I used the following sources: Image Colorization Dataset and ImageNet Mini. I converted all images to grayscale mode and used them as input for my model, while the original images served as the expected output.

Model Specification

Like all GANs, my GAN consists of a generator and a discriminator. You can see the architecture of my generator in the picture. Basically, I used a CNN with skip connections because I think that the best idea for colorizing a picture is to reference the original image and its features. photo_2024-09-25_14-57-39

At the beginning of my training, the discriminator was really good while the generator wasn’t. That's why I trained the discriminator only for every 10 batches. When the results of my CNN started to be as good as the original pictures, my discriminator couldn't recognize which images were real and which were colorized, so I decided to focus on training only my generator.

This GAN resizes every image to 128x128 pixels, which is why it can colorize pretty good pictures at that size. However, if you provide a larger picture, the results may not be very good.

Examples of Colorizing

Here are examples of colorizing for the pictures that my model did not see during training. image image image image image image image image image

About

Web application for photo colorizing

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published