0%

Implement various state-of-the-art architectures, such as GANs and autoencoders, for image generation using TensorFlow 2.x from scratch

Key Features

  • Understand the different architectures for image generation, including autoencoders and GANs
  • Build models that can edit an image of your face, turn photos into paintings, and generate photorealistic images
  • Discover how you can build deep neural networks with advanced TensorFlow 2.x features

Book Description

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.

What you will learn

  • Train on face datasets and use them to explore latent spaces for editing new faces
  • Get to grips with swapping faces with deepfakes
  • Perform style transfer to convert a photo into a painting
  • Build and train pix2pix, CycleGAN, and BicycleGAN for image-to-image translation
  • Use iGAN to understand manifold interpolation and GauGAN to turn simple images into photorealistic images
  • Become well versed in attention generative models such as SAGAN and BigGAN
  • Generate high-resolution photos with Progressive GAN and StyleGAN

Who this book is for

The Hands-On Image Generation with TensorFlow book is for deep learning engineers, practitioners, and researchers who have basic knowledge of convolutional neural networks and want to learn various image generation techniques using TensorFlow 2.x. You'll also find this book useful if you are an image processing professional or computer vision engineer looking to explore state-of-the-art architectures to improve and enhance images and videos. Knowledge of Python and TensorFlow will help you to get the best out of this book.

Table of Contents

  1. Hands-On Image Generation with TensorFlow
  2. Why subscribe?
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Packt is searching for authors like you
  7. Preface
    1. Who this book is for
    2. How to use this book
    3. What this book covers
    4. To get the most out of this book
    5. Download the example code files
    6. Download the color images
    7. Conventions used
    8. Get in touch
    9. Reviews
  8. Section 1: Fundamentals of Image Generation with TensorFlow
  9. Chapter 1: Getting Started with Image Generation Using TensorFlow
    1. Technical requirements
    2. Understanding probabilities
    3. Probability distribution
    4. Prediction confidence
    5. The joint probability of pixels
    6. Generating faces with a probabilistic model
    7. Mean faces
    8. Conditional probability
    9. Probabilistic generative models
    10. Parametric modeling
    11. Building a PixelCNN model from scratch
    12. Autoregressive models
    13. PixelRNN
    14. Building a PixelCNN model with TensorFlow 2
    15. Summary
  10. Chapter 2: Variational Autoencoder
    1. Technical requirements
    2. Learning latent variables with autoencoders
    3. Encoder
    4. Decoder
    5. Building an autoencoder
    6. Generating images from latent variables
    7. Variational autoencoders
    8. Gaussian distribution
    9. Sampling latent variables
    10. Loss function
    11. Generating faces with VAEs
    12. Network architecture
    13. Facial reconstruction
    14. Generating new faces
    15. Sampling trick
    16. Controlling face attributes
    17. Latent space arithmetic
    18. Finding attribute vectors
    19. Face editing
    20. Summary
  11. Chapter 3: Generative Adversarial Network
    1. Technical requirements
    2. Understanding the fundamentals of GANs
    3. The architecture of a GAN
    4. Value functions
    5. GAN training steps
    6. Building a Deep Convolutional GAN (DCGAN)
    7. Architecture guidelines
    8. Building a DCGAN for Fashion-MNIST
    9. Training our DCGAN
    10. Challenges in training GANs
    11. Uninformative loss and metrics
    12. Instability
    13. Vanishing gradient
    14. Mode collapse
    15. Building a Wasserstein GAN
    16. Understanding Wasserstein loss
    17. Implementing the 1-Lipschitz constraint
    18. Restructuring training steps
    19. Implementing gradient penalty (WGAN-GP)
    20. Tweaking WGAN-GP for CelebA
    21. Summary
  12. Section 2: Applications of Deep Generative Models
  13. Chapter 4: Image-to-Image Translation
    1. Technical requirements
    2. Conditional GANs
    3. Implementing a conditional DCGAN
    4. Variants of cGAN
    5. Image translation with pix2pix
    6. Discarding random noise
    7. U-Net as a generator
    8. Loss functions
    9. Implementing a PatchGAN discriminator
    10. Training pix2pix
    11. Unpaired image translation with CycleGAN
    12. Unpaired dataset
    13. Cycle consistency loss
    14. Building CycleGAN models
    15. Analysis of CycleGAN
    16. Diversifying translation with BicyleGAN
    17. Understanding architecture
    18. Implementing BicycleGAN
    19. Summary
  14. Chapter 5: Style Transfer
    1. Technical requirements
    2. Neural style transfer
    3. Extracting features with VGG
    4. Reconstructing content
    5. Reconstructing styles with the Gram matrix
    6. Performing neural style transfer
    7. Improving style transfer
    8. Faster style transfer with a feed-forward network
    9. A different style feature
    10. Controlling styles with a normalization layer
    11. Arbitrary style transfer in real time
    12. Implementing adaptive instance normalization
    13. Style transfer network architecture
    14. Arbitrary style transfer training
    15. Introduction to style-based GANs
    16. Multimodal Unsupervised Image-to-Image Translation (MUNIT)
    17. Summary
  15. Chapter 6: AI Painter
    1. Technical requirements
    2. Introduction to iGAN
    3. Understanding manifold
    4. Image editing
    5. Segmentation map-to-image translation with GauGAN
    6. Introduction to pix2pixHD
    7. Spatial Adaptive Normalization (SPADE)
    8. Implementing GauGAN
    9. Summary
  16. Section 3: Advanced Deep Generative Techniques
  17. Chapter 7: High Fidelity Face Generation
    1. Technical requirements
    2. ProGAN overview
    3. Pixel normalization
    4. Increasing image variation with minibatch statistics
    5. Equalized learning rate
    6. Building a ProGAN
    7. Building the generator blocks
    8. Building the discriminator blocks
    9. Progressively growing the network
    10. Loss function
    11. Growing pains
    12. Implementing StyleGAN
    13. Style-based generator
    14. Implementing the mapping network
    15. Adding noise
    16. Implementing AdaIN
    17. Building the generator block
    18. Training StyleGAN
    19. Summary
  18. Chapter 8: Self-Attention for Image Generation
    1. Technical requirements
    2. Spectral normalization
    3. Understanding spectral norm
    4. Implementing spectral normalization
    5. Self-attention modules
    6. Self-attention for computer vision
    7. Implementing a self-attention module
    8. Building a SAGAN
    9. Building a SAGAN generator
    10. Conditional batch normalization
    11. Building the discriminator
    12. Training the SAGAN
    13. Implementing BigGAN
    14. Scaling GANs
    15. Skipping latent vectors
    16. Shared class embedding
    17. Orthogonal regularization
    18. Summary
  19. Chapter 9: Video Synthesis
    1. Technical requirements
    2. Video synthesis overview
    3. Understanding face video synthesis
    4. DeepFake overview
    5. Implementing face image processing
    6. Extracting image from video
    7. Detecting and localizing a face
    8. Detecting facial landmarks
    9. Aligning a face
    10. Face warping
    11. Building a DeepFake model
    12. Building the encoder
    13. Building the decoder
    14. Training the autoencoders
    15. Swapping faces
    16. Improving DeepFakes with GANs
    17. Summary
  20. Chapter 10: Road Ahead
    1. Reviewing GANs
    2. Optimizer and activation functions
    3. Adversarial loss
    4. Auxiliary loss
    5. Normalization
    6. Regularization
    7. Putting your skills into practice
    8. Don't trust everything you read
    9. How big is your GPU?
    10. Build your model using existing models
    11. Understand the model's limitations
    12. Image processing
    13. Image inpainting
    14. Image compression
    15. Image super-resolution
    16. Text to image
    17. Video retargeting
    18. Pose transfer
    19. Motion transfer
    20. Neural rendering
    21. Summary
  21. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think
3.145.94.251