Sure, let’s follow these steps:
Face swaps are bizarrely funny, weirdly fascinating, and even a bit creepy, but they're incredibly popular on the web. So, how do face swaps actually work?
Hi, I'm Alvin, a computer science PhD student and lecturer at UC Berkeley. In this article, I'll explain how face swaps work, starting with the basic version and then adding advanced features to make professional, meme-worthy face swaps.
Step 1: Detect Faces
First, detect all the faces in the image and draw boxes around each face.
Step 2: Switch Boxes
Next, switch the contents of these boxes between faces. However, the boxes may not match in size, so you'll need to resize both boxes to match the original sizes. And there you have it—a basic face swap.
To upgrade our basic face swap, we'll add three advanced techniques:
Key points relate to notable parts of the face, such as the nose bridge, eyebrow area, and dimples.
Edges can be visible after a face swap. To address this, we smooth the colors at these edges using a technique called Gradient Domain Fusion.
Consider a small 5x5 pixel image:
Sometimes, the swapped face stands out because its color doesn't match the rest of the image. To fix this, we match the average color intensities.
And that's it! This three-step process—detecting key points, warping and smoothing edges, and matching color averages—produces the face swaps you've seen all over the internet.
Here are some examples:
To learn more and build your own face-swapping tool, check out my computer vision course on Skillshare (link in the description).
Thanks for reading!
Q: What is the first step in performing a basic face swap? A: The first step is to detect faces and draw boxes around each face.
Q: How do you handle different-sized face boxes in a basic face swap? A: Resize both boxes to match the original sizes before swapping the contents.
Q: What are key points in the context of face swaps? A: Key points correspond to meaningful parts of the face like the nose bridge, area above the eyebrow, and dimples.
Q: How does warping work in an advanced face swap? A: Warping the face involves using triangles formed by key points and mapping these triangles from one face to another.
Q: What technique is used to smooth the edges in face swaps? A: Gradient Domain Fusion is used to smooth the colors along the edges.
Q: How do you match the color of the swapped face with the rest of the image? A: By adjusting the new face’s color values to match the average intensity of the original face.
Q: Where can I learn more about building a face-swapping tool? A: You can learn more from the computer vision course on Skillshare linked in the description of the article.
This concludes the three steps.
In addition to the incredible tools mentioned above, for those looking to elevate their video creation process even further, Topview.ai stands out as a revolutionary online AI video editor.
TopView.ai provides two powerful tools to help you make ads video in one click.
Materials to Video: you can upload your raw footage or pictures, TopView.ai will edit video based on media you uploaded for you.
Link to Video: you can paste an E-Commerce product link, TopView.ai will generate a video for you.