Swap the Eyes

Learn how to swap the eyes between two face images.

Introduction

This lesson provides the steps needed to develop a utility that swaps specific facial components. For the sake of this lesson, we’ll emphasize the mechanism of swapping an eye between two face images.

This utility will enable you to try out different eye colors since you can swap your eye color with a different one. Afterwards, you’ll be able to see the difference between your current eye color and the new eye.

Dependencies

We’ll be using the following external Python libraries.

Library

Version

Dlib

19.17.0

opencv-python

4.4.0.46

imutils

0.5.3

filetype

1.0.7

Let’s code the utility!

Let’s take a look at the main function of this utility.

The swap_facial_component function

The core function ...