Book Image

Generative Adversarial Networks Cookbook

By : Josh Kalin
Book Image

Generative Adversarial Networks Cookbook

By: Josh Kalin

Overview of this book

Developing Generative Adversarial Networks (GANs) is a complex task, and it is often hard to find code that is easy to understand. This book leads you through eight different examples of modern GAN implementations, including CycleGAN, simGAN, DCGAN, and 2D image to 3D model generation. Each chapter contains useful recipes to build on a common architecture in Python, TensorFlow and Keras to explore increasingly difficult GAN architectures in an easy-to-read format. The book starts by covering the different types of GAN architecture to help you understand how the model works. This book also contains intuitive recipes to help you work with use cases involving DCGAN, Pix2Pix, and so on. To understand these complex applications, you will take different real-world data sets and put them to use. By the end of this book, you will be equipped to deal with the challenges and issues that you may face while working with GAN models, thanks to easy-to-follow code solutions that you can implement right away.
Table of Contents (17 chapters)
Title Page
Copyright and Credits
About Packt
Dedication
Contributors
Preface
Dedication2
Index

Preface

Developing Generative Adversarial Networks (GANs) is a complex task, and it is often hard to find code that is easy to understand. This book leads you through eight different examples of modern GAN implementation, including CycleGAN, SimGAN, DCGAN, and imitation learning with GANs. Each chapter builds on a common architecture in Python and Keras to explore increasingly difficult GAN architectures in an easy-to-read format.

The Generative Adversarial Networks Cookbook starts by covering the different types of GAN architecture to help you understand how the model works. You will learn how to perform key tasks and operations, such as creating false and high-resolution images, text-to-image synthesis, and generating videos with this recipe-based guide. You will also work with use cases such as DCGAN and deepGAN. To become well versed in the working of complex applications, you will take different real-world datasets and put them to use.

By the end of this book, you will be equipped to deal with the challenges and issues that you may face while working with GAN models thanks to easy-to-follow code solutions that you can implement right away.

Who this book is for

This book is for data scientists, machine learning (ML) developers, and deep learning practitioners looking for a quick reference to tackle challenges and tasks in the GAN domain. Familiarity with machine learning concepts and a working knowledge of the Python programming language will help you get the most out of the book.

What this book covers

Chapter 1What is a Generative Adversarial Network?, introduces you to GAN architectures and looks at the implementation of each of them.

Chapter 2, Data First – Easy Environment and Data Preparation, lays down the groundwork for manipulating data, augmenting your data, and balancing imbalanced datasets or data with massive outliers.

Chapter 3, My First GAN in Under 100 Lines, covers how to take the theory we'll have discussed and produce a simple GAN model using Keras, TensorFlow, and Docker.

 

 

Chapter 4, Dreaming of New Outdoor Structures Using DCGAN, covers the building blocks required to build your first deep convolutional generative adversarial network (DCGAN) implementation.

Chapter 5Pix2Pix Image-to-Image Translation, covers Pix2Pix, how it works, and how it is implemented.

Chapter 6, Style Transfering Your Image Using CycleGAN, explains what CycleGAN is, and how to parse the CycleGAN datasets and implementations.

Chapter 7, Using Simulated Images To Create Photo-Realistic Eyeballs with SimGAN, demonstrates how SimGAN works, and how it is implemented.

Chapter 8, From Images to 3D Models Using GANs, talks about 3D models and techniques to implement these 3D models using images.

To get the most out of this book

A basic knowledge of Python is a prerequisite, while a familiarity with machine learning concepts will be helpful.

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-Cookbook. 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!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781789139907_ColorImages.pdf.

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: "You can run the nvidia-smi command to know which version of driver is installed on your system."

A block of code is set as follows:

docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f

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

sudo ./build.sh

Bold: Indicates a new term, an important word, or words that you see on screen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Now, click Save and let's check to make sure that we have the appropriate directory structure with our files."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it..., How it works..., There's more..., and See also).

To give clear instructions on how to complete a recipe, use these sections as follows:

Getting ready

This section tells you what to expect in the recipe and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to increase your knowledge of it.

See also

This section provides helpful links to other useful information for the recipe.

 

 

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 [email protected].

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 [email protected] 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.