Real Face vs. AI-Generated Fake: The Science Behind GANs

How can we tell the difference between what’s real...and what’s not? Learn the science behind generative adversarial networks and find out.
Headshot of author Natassha Selvaraj
Natassha Selvaraj
Expert Contributor
November 19, 2021
Headshot of author Natassha Selvaraj
Natassha Selvaraj
Expert Contributor
November 19, 2021

We’ve seen great advancements in artificial intelligence in the past two decades. AI has applications in a wide array of industries like healthcare, fashion, education, agriculture and will no doubt continue to act as a major digital disruptor.

As Andrew Ng put it: “Just as electricity transformed almost everything 100 years ago, today I actually have a hard time thinking of an industry that I don’t think AI will transform in the next several years.”

However, bad actors can misuse AI easily. Let’s look at an application of AI that’s been used to trick people and spread misinformation: AI-generated images, some of which we call deepfakes.

What Is a Deepfake?

Deepfakes (a portmanteau of “deep learning” and “fake”) are highly convincing fake videos and images created by AI neural networks. 


Deepfakes and AI-Generated Images

In the past few years, deepfakes began taking the internet — and the real world — by storm and, in 2020, deepfakes went mainstream. We see deepfakes in ads and tv shows, but some use them to spread mis- and disinformation. While many videos are harmless, others have caused a great deal of vexation when faces of politicians are made to look like they’re saying and doing things they haven’t said or done. 

More From Built In ExpertsHow to Spot a Deepfake

While you may be familiar with deepfake videos, you may not know that deepfakes can be still images, too. AI deep learning models are indeed capable of generating fake faces that look almost identical to real people. These programs have become really strong over the years, and it’s almost impossible to distinguish between a real face and an AI-generated fake.

Can you tell which one of these faces is real and which one is AI-generated?

real face a dark-haired little girl and a dark-haired adult woman side-by-side facing the camera
Image by and Omid Armin on Unsplash

The face on the right is real. An AI application generated the photo on the left. Did you guess right?


GANs: The Technology Behind AI-Generated Images

Deepfakes can be generated by a class of machine learning models called GANs (generative adversarial networks). Researcher Ian Goodfellow and his colleagues designed GANs in 2014.

How Does a GAN Work?

Two neural networks compete against each other. The first network (the generator) generates fake images based on an existing image data set. The second network (the discriminator) learns to identify the difference between real and computer-generated images.

The generator’s job is to trick the discriminator into believing the images are real. This way, as the discriminator gets better at identifying AI-generated images, the generator produces more and more realistic images to trick the discriminator.

This is why they’re adversaries: As one network gets better, so does the other.

Introduction to GANs

The GAN remains one of the most fascinating innovations in deep learning. In fact, Yann LeCun, Meta’s chief AI scientist, called GANs “the most interesting idea in ML in the last 10 years.”

Back to BasicsAI vs. Machine Learning vs. Deep Learning: What’s the Difference?


Now You Try: Real Faces vs. GAN-Generated Images

real face GAN-generated images infographic

As we now know, GAN-generated images can be very convincing. Neural networks have become alarmingly good at creating realistic human faces. Given the high stakes are for both personal and national security, it’s important for us to be able to distinguish between real faces and those generated by GANs. So how do we do that? Practice, practice, practice.

Inspired by, I created an application  to quiz you on whether you can tell a real person’s face from a fake one. I used the one million fake face data set to get GAN-generated images for this project, and Kaggle’s UTKFace data set for the real images.

Try identifying which of the images are real faces and which ones are GAN-generated.

real face

In essence, you’ll be acting as a GAN discriminator. Just as the discriminator gets better at identifying AI-generated images over time, so will you. 

This article was originally published on Towards Data Science.

Expert Contributors

Built In’s expert contributor network publishes thoughtful, solutions-oriented stories written by innovative tech professionals. It is the tech industry’s definitive destination for sharing compelling, first-person accounts of problem-solving on the road to innovation.

Learn More

Great Companies Need Great People. That's Where We Come In.

Recruit With Us