Realtime Deepfake Video AI

How to use DeepLiveCam to create deepfake face-swap images, videos, and streams

In this post, I walk through setting up Deep Live Cam to create deepfake AI images, videos, and real-time streams. At the end, I discuss the latest research and developments to combat deepfakes.

Hereā€™s the Youtube version of this post:

Table of Contents

What are ā€œDeepfakesā€?

Think of a deepfake like a super advanced Snapchat face-swap filter šŸ˜… 

AI manipulates existing media to create new, fake content that looks shockingly real.

Deepfakes make it look (or sound) like someone is saying or doing something they never actually did!

For example, a deepfake might show a famous person giving a speech they never made, saying things they never said, or visiting places theyā€™ve never been.

Images, audio, and video can all be manipulated into a deepfake.

Although deepfakes can be used in movies and games to create cool special effects, theyā€™re also nefariously used to spread misinformation and scam people šŸ˜± 

Scammer alert!

Deep Live Cam

Deep Live Cam is an open-source project that generate real-time deepfakes for live video streams. It can also swap faces in an image or video.

Hereā€™s their disclaimer:

This software is intended as a productive contribution to the AI-generated media industry. It aims to assist artists with tasks like animating custom characters or using them as models for clothing, etc.

We are aware of the potential for unethical applications and are committed to preventative measures. A built-in check prevents the program from processing inappropriate media (nudity, graphic content, sensitive material like war footage, etc.). We will continue to develop this project responsibly, adhering to law and ethics. We may shut down the project or add watermarks if legally required.

Installation

Step 1: Download Deep Live Cam

  1. Go to https://github.com/hacksider/Deep-Live-Cam

  2. Choose between an easy install ($12 one time) or a manual install (free) if you have technical experience. You must use Windows to choose the easy installation option:

  1. For this tutorial, weā€™re going to follow the easy install process. Click the large pink button ā€œDownloadā€.

  2. Youā€™ll be redirected to the projectā€™s Gumroad page, which looks like the image. Hit the pink ā€œSubscribeā€ button. After you subscribe, I recommend CANCELLING your subscription immediately so you donā€™t forget. You do NOT need a monthly subscription to keep using it. When you pay $12 once, you can continue using your downloaded model indefinitely.

  1. Download both files (~3GB each). The first link (1.4) is the stable version, while the second link (1.5) is the experimental version. I recommend downloading both so you always have them. But you only need to install one of them.

  1. Extract ONE of the download files to your preferred folder. I created a new folder ā€œDeepLiveCamā€ in my Documents folder.

Step 2: Install Cuda Toolkit 11.8

  1. Go to https://developer.nvidia.com/cuda-11-8-0-download-archive to install CUDA Toolkit 11.8 from NVIDIA

  2. Select your operating system and download the local executable. Windows operating system is required for the easy installation path. So, click on Windows > x86_64 > 11 > exe(local) > Download

  3. The download will start and will take awhile (~3GB).

  4. When itā€™s done downloading, double click on the exe file and follow the on-screen installation prompts.

Usage

Launch

Now, weā€™re ready to start playing around with Deep Live Cam! šŸ˜Ž 

  1. Navigate to your Deep Live Cam folder.

  2. Double click on the file start_portable_nvidia.bat

  3. A terminal window will pop up, and then youā€™ll see the Deep Live Cam app.

Real-Time Face Swap

First, letā€™s try the real-time face swap.

Find a high-quality photo of a person you want to swap your face with.

Make sure your computer has a working camera or webcam.

  1. Click ā€œSelect a faceā€

  2. Upload a high quality image of the source face (e.g. Kylie Jenner)

  3. At the bottom, click "Live" to start the real-time face swap.

  4. Wait a few moments, then you should see the Preview box

Hereā€™s Kylie Jennerā€™s face mapped onto my face in real-time:

Super frickinā€™ impressive! šŸ¤“ 

Face Enhancer

DeepLiveCam also offers the option to enhance the quality of the face-swap even further.

Simply enable the setting toggle "Face Enhancer" in the Deep Live Cam app:

Much higher quality!

But the downside ā€” itā€™s very laggy!

Resize Output Window

Your default easy install of Deep Live Cam wonā€™t have this feature enabled ā€” the ability to resize the Preview output window.

To enable it:

  1. Open the folder containing your Deep Live Cam installation.

  2. Right-click on start_portable_nvidia.bat and click Edit in Notepad. Alternatively, if you already use an IDE, open it with that.

  3. Add the parameter: --live-resizable at the end like this:

  1. Save the file.

  2. Click on start_portable_nvidia.bat to launch Deep Live Cam again.

Now, you should be able to resize the Preview output window!

Check the Deep Live Cam repo to see other parameters you can play around with:

Swap Multiple Faces in Images

In addition to real-time face-swap deepfakes, Deep Live Cam also supports swapping faces in images and videos.

To swap a face in an image:

  1. Upload a source photo (e.g. Kylie Jenner)

  2. Upload a target photo (e.g. Wednesday Addams)

  3. Click ā€œStartā€ button

  4. Youā€™ll see a popup asking where you want to save the file

  5. It takes a few moments, then youā€™ll see the file on your computer (most likely called output unless you changed the name).

I highly recommend enabling ā€œFace Enhancerā€ like we did before.

Just hit the toggle button.

The result is a much clearer, more crisp deepfake image:

Use Deep Live Cam in Video Calls

Hereā€™s how to prank your coworkers with your newfound AI deepfake skills, without having to setup actual livestream software (e.g. OBS).

  1. Start a conference meeting (Google Hangout, Teams, Zoom, Webex, etc.)

  2. Disable your camera in the meeting

  3. Start Deep Live Cam and setup a real-time face swap like we did earlier

  4. Share your screen > Window > Preview (it can glitch in and out)

And now as your coworkers join the call, theyā€™ll see your deepfake faceswap!

Bonus points if you end up doing this ā€” and please send me a screenshot!

Security Concerns

Deepfake AI obviously raises many serious security, social, and ethical concerns.

In one highly publicized case, a bank manager was scammed by a voice deepfake into transferring $35 million.

Yep, you read that right!

35 MILLION US DOLLARS šŸ’ø 

The scam involved a bank manager from the United Arab Emirates who had a phone call conversation with a person he knew ā€“ a manager at a company heā€™d spoken with before. The company manager needed help from the bank with some transfers, precisely $35 million, and mentioned his lawyer would handle all the procedures. As the bank manager received emails from the lawyer, he didnā€™t suspect anything fishy, so he made the transfers.

Weā€™re also seeing:

It is cheaper, easier, and faster than ever before to produce mass amounts of misinformation and deepfake media šŸšØ 

Combatting Deepfakes

Thankfully, there are many promising efforts underway to combat AI deepfakes.

There are 2 main categories:

  • Detection

  • Authentication

Detection uses AI to identify deepfakes, especially looking for:

  • Facial or vocal inconsistencies

  • Traces of deepfake processes

  • Color abnormalities

Authentication tools are incorporated when a piece of media is created, and these tools include:

  • Digital watermarks: Small pixel or audio patterns, invisible to humans, that prove originality

  • Metadata: cryptographically secure metadata describing the media

  • Blockchain: publicly verifiable records of the original media and metadata

These approaches will help ensure the trustworthiness of a piece of media.

I remain cautiously optimistic.

Has my free AI education helped you?

It would mean the world to meā€¦

If you are willing to share your story and inspire others too! šŸ˜šŸ™ šŸ˜Š