Getting hands-on with the convert code
Like the rest of the chapters in this section, we’ll be going through the code line by line to talk about how it works and what it’s doing.
Initialization
Here we will initialize and prepare the code to run the convert process:
- Like all Python code, we’ll start with the imports:
import os from argparse import ArgumentParser import json_tricks import torch import cv2 import numpy as np from tqdm import tqdm import face_alignment from face_alignment.detection.sfd import FaceDetector from face_alignment import FaceAlignment, LandmarksType from lib.bisenet import BiSeNet from lib.models import OriginalEncoder, OriginalDecoder
These libraries are all ones we’ve already seen in previous chapters. This is because the conversion process is not really doing anything too different from what we’ve done before. We’ll see that as we go through the code to covert the face back into the original images...