Latest / CyberCode Academy / Course 24 - Machine Learning for Red Team Hackers | Episode 5: The Complete Guide to Deepfake Creation
Transcript
- 0:00Speaker 1: You know, there's this old saying that's been like the
- 0:02Speaker 1: bedrock of evidence for all of human history. Seeing is believing, right,
- 0:07Speaker 1: if you saw it, it happened exactly. Case closed. But
- 0:12Speaker 1: I think we're kind of standing at the funeral for
- 0:14Speaker 1: that phrase right now.
- 0:15Speaker 2: We really are. We're in an era where I mean,
- 0:18Speaker 2: anyone from a state actor to just a bored teenager
- 0:22Speaker 2: can make it look like anyone said.
- 0:23Speaker 1: Anything anything at all, even things they would never ever say.
- 0:27Speaker 1: It feels like science fiction.
- 0:29Speaker 2: It does, but it's not coming in the future. It's
- 0:31Speaker 2: already here. The tech is accessible, it's getting faster every day,
- 0:35Speaker 2: and that barrier to entry is just you know, crashing down.
- 0:39Speaker 1: And the source material we're looking at today frames this perfectly.
- 0:42Speaker 1: It calls this a dangerous time, which okay, fair enough,
- 0:47Speaker 1: but it also calls it a technologically fascinating one. So
- 0:50Speaker 1: welcome to the deep dive today. We aren't just going
- 0:54Speaker 1: to talk about the ethics of it all. We are
- 0:56Speaker 1: going to pop the hood we are.
- 0:57Speaker 2: We're going to look at the actual mechanics of this.
- 1:00Speaker 2: We're going to walk through step by step how you
- 1:02Speaker 2: actually build the deep fake.
- 1:04Speaker 1: From the Hello World mobile apps all the way to
- 1:07Speaker 1: spinning up a professional grade cloud rig.
- 1:10Speaker 2: And I think that engineering perspective is just so important.
- 1:13Speaker 2: People treat AI like it's some kind of magic.
- 1:15Speaker 1: Yeah, you press a button and poof.
- 1:17Speaker 2: Exactly, poof, a fake video appears. Yeah, but it's not magic.
- 1:21Speaker 2: It's math. It's pipeline management, and honestly, it's a lot
- 1:26Speaker 2: of trial and air.
- 1:27Speaker 1: So let's unpack this before we get into the nitty
- 1:29Speaker 1: gritty of training models and all that. We need a
- 1:31Speaker 1: baseline when we say deep fake, what are we technically
- 1:34Speaker 1: talking about?
- 1:35Speaker 2: At its core, a deep fake is an application of
- 1:37Speaker 2: neural networks. Specifically, it's the automated transfer of properties from
- 1:42Speaker 2: one set of data to another.
- 1:43Speaker 1: Transfer of properties that sounds very clinical.
- 1:46Speaker 2: It is clinical, But think of this way. You have
- 1:48Speaker 2: a source face. The classic example in the community, and
- 1:52Speaker 2: it's in our materials. Here is the actor Steve Boutimi.
- 1:55Speaker 1: Oh, an unforgettable face, very distinct, very.
- 1:58Speaker 2: Distinct, exactly. That's your source. Then you have a target video,
- 2:01Speaker 2: let's say Jennifer Lawrence on a red carpet. The neural
- 2:04Speaker 2: network learns the properties of Betemi's face.
- 2:07Speaker 1: Like the geometry, the lighting.
- 2:10Speaker 2: The way his mouth moves right, and it transfers those
- 2:12Speaker 2: properties onto the underlying structure of Jennifer Lawrence's.
- 2:16Speaker 1: Head, which I have to say, the mental image of
- 2:19Speaker 1: Steve Buscemi's face on Jennifer Lawrence is something I will
- 2:22Speaker 1: never be able to unsee. The source material uses that example,
- 2:25Speaker 1: and it is absolute nightmare fuel.
- 2:28Speaker 2: It is memorable, right, But that's just a surface you
- 2:31Speaker 2: can transfer voices, accents, body language. The imagination is really
- 2:36Speaker 2: the limit here.
- 2:37Speaker 1: Okay, so that's the what now for the how Because
- 2:39Speaker 1: for most people, their first brush with this isn't coding
- 2:43Speaker 1: a neural network in Python. It's usually something much more accessible.
- 2:47Speaker 2: Oh yeah, we're talking about things like face app.
- 2:49Speaker 1: Face app.
- 2:50Speaker 2: It's the perfect entry point because it just raps all
- 2:52Speaker 2: that complex tech in a really user friendly package. Yeah,
- 2:56Speaker 2: that hides all the math.
- 2:57Speaker 1: You take a photo, tap a filter, and suddenly you're smiling,
- 3:00Speaker 1: or you're the opposite gender or fifty years older.
- 3:03Speaker 2: I tried the aging filter. It was humbling.
- 3:05Speaker 1: It usually is.
- 3:06Speaker 2: Yeah.
- 3:06Speaker 1: The source notes that people often find it kind of creepy,
- 3:09Speaker 1: and I have to agree it's a little too real.
- 3:11Speaker 1: But it also mentioned hipster beards. Apparently if you don't
- 3:14Speaker 1: have one, it gives you this very specific lumberjack.
- 3:17Speaker 2: Look. It's fun to play with, but here's where we
- 3:19Speaker 2: need to start putting on our privacy and security ads.
- 3:23Speaker 1: I sends a butt coming.
- 3:24Speaker 2: There is a massive butt. When you use these apps.
- 3:28Speaker 2: You're making a trade off. You get a funny picture,
- 3:31Speaker 2: but to do that, you're uploading your photo, your personal
- 3:34Speaker 2: biometric data to a cloud server.
- 3:37Speaker 1: Right The processing doesn't happen on your phone.
- 3:39Speaker 2: Not at all. Your phone just doesn't have the horsepower.
- 3:41Speaker 2: So you send your face to some server, probably another country.
- 3:45Speaker 2: They process it and send the result back. You're basically
- 3:48Speaker 2: trading your privacy for a little bit of entertainment.
- 3:52Speaker 1: And that is a perfect segue to our main mission today,
- 3:55Speaker 1: because if you really want to understand this tech and
- 3:57Speaker 1: you want to protect your privacy, you shouldn't be using
- 4:00Speaker 1: these black box apps.
- 4:01Speaker 2: You should do it yourself. You have to run the
- 4:02Speaker 2: tech locally. Yeah, and that brings us to the workflow.
- 4:06Speaker 1: I love this approach because deep fakes require I mean
- 4:09Speaker 1: massive computing power. But the advice here is don't start
- 4:13Speaker 1: with the Ferrari.
- 4:14Speaker 2: Start with the bicycle exactly. You don't want to go
- 4:17Speaker 2: rent some massive, expensive supercomputer right away. You test your
- 4:21Speaker 2: pipeline on your local machine.
- 4:22Speaker 1: First, even if it's slow, Even if it's.
- 4:24Speaker 2: Slow, even if the result is blurry, you just need
- 4:26Speaker 2: to verify the process. You're going to crash the car.
- 4:30Speaker 2: You want to do it in the driveway where it
- 4:31Speaker 2: doesn't cost you money.
- 4:33Speaker 1: So let's walk through this driveway test. Step one is extraction.
- 4:37Speaker 2: Right. A video is just a sequence of still images
- 4:40Speaker 2: or frames. The software needs to go through frame by frame,
- 4:43Speaker 2: identify where the face is, crop it, and save it.
- 4:46Speaker 1: And this sounds straightforward, but this is where my favorite
- 4:49Speaker 1: anecdote from the research comes in. It really highlights how
- 4:53Speaker 1: well how dumb AI can be.
- 4:55Speaker 2: Sometimes got a plate story.
- 4:56Speaker 1: The plate story. So the software is scanning the video
- 5:00Speaker 1: and it's grabbing faces, but then it starts getting confused.
- 5:03Speaker 1: It was extracting the speaker's face just fine, but it
- 5:07Speaker 1: also started extracting a decorative plate hanging on the wall.
- 5:09Speaker 2: It's a classic false positive. The pattern on the plate
- 5:14Speaker 2: looked just enough like a face. Maybe it saw two
- 5:17Speaker 2: dark spots for eyes a curve for a mouth that
- 5:20Speaker 2: the AI went, uh huh, I found another one.
- 5:23Speaker 1: So now your data folder is full of your face
- 5:26Speaker 1: and a dinner plate. And this is crucial, right. If
- 5:28Speaker 1: you don't fix that, what happens.
- 5:31Speaker 2: The AI tries to learn from the data you give it.
- 5:34Speaker 2: So if you feed at dinner plates, it will try
- 5:36Speaker 2: to map the texture of a dinner plate onto your target.
- 5:39Speaker 2: Not really the effect you're going for, not at all.
- 5:41Speaker 1: So you have to do this cleanup phase. But you
- 5:43Speaker 1: can't just scroll through thirty thousand frames manually.
- 5:46Speaker 2: No, it would take forever. So the tools usually come
- 5:49Speaker 2: with a sorder. You tell it to sort the images
- 5:51Speaker 2: by face similarity.
- 5:52Speaker 1: Ah okay, so it groups visually similar things together.
- 5:55Speaker 2: Exactly, it clusters them. It's getting one big cluster of
- 5:58Speaker 2: all the real faces and another cluster of all the
- 6:01Speaker 2: dinner plates. Then you can just select all the plates
- 6:03Speaker 2: and hit delete. Boom, clean data set efficient.
- 6:05Speaker 1: I liked it, So plates are gone. Next step is alignment.
- 6:09Speaker 1: What does that mean here?
- 6:10Speaker 2: It's basically just bookkeeping. When the software first extracted the faces,
- 6:15Speaker 2: it created this little text file, an alignments file that
- 6:18Speaker 2: maps where each face was found, like face as that
- 6:21Speaker 2: coordinates X and Y. Got it, But we just deleted
- 6:24Speaker 2: a bunch of those faces the plates, so that map
- 6:26Speaker 2: is wrong. Now the system will look for files we
- 6:29Speaker 2: deleted and it'll crash. So you run a command to
- 6:32Speaker 2: update the alignments file. It basically tells the AI forget
- 6:35Speaker 2: the plates, they're gone.
- 6:36Speaker 1: Okay, cleaning complete database is pure. Now we move to
- 6:41Speaker 1: the main event, training the model, and.
- 6:43Speaker 2: This is where hardware limitations really come into play. On
- 6:46Speaker 2: our dry run, we're just using a regular computer, so
- 6:49Speaker 2: you have to choose our model carefully. The source mentions
- 6:52Speaker 2: a popular one called Villain Villain. That sounds ominous, just
- 6:56Speaker 2: a really high quality model, but it's a beast. It's
- 6:59Speaker 2: incredibly resource intensive. It would crush a regular laptop. So
- 7:02Speaker 2: for the dry run, we picked the lightweight model.
- 7:05Speaker 1: Keep the training wheels on exactly.
- 7:07Speaker 2: We keep the batch size small, maybe under one hundred
- 7:09Speaker 2: and fifteen images at a time. Then you hit train
- 7:12Speaker 2: and appreciate window pops up and what you see at
- 7:14Speaker 2: first is, yeah, well it's pretty weird. It's not instant,
- 7:17Speaker 2: is it?
- 7:18Speaker 1: Not at all? At the very beginning iteration zero, the
- 7:20Speaker 1: AI knows nothing about faces, so the preview just looks
- 7:23Speaker 1: like a gray.
- 7:24Speaker 2: Blob, a gray blob like static.
- 7:27Speaker 1: Literally just unstructured noise. But as the iterations tick by
- 7:31Speaker 1: one hundred, five hundred, one thousand, that blob starts to resolve.
- 7:35Speaker 1: You might see a shadow where an eye should be,
- 7:37Speaker 1: Then a mouth forms. The AI is playing this game
- 7:41Speaker 1: of hot and cold. It tries to draw face, compares
- 7:44Speaker 1: it to the original, sees it's wrong, and adjusts.
- 7:47Speaker 2: It's like watching evolution and fast forward from primordial soup
- 7:51Speaker 2: to a face.
- 7:52Speaker 1: It is and in the dry run, because we're using
- 7:54Speaker 1: that lightweight model and not training for long, the final
- 7:57Speaker 1: result is going to be pretty bad. Yeah, blurry and.
- 8:00Speaker 2: Ill defined, and that's a success.
- 8:02Speaker 1: That is a success because the goal wasn't a perfect movie.
- 8:05Speaker 1: The goal was to prove the pipeline works. Did extraction work, yes,
- 8:08Speaker 1: did training start? Yes? Did we convert it back to
- 8:10Speaker 1: a video? Yes. If you have a video of a
- 8:12Speaker 1: blurry ghost face, you've passed the test. Now you're ready
- 8:15Speaker 1: to spend some money.
- 8:16Speaker 2: Okay, let's talk about spending money to get that photorealistic quality.
- 8:20Speaker 2: My laptop isn't get to cut it. We need a GPU,
- 8:23Speaker 2: a graphics processing unit, and a serious one. Deep learning
- 8:27Speaker 2: is just millions of matrix calculations in parallel. A CPU
- 8:31Speaker 2: is like one smart mathematician solving problems one by one.
- 8:35Speaker 2: A GPU is like ten thousand people solving simple problems
- 8:38Speaker 2: all at once.
- 8:39Speaker 1: And most people don't have a professional Nvidia card at home.
- 8:42Speaker 1: They cost thousands exactly.
- 8:44Speaker 2: So the solution is the cloud. The source walks through
- 8:48Speaker 2: setting up a rig on the Google Cloud Platform GCP.
- 8:51Speaker 1: So we're renting a supercomputer by the hour. What's the recipe.
- 8:54Speaker 2: It's like a shopping list. You want an N one
- 8:56Speaker 2: standard for machine type. That's the base computer. Oh, the engines,
- 9:00Speaker 2: the accelerator. That's the heavy lifter. You want a P
- 9:02Speaker 2: one hundred GPU that's the workhorse. It has a lot
- 9:05Speaker 2: of video memory, which is key.
- 9:07Speaker 1: And for the operating system, you don't want just regular Windows.
- 9:10Speaker 2: Now, you'd select the deep Lending image from Google that
- 9:12Speaker 2: comes pre installed with things like TensorFlow. That saves you
- 9:15Speaker 2: from what we call dependency. Hell, trust me, you do
- 9:18Speaker 2: not want to go there.
- 9:19Speaker 1: Now, here's a practical question. Cloud servers are usually just
- 9:23Speaker 1: a black screen with text a command line, but the
- 9:26Speaker 1: software has a graphical interface with buttons and previews. How
- 9:30Speaker 1: do you get that visual experience on a server that's
- 9:33Speaker 1: in a data center somewhere.
- 9:35Speaker 2: That is a great question, and it's a big hurdle.
- 9:37Speaker 2: The solution is a tool called VNC Virtual Network computing VNC.
- 9:42Speaker 1: How does that work like screen sharing?
- 9:44Speaker 2: Basically? Yeah, you install a v ANDC server on the
- 9:47Speaker 2: cloud machine and a VNC viewer on your laptop at home.
- 9:51Speaker 2: You create a secure SSH tunnel between them, and it
- 9:54Speaker 2: beams the visual desktop from the cloud right down to
- 9:57Speaker 2: your screen.
- 9:57Speaker 1: That's amazing. So you're not flying blind in a text
- 10:00Speaker 1: terminal exactly.
- 10:01Speaker 2: But and there's always, but there's one technical gotcha that
- 10:04Speaker 2: drives people crazy.
- 10:05Speaker 1: Oh, let me guess. Is it the drivers?
- 10:07Speaker 2: It's always the drivers. You spin up this expensive machine,
- 10:10Speaker 2: you're paying by the minute, you're ready to go, and
- 10:12Speaker 2: the software says, error, can't find the GPU.
- 10:15Speaker 1: Total panic mode.
- 10:16Speaker 2: Yeah, you're just bleeding money. Usually it's just that the
- 10:19Speaker 2: Nvidia drivers on the cloud instance are a bit out
- 10:21Speaker 2: of date. You have to do the boring work of
- 10:23Speaker 2: updating them from the terminal.
- 10:24Speaker 1: First five minutes of work. That saves you hours of frustration.
- 10:28Speaker 2: Absolutely, So rig is built. P one hundred is humming.
- 10:32Speaker 2: We've uploaded our clean data sets, no dinner plates. We
- 10:36Speaker 2: hit train on the villain model. Now this isn't going
- 10:38Speaker 2: to take ten minutes?
- 10:39Speaker 1: How long are we talking?
- 10:40Speaker 2: High quality models can take days easily twenty four to
- 10:44Speaker 2: forty eight hours of continuous processing.
- 10:46Speaker 1: So what do we do? Just leave our laptop open
- 10:48Speaker 1: and stare at the VNC window for two days.
- 10:50Speaker 2: You could, but it's risky. If your internet flickers, you
- 10:53Speaker 2: lose the connection. This brings us to monitoring. You need
- 10:57Speaker 2: a way to check on that gray blob turning into
- 10:59Speaker 2: a face without being glued to the screen.
- 11:01Speaker 1: And there's a command line trick for this, right a flag.
- 11:03Speaker 2: Yes, the W flag. When you start the training, you
- 11:06Speaker 2: had that little flag. It tells the AI, Hey, every
- 11:09Speaker 2: twenty minutes or so, write an image file to the
- 11:11Speaker 2: hard drive showing me your current progress.
- 11:14Speaker 1: So it saves a preview dot jpg right on the
- 11:16Speaker 1: cloud server exactly.
- 11:18Speaker 2: Yeah, and then from your home computer you can use
- 11:21Speaker 2: a protocol called SEP Secure Copy Protocol to just download
- 11:26Speaker 2: that one specific image file.
- 11:27Speaker 1: So you just pull down that one picture, you open it,
- 11:30Speaker 1: sip your coffee, and judge the progress. You can say, Okay,
- 11:33Speaker 1: the blob is looking more like a face, or wow,
- 11:35Speaker 1: the eyes are still crossed. Let it run another ten hours.
- 11:38Speaker 2: Precisely and lets you manage the creation remotely and efficiently.
- 11:42Speaker 2: You only stop the expensive meter from running when you're
- 11:44Speaker 2: happy with that preview.
- 11:45Speaker 1: So we've gone from facesap filters to a local dry
- 11:49Speaker 1: run to a professional cloud rig. We've really demystified the
- 11:52Speaker 1: black box.
- 11:53Speaker 2: We have, and I think what's fascinating is how methodical
- 11:56Speaker 2: it is. When you break it down, it stops being
- 11:59Speaker 2: this scary site weapon and it starts looking like, well,
- 12:02Speaker 2: like work. It's sorting images, updating drivers, managing servers.
- 12:06Speaker 1: It's a craft, a potentially dangerous one, but a craft
- 12:09Speaker 1: which brings us to the assignment from the source material.
- 12:12Speaker 1: They don't just want you to read about.
- 12:13Speaker 2: This, they want you to try it. The challenge is
- 12:16Speaker 2: for you to actually go out and do this, create
- 12:18Speaker 2: a deep fake of your own choosing, and post it now.
- 12:20Speaker 1: Obviously keep it legal and ethical. But why do they
- 12:23Speaker 1: encourage this? Why tell people to go make one?
- 12:27Speaker 2: Because active participation is key. Once you've built one, once
- 12:31Speaker 2: you've seen that gray blob resolve, once you've seen the
- 12:34Speaker 2: glitches where the face falls off, you look at media differently.
- 12:38Speaker 2: You become inoculated.
- 12:40Speaker 1: You really do, you stop trusting video blindly. But before
- 12:43Speaker 1: we let everyone go off and start swapping faces, we
- 12:46Speaker 1: have a little review question.
- 12:48Speaker 2: Right. We talked about the extraction phase. Why was it
- 12:51Speaker 2: so crucial to use the sort by face similarity tool
- 12:54Speaker 2: during the cleanup? What was this specific error we were
- 12:57Speaker 2: trying to catch.
- 12:57Speaker 1: I'll give you a hint. It belongs in a kitchen,
- 13:00Speaker 1: not on a human neck.
- 13:01Speaker 2: Hopefully that image sticks.
- 13:02Speaker 1: If you shouted the plate on the wall, you are
- 13:05Speaker 1: ready to build your own neural network.
- 13:07Speaker 2: And if we connect this all back mastering. This isn't
- 13:09Speaker 2: just about making funny videos. It's about literacy. We're living
- 13:13Speaker 2: in a world where seeing is believing is just an
- 13:18Speaker 2: outdated concept.
- 13:20Speaker 1: That's the heavy truth to end on. This tack is
- 13:23Speaker 1: a tool. It can be used for Hollywood effects, for satire,
- 13:27Speaker 1: or for deception. By understanding how the sausage is made,
- 13:30Speaker 1: we become better at spotting the fakes. We reclaim a
- 13:33Speaker 1: little bit of that truth and.
- 13:34Speaker 2: That critical thinking is the best defense we have.
- 13:37Speaker 1: So go forth, experiment reclonsively, and maybe don't put your
- 13:41Speaker 1: face on too many loud servers if you can avoid it.
- 13:44Speaker 1: That's it for this deep dive.
- 13:45Speaker 2: Thanks for listening, See you next time.