Book Image

Hands-On Image Generation with TensorFlow

By : Soon Yau Cheong
Book Image

Hands-On Image Generation with TensorFlow

By: Soon Yau Cheong

Overview of this book

The emerging field of Generative Adversarial Networks (GANs) has made it possible to generate indistinguishable images from existing datasets. With this hands-on book, you’ll not only develop image generation skills but also gain a solid understanding of the underlying principles. Starting with an introduction to the fundamentals of image generation using TensorFlow, this book covers Variational Autoencoders (VAEs) and GANs. You’ll discover how to build models for different applications as you get to grips with performing face swaps using deepfakes, neural style transfer, image-to-image translation, turning simple images into photorealistic images, and much more. You’ll also understand how and why to construct state-of-the-art deep neural networks using advanced techniques such as spectral normalization and self-attention layer before working with advanced models for face generation and editing. You'll also be introduced to photo restoration, text-to-image synthesis, video retargeting, and neural rendering. Throughout the book, you’ll learn to implement models from scratch in TensorFlow 2.x, including PixelCNN, VAE, DCGAN, WGAN, pix2pix, CycleGAN, StyleGAN, GauGAN, and BigGAN. By the end of this book, you'll be well versed in TensorFlow and be able to implement image generative technologies confidently.
Table of Contents (15 chapters)
Section 1: Fundamentals of Image Generation with TensorFlow
Section 2: Applications of Deep Generative Models
Section 3: Advanced Deep Generative Techniques

Improving DeepFakes with GANs

The output image of deepfake's autoencoders can be a little blurry, so how can we improve that? To recap, the deepfake algorithm can be broken into two main techniques – face image processing and face generation. The latter can be thought of as an image-to-image translation problem, and we learned a lot about that in Chapter 4, Image-to-Image Translation. Therefore, the natural thing to do would be to use a GAN to improve the quality. One helpful model is faceswap-GAN, and we will now go over a high-level overview of it. The autoencoder from the original deepfake is enhanced with residual blocks and self-attention blocks (see Chapter 8, Self-Attention for Image Generation) and used as a generator in faceswap-GAN. The discriminator architecture is as follows:

Figure 9.10 - faceswap-GAN’s discriminator architecture (Redrawn from:

Figure 9.10 - faceswap-GAN's discriminator architecture (Redrawn from:

We can learn a lot about the discriminator...