Hands-on GANs in practice
Let’s examine how we can utilize a GAN to generate some synthetic images in practice. We will examine Closed-Form Factorization of Latent Semantics in GANs (https://arxiv.org/abs/2007.06600) to learn how we can simply generate synthetic images for our ML problem. The code for this example was adapted from the paper’s original GitHub (https://github.com/genforce/sefa).
We begin by importing the essential libraries as shown:
# import the required libraries import cv2 import torch import numpy as np from utils import to_tensor from utils import postprocess from utils import load_generator from models import parse_gan_type from utils import factorize_weight from matplotlib import pyplot as plt
Then, we select the parameters of the generation process such as the number of images to generate, and the noise seed. Please note that the seed
parameter will help us to get diverse images in this example:
num_samples = 1 # num of image to generate...