How Dangerous Are Deepfakes?
By: Katie Escoto
Tags: Politics, Technology News, Social Media, Deepfake Technology, Policy

On September 26, 1960, almost 60 years to the day before the carnival sideshow that was last Tuesday’s presidential debate, John F. Kennedy went head-to-head with Richard Nixon in the nation’s first televised presidential debate. As the story goes, Americans who tuned into the debate over the radio believed Richard Nixon had won, though anyone who watched the televised broadcast believed the opposite. Overnight, John F. Kennedy became a political icon and over time, it became clear that television had forever transformed election cycles, and the world at large.

Video has become integral in aspects across the spectrum of society. It’s hard to imagine the criminal justice system before video was ubiquitous. Controversial video clips have ended political careers. Even the idea that we can tune into our government’s proceedings by livestream is simultaneously mind-blowing and something often taken for granted.

Of course, between its advent and somewhat recently, we’ve accustomed ourselves to the idea that what we can clearly see in a video is (at least somewhat) reliably true, or at the very least that it’s possible to detect when a video is manipulated. If you’re familiar with the concept of a deepfake, though, you know that videos now require a new level of scrutiny.

The term “deepfake” is a portmanteau (side note: love me a portmanteau) of “deep learning” and “fake”. A deepfake is a video that has been manipulated using machine learning and deep neural networks, and is difficult to distinguish from legitimate media. Deepfakes first emerged in 2017, and Forbes estimates that 60% of deepfakes now target politics, and that views of them have increased by 2000% since late last year.

One striking aspect of deepfake technology is how quickly it’s advanced since it was first introduced. There are plenty of tutorials out there that have very rudimentary Readme and Install documentation and require lots of debugging and a not-insignificant amount of savvy. I played around with this python-based tutorial for a full day and did not get it up and running, though the process is broken up into four steps: gather, extract, train, and convert.

First paragraph of the FaceSwap Readme

Below, I am describing the steps as run in the command line, though there is also a GUI if that’s easier.

Gather

This particular repo’s default is converting images of Donald Trump to images of Nicolas Cage (I can’t speak to the particulars of this decision, but you can read about it here). Whoever the two people are, the point of this step is to find images and videos of each one and save them to corresponding source directories. One of FaceSwap’s features is its ability to extract faces from video frames with the built-in effmpeg command, so a lot of the gathering work is automated. Users are also given the option of using the standalone tool ffmpeg.

python tools.py effmpeg -h

Extract

Once FaceSwap has enough source material, users can run the extract command, as below.

# To extract trump from photos in a folder:

python faceswap.py extract -i ~/faceswap/src/trump -o ~/faceswap/faces/trump # To extract trump from a video file:

python faceswap.py extract -i ~/faceswap/src/trump.mp4 -o ~/faceswap/faces/trump # To extract cage from photos in a folder:

python faceswap.py extract -i ~/faceswap/src/cage -o ~/faceswap/faces/cage # To extract cage from a video file:

python faceswap.py extract -i ~/faceswap/src/cage.mp4 -o ~/faceswap/faces/cage

There are several tips and tricks for the extraction process, but ultimately FaceSwap requires 500–5000 images to be able to train the model sufficiently. The input of these commands is the source directory of faces

~/faceswap/src/cage.mp4

The user must also specify the output directory, where the extraction results are saved along with an alignments.json file.

~/faceswap/faces/cage

Train

Now that faces have been extracted, the model can begin training on them. The process of training is best undertaken with powerful computing resources. If a Graphics Processing Unit (GPU) is used, the documentation suggests that this process can take 12–48 hours. If a regular CPU is used instead, it can take several weeks.

python faceswap.py train -A ~/faceswap/faces/trump -B ~/faceswap/faces/cage -m ~/faceswap/trump_cage_model/ # or -p to show a preview python faceswap.py train -A ~/faceswap/faces/trump -B ~/faceswap/faces/cage -m ~/faceswap/trump_cage_model/ -p

Finally, once the model has been trained there’s yet another process of generating an alignments.json file and then converting the video.

Yikes! This seems complex and frankly, like a lot of work.