Table of contents
1.
Introduction
2.
CycleGAN
2.1.
The Architecture
2.2.
The Losses
2.3.
Uses And Advantages
3.
Frequently Asked Questions
4.
Conclusion
Last Updated: Mar 27, 2024
Easy

Introduction to CycleGAN

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

We know that as deep learning enthusiasts, we always try to improve or generate our models so as to solve real-world problems. Deep learning is an evolving concept, and there is so much to learn from it. One of the concepts that evolved from this research or learning is CycleGAN. We are already familiar with GANs. GANs are Generative Adversarial Networks.
These are the adversarial networks that are supposed to generate information such as images, music, etc. Well, this concept of GANs leads to more interesting insights to develop more similar kinds of models or concepts which perform more similar tasks. One of the concepts, CycleGANs, became very popular in this scenario. CycleGANs are the GANs that can convert the generated output back and forth to its original state. It is a kind of mapping of info from one state to another and vice versa. We will learn more about this in this article.  

CycleGAN

CycleGANs are the Generative Adversarial Networks that are used to convert or generate output from one domain to another domain. For example, converting a horse to zebra, converting one season to another, etc. CycleGANs can do these things by using cycle consistency loss so as to enable training without the need for paired images/data.
Thus, we can say that this concept - CycleGANs can convert from one domain to another domain without directly mapping one-to-one from source to target domain.
Mathematically,\
Let’s say we are converting from source domain X to target domain Y. Then, the mapping can be shown as G: X - > Y.
Here the data of G(X) is indistinguishable from Y, this can be done using adversarial loss. As we said, this is a CycleGAN concept thus, the inverse can also be possible, can be shown as 
F: Y - > X. Thus, we can conclude that F(G(X)) ≅ X.

The Architecture

The architecture of CycleGAN is simple and varies based on many values such as type of data, how accurate you are gonna translate from one domain to another, etc.
But, the overall architecture can be said as follows:

source

Here we can say that the AutoEncoder architecture involves a source domain data, a pool of convolutional networks, first a series of downsampling network layers that are used to pick only a few important features of domain X, and then upsampling layers used to encode the taken important info to convert to domain Y. This architecture is just for understanding purpose only, and this can be modified based on the use-case you are working on.

The Losses

We said, G is a  Generator used to convert from domain X to domain Y, and F is a Generator to convert from domain Y to domain X. This can be represented as

source

Here the DX  is a discriminator that gradually learns how to differentiate between X to generate image X F(Y). And similarly, DY. 
The Loss that is calculated in between the generated image X F(Y) and original image Y is called Adversarial Loss. For example, from the architecture image, the difference between the image generated on the right side and the actual/original image similar to the right side can be termed Adversarial Loss. 
This Adversarial Loss can be mathematically viewed as:

source

Here y, x is the real samples. 
Similarly, Let’s say we have a sample x of domain X. Using a CycleGAN generator, we have converted it to y of domain Y. Then again, you have used another generator to convert y of domain Y back to domain Y X as x1. Now, the Loss that can be calculated between the original sample x of domain X, and the regenerated sample of the same domain X, i.e., x1, can be termed as Cycle- Consistency Loss.
This, the Cycle-Consistency Loss can be mathematically viewed as 

source

Thus, we can conclude the overall loss can be calculated as,

source

Uses And Advantages

CycleGANs are mainly introduced to solve/clear the problem of image-image translation. As shown in the first figure. Thus, the ultimate use case of CycleGANs is image-image translation. Other applications of CycleGANs are as follows:

  • Style Transfer: This application can be seen even before the development of this concept. The main intention of this application is to transfer one artistic style to another style. This can be simply said as transferring the style of one to another.

Example:

source

Here we are going to apply/transfer a style of Monet to our input image and the output as shown above. 

  • Object Transfiguration/Season Transfer: This application can be said as for a given image, we will convert this image to another domain image. For example, if orange is given, convert it to apple. And a seasoned picture to another season picture.

Example:

 

source

  • PhotoGraph Generation/Photograph Enhancement: In this application, we will generate a photo from paintings or enhance the already existing photos by improving their ways.

For example:

 

source

Frequently Asked Questions

  1. What are CycleGANs?
    CycleGANs are the Cycle-Consistent Generative Adversarial Networks used for image-image translation problem-solving. This concept uses cycle-consistency loss so as to eliminate the use of the target domain data for training purposes.
  2. What is the difference between CycleGANs to other GANs?
    CycleGANs are one of the variants of the GANs, where CycleGANs can have more than one generator to convert from one domain to another and vice versa. This concept also uses cycle-consistency loss in addition to adversarial loss that is used by other GANs.
  3. What is a cycle-consistency loss in CycleGANs?
    Cycle-Consistency loss can be treated as loss that is calculated between an actual source image and the regenerated source image after a cycle.
  4. What is the architecture of CycleGANs?
    CycleGANs generally include at least two generators and two discriminators in their architecture. And mostly a generator contains an encoder, a transformer, and a decoder.

Conclusion

In this article, we have extensively discussed the basics of CycleGANs, how they work, what their architecture is, some of their applications of it, etc. We can explore this concept in detail in the upcoming articles. Until then, keep exploring.
Hey Ninjas! You can check out more unique courses on machine learning concepts through our official website, Coding Ninjas, and checkout Coding Ninjas Studio to learn through articles and other important stuff to your growth.
Happy Learning!

Live masterclass