Reader small image

You're reading from  Exploring Deepfakes

Product typeBook
Published inMar 2023
Reading LevelBeginner
PublisherPackt
ISBN-139781801810692
Edition1st Edition
Languages
Right arrow
Authors (2):
Bryan Lyon
Bryan Lyon
author image
Bryan Lyon

Bryan Lyon is a developer for Faceswap.
Read more about Bryan Lyon

Matt Tora
Matt Tora
author image
Matt Tora

Matt Tora is a developer for Faceswap.
Read more about Matt Tora

View More author details
Right arrow

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.

  1. 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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Exploring Deepfakes
Published in: Mar 2023Publisher: PacktISBN-13: 9781801810692

Authors (2)

author image
Bryan Lyon

Bryan Lyon is a developer for Faceswap.
Read more about Bryan Lyon

author image
Matt Tora

Matt Tora is a developer for Faceswap.
Read more about Matt Tora