Exploring the training code
Now that we have defined our models, we can go ahead with the process of training a neural network on our data. This is the part where we actually have AI learn the different faces so that it can later swap between them.
- First, we import our libraries:
from glob import glob import os import random from argparse import ArgumentParser import cv2 import numpy as np from tqdm import tqdm import torch from lib.models import OriginalEncoder, OriginalDecoder
Like all Python programs, we import our libraries. We also import our encoder and decoders from our model file. This loads the AI model code from earlier in this chapter and lets us use those to define our models in this code. Python really makes it easy to import code we’ve already written, as every Python file can be called directly or imported into another file.
Note that Python uses a strange syntax for folder paths. Python treats this syntax exactly the same as a module, so you...