Reader small image

You're reading from  Generative Adversarial Networks Projects

Product typeBook
Published inJan 2019
Reading LevelIntermediate
PublisherPackt
ISBN-139781789136678
Edition1st Edition
Languages
Right arrow
Author (1)
Kailash Ahirwar
Kailash Ahirwar
author image
Kailash Ahirwar

Kailash Ahirwar is a machine learning and deep learning enthusiast. He has worked in many areas of Artificial Intelligence (AI), ranging from natural language processing and computer vision to generative modeling using GANs. He is a co-founder and CTO of Mate Labs. He uses GANs to build different models, such as turning paintings into photos and controlling deep image synthesis with texture patches. He is super optimistic about AGI and believes that AI is going to be the workhorse of human evolution.
Read more about Kailash Ahirwar

Right arrow

Preface

Generative Adversarial Networks (GANs) have the potential to build next-generation models, as they can mimic any distribution of data. Major research and development work is being undertaken in this field because it is one of the most rapidly growing areas of machine learning (ML). This book will test unsupervised techniques of training neural networks as you build eight end-to-end projects in the GAN domain.

Generative Adversarial Network Projects begins by covering the concepts, tools, and libraries that you will use to build efficient projects. You will also use a variety of datasets in the different projects in the book. With every chapter, the level of complexity and operations advances, helping you get to grips with the GAN domain.

You will cover popular approaches such as 3D-GAN, DCGAN, StackGAN, and CycleGAN, and you'll understand the architecture and functioning of generative models through their practical implementation.

By the end of this book, you will be ready to build, train, and optimize your own end-to-end GAN models at work or in your projects.

Who this book is for

If you're a data scientist, ML developer, deep learning practitioner, or AI enthusiast looking for a project guide to test your knowledge and expertise in building real-world GANs models, this book is for you.

What this book covers

Chapter 1, Introduction to Generative Adversarial Networks, starts with the concepts of GANs. Readers will learn what a discriminator is, what a generator is, and what Game Theory is. The next few topics will cover the architecture of a generator, the architecture of a discriminator, objective functions for generators and discriminators, training algorithms for GANs, Kullback–Leibler and Jensen–Shannon Divergence, evaluation matrices for GANs, different problems with GANs, the problems of vanishing and exploding gradients, Nash equilibrium, batch normalization, and regularization in GANs.

Chapter 2, 3D-GAN – Generating Shapes Using GANs, starts with a short introduction to 3D-GANs and various architectural details. In this chapter, we will train a 3D-GAN to generate real-world 3D shapes. We write code for collecting a 3D Shapenet dataset, cleaning it, and making it training ready. Then, we will write code for a 3D-GAN with the Keras deep learning library.

Chapter 3, Face Aging Using Conditional GAN, introduces Conditional Generative Adversarial Networks (cGANs) and Age-cGAN to the readers. We will learn different steps in data preparation, such as downloading, cleaning, and formatting data. We will be using the IMDb Wiki Images dataset. We will write code for an Age-cGAN using the Keras framework. Next, we will train the network on the IMDb Wiki Images dataset. Finally, we will generate images using our trained model with age as our conditional argument, and our trained model will generate images for a person's face at different ages.

Chapter 4, Generating Anime Characters Using DCGANs, starts with an introduction to DCGANs. We will learn different steps in data preparation, such as gathering the anime characters dataset, cleaning the dataset, and preparing it for training. We will cover the Keras implementation of a DCGAN inside a Jupyter Notebook. Next, we will learn different ways to train the DCGAN and choose different hyper-parameters for it. Finally, we will generate anime characters using our trained model. Also, we will discuss practical applications of DCGANs.

Chapter 5, Using SRGANs to Generate Photo-Realistic Images, explains how to train an SRGAN to generate photo-realistic images. The first step in the training process is to gather the dataset, followed by cleaning it and formatting it for training. Readers will learn where to gather the dataset from, how to clean it, and how to get it into a format that is ready for training.

Chapter 6, StackGAN – Text to Photo-Realistic Image Synthesis, this chapter will start with an introduction to StackGAN. Data collection and data preparation are important steps, and we will learn the process of gathering the dataset, cleaning the dataset, and formatting it ready for training. We will write the code for a StackGAN in Keras inside a Jupyter Notebook. Next, we will train the network on the CUB dataset. Finally, after we finish training the model, we will generate photo-realistic images from the text descriptions. We will discuss different industry applications of StackGANs and how to deploy them in production.

Chapter 7, CycleGAN – Turn Paintings into Photos, explains how to train a CycleGAN to turn paintings into photos. We will start with an introduction to CycleGANs and look at their different applications. We will cover different data gathering, data cleaning, and data formatting techniques. Next, we will write the Keras implementation of the CycleGAN and get a detailed explanation of the code in Jupyter Notebook. We will train the CycleGAN on the dataset that we have prepared. We will test our trained model to turn paintings into photos. Finally, we look at practical applications of CycleGANs.

Chapter 8, Conditional GAN – Image-to-Image Translation Using Conditional Adversarial Networks, covers how to train a conditional GAN for image-to-image translation. We will start with an introduction to conditional GANs and different data preparation techniques, such as data gathering, data cleaning, and data formatting. Next, we will write the code for the conditional GAN in Keras inside Jupyter Notebook. Next, we learn how to train the conditional GAN on the dataset that we have prepared. We will explore different hyper-parameters for training. Finally, we will test the conditional GAN and will discuss different use cases of image-to-image translation in real-world applications.

Chapter 9, Predicting the Future of GANs, is the final chapter. After covering the fundamentals of GANs and going through six projects, this chapter will give readers a glimpse into the future of GANs. Here, we will look at how, in the last 3-4 years, the adoption of GANs has been phenomenal and how well the industry has accepted it. I will also discuss my personal views on the future of GANs.

To get the most out of this book

Familiarity with deep learning and Keras and some prior knowledge TensorFlow is required. Experience of coding in Python 3 will be useful.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Generative-Adversarial-Networks-Projects. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Use the loadmat() function from scipy to retrieve the voxels."

A block of code is set as follows:

import scipy.io as io
voxels = io.loadmat("path to .mat file")['instance']

Any command-line input or output is written as follows:

pip install -r requirements.txt

Bold: Indicates a new term, an important word, or words that you see onscreen.

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Generative Adversarial Networks Projects
Published in: Jan 2019Publisher: PacktISBN-13: 9781789136678
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Kailash Ahirwar

Kailash Ahirwar is a machine learning and deep learning enthusiast. He has worked in many areas of Artificial Intelligence (AI), ranging from natural language processing and computer vision to generative modeling using GANs. He is a co-founder and CTO of Mate Labs. He uses GANs to build different models, such as turning paintings into photos and controlling deep image synthesis with texture patches. He is super optimistic about AGI and believes that AI is going to be the workhorse of human evolution.
Read more about Kailash Ahirwar