Skip to content

This is the implementation of conditional GAN called Pix2Pix for Image translation using Tensorflow.

Notifications You must be signed in to change notification settings

afshari-maryam/Image-Translation-Pix2Pix

Repository files navigation

Image Translation using pix2pix in Tensorflow

Translation of an input image to a target image(Style Transfer).

                       In the Name of God, the Beneficent, the Merciful

This is the implementation of image translation by conditional GAN architecture for Image translation using tensorflow of a dataset of image pairs .
It is a dataset of 1207 paired images as input and target.
An example of the input image and its target image is shown below :
image

About the pix2pix model and Image Translation:

The Pix2Pix model and image translation techniques is to enable the generation of realistic images by learning the mapping between an input image and an output image. This mapping can be used for various tasks, such as image-to-image translation or image generation.
Pix2Pix is a specific model architecture proposed in a research paper titled "Image-to-Image Translation with Conditional Adversarial Networks" by Isola et al..
It uses a conditional generative adversarial network (cGAN) to learn the mapping between input and output images.
The cGAN framework consists of two main components: a generator network that generates the output image from the input image,.
and a discriminator network that tries to distinguish between the generated output image and the real target image..
The generator and discriminator are trained together in an adversarial manner, where the generator aims to fool the discriminator and produce realistic outputs, while the discriminator tries to correctly classify the real and generated images.

For Dependencies :

Run pip install -r requirements.txt script.
Dependencies are :
tensorflow==2.12.0
matplotlib==3.7.1
ipython==7.34.0
Pydub

For training :

Run dataset.py script. to make train_dataset and test_dataset.
Run Model.py script. to make model ready and will make some images from architecture of model.
Run Loss.py script. to make model loss .
Run train.py script.
You can see the output images after 1k steps.

For making an inference (testing a single image )

Download the model from here.
Model's name is ckpt-10.
Put the model in /training_checkpoints folder.
Put the directory of your test image in Make_Inference.py
Run Make_Inference.py on a test image.
My model, designed to handle images with arbitrary size.
I have implemented a resizing mechanism that standardizes all input images to a consistent size.
IMG_WIDTH = 256
IMG_HEIGHT = 256

Prediction and Accuracy

Run Prediction.py script. to find some prediction result from test_dataset.
Run Compute_accuracy.py script. to find the accurcy Average Pixel-wise result.
Average Pixel-wise Accuracy: 0.78219396 by 50000 step.

Results

These are the result of test model using test_dataset after trainig the model. image image

Details of training procedure:

The training procedure for the generator :

image

The training procedure for the discriminator :

image

About

This is the implementation of conditional GAN called Pix2Pix for Image translation using Tensorflow.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages