1
00:00:00,390 --> 00:00:06,660
And welcome to lesson tapes, where we take a look at performing or implementing fear swaps, which

2
00:00:06,660 --> 00:00:14,430
is a very cool and I guess it's a bit outdated now, but it was quite big back in 2015 2016 with Snapchats

3
00:00:14,430 --> 00:00:18,930
and those ups, I mean, few swaps are so popular right now, but it was the height of its popularity

4
00:00:18,930 --> 00:00:19,770
was probably back then.

5
00:00:20,910 --> 00:00:25,890
So we're going to implement that using dylib, which we just demonstrated before on how we get facial

6
00:00:25,890 --> 00:00:27,150
landmarks will know.

7
00:00:27,210 --> 00:00:32,790
We're going to use those facial landmarks, line them up to do swaps, which is the underlying technology,

8
00:00:32,790 --> 00:00:35,610
would help all of those with physical bumps work.

9
00:00:35,880 --> 00:00:44,100
So let's open this notebook and we'll wait for it to load and standard procedure.

10
00:00:44,100 --> 00:00:47,850
We load all libraries in images and the prediction model.

11
00:00:48,900 --> 00:00:51,420
And this is a code for performing peer swaps.

12
00:00:52,080 --> 00:00:55,470
So I wouldn't go to every single thing in this code because it's quite long.

13
00:00:55,680 --> 00:00:56,430
You can see that here.

14
00:00:56,490 --> 00:00:57,330
It's actually very low.

15
00:00:58,350 --> 00:00:59,970
But firstly, I will say I didn't write this code.

16
00:00:59,970 --> 00:01:02,480
This code was created by Matt.

17
00:01:02,490 --> 00:01:06,570
We're not sure how much you care so much of it or something.

18
00:01:07,050 --> 00:01:07,450
Yes.

19
00:01:08,490 --> 00:01:10,950
And this is his blog address.

20
00:01:10,950 --> 00:01:16,200
Here is this copyright license material is his name and why it took me so long to say that.

21
00:01:16,770 --> 00:01:19,670
So we'll take a look at the code in a broad sense.

22
00:01:19,710 --> 00:01:21,330
So let's take a look.

23
00:01:21,440 --> 00:01:22,200
Perception is good.

24
00:01:22,230 --> 00:01:30,030
Firstly, so we just declare some variables here, which is a path for prediction model scale effect

25
00:01:30,350 --> 00:01:34,170
of the amount, which is basically how much we're doing the layering of the faces.

26
00:01:34,770 --> 00:01:40,020
Then you can see remember how we had zero to 60 odd points, each of those points each.

27
00:01:40,160 --> 00:01:46,170
Each of those points has some ranges, which correspond to first points, most points right by our left

28
00:01:46,170 --> 00:01:46,500
brow.

29
00:01:46,860 --> 00:01:47,220
Right.

30
00:01:47,230 --> 00:01:49,230
I left a notice points in Joplin.

31
00:01:49,230 --> 00:01:54,600
So those are the points we need to mesh and align so that we can line up on the face.

32
00:01:54,900 --> 00:01:59,910
So you can see that that points used to line up on the face here, but is here and these are the overlay

33
00:01:59,910 --> 00:02:00,780
points as well.

34
00:02:01,140 --> 00:02:07,350
So remember, we're trying to overlay another face onto office, so we have to mesh those points together,

35
00:02:07,560 --> 00:02:10,170
and that's what the overlay points indicate here.

36
00:02:12,120 --> 00:02:16,950
So the other part to be doing here is just doing some color correction and some blurring so that we

37
00:02:16,950 --> 00:02:19,860
can make the face swap look a little bit more realistic.

38
00:02:20,880 --> 00:02:24,330
So that's what this color correction factor parameters controls.

39
00:02:24,990 --> 00:02:27,540
This here is the detect and predict two objects.

40
00:02:27,960 --> 00:02:31,350
You've seen this before the annotated landmark functions.

41
00:02:32,070 --> 00:02:37,890
This is a draw convex hull, which allows us to map the points properly to three interfaces.

42
00:02:38,910 --> 00:02:44,160
This is to get first mass so we can extract the face from the image to put onto the first image.

43
00:02:44,940 --> 00:02:47,610
This here now is a transformation from two points.

44
00:02:48,060 --> 00:02:54,330
So it returns the Afeyan transformation so that the points sort of line up and perspective adjusted

45
00:02:54,720 --> 00:02:55,380
correctly.

46
00:02:55,710 --> 00:03:00,090
So it's a lot of different stuff is going on in this code, but I hope this gives you that this shows

47
00:03:00,090 --> 00:03:06,150
you the power of open TV so you can do some pretty complicated functional programs with open but simply

48
00:03:06,150 --> 00:03:09,570
just open TV doing the manipulation in the back end.

49
00:03:09,960 --> 00:03:11,410
So we have that and there.

50
00:03:12,090 --> 00:03:14,410
No, we're going to take a look at the functions here.

51
00:03:14,430 --> 00:03:15,580
This is a surreal image.

52
00:03:15,580 --> 00:03:17,280
You get the landmarks simple function.

53
00:03:17,820 --> 00:03:24,600
This is a warped image function where we just take down the image, the matrix and the shape, and we

54
00:03:24,600 --> 00:03:27,810
just output the final image based on those parameters.

55
00:03:28,770 --> 00:03:31,230
We have completely prevent the war by firing a function on it.

56
00:03:32,340 --> 00:03:33,490
This is the color correction.

57
00:03:33,510 --> 00:03:38,070
Remember, I mentioned we're doing some color correction with the color correct glyph parameter.

58
00:03:38,640 --> 00:03:42,810
So this and reasons of Gaussian blur to make sure it looks, it looks nice.

59
00:03:43,230 --> 00:03:46,770
And then this is a function here that controls everything swampy.

60
00:03:47,490 --> 00:03:53,280
So we'll be just text to images here and uses all the functions we defined above to return the final

61
00:03:53,280 --> 00:03:56,460
image, which is the image of the face being swapped.

62
00:03:56,610 --> 00:04:01,100
So let's run this and it shouldn't take too long.

63
00:04:01,120 --> 00:04:02,280
It's not super complicated.

64
00:04:03,870 --> 00:04:04,320
There we go.

65
00:04:04,740 --> 00:04:05,670
Very scary.

66
00:04:05,850 --> 00:04:09,690
But we have just put Hillary Clinton's face on Donald Trump.

67
00:04:10,110 --> 00:04:11,760
Color corrected it, warped it.

68
00:04:11,880 --> 00:04:13,830
Properly adjusted the color.

69
00:04:13,830 --> 00:04:14,850
Blue did slightly.

70
00:04:15,240 --> 00:04:20,070
And we have this product here, which is pretty cool and the one above, because we did it twice.

71
00:04:20,080 --> 00:04:22,290
That's what we see is what we want to do.

72
00:04:23,160 --> 00:04:23,920
This is reverse.

73
00:04:23,920 --> 00:04:29,550
This is Donald Trump's face overlaid onto Hillary Clinton's, so you can have a lot of fun with this,

74
00:04:29,550 --> 00:04:29,850
too.

75
00:04:30,180 --> 00:04:37,110
In fact, you can use this probably function here in the video quite easily and get the output so you

76
00:04:37,110 --> 00:04:42,480
can actually have a video of Donald Trump's face swapped with Hillary or Biden's Obama's.

77
00:04:42,480 --> 00:04:48,480
Anybody you want anybody famous who's calling us politicians because everyone knows who they are, but

78
00:04:49,140 --> 00:04:50,550
they can use anything you want.

79
00:04:50,880 --> 00:04:55,710
So that concludes this very cool lesson on implementing fierce works with Dillard.

80
00:04:56,210 --> 00:04:59,100
Hope you enjoyed it, and I hope you have fun with this because I certainly did.

81
00:05:00,280 --> 00:05:05,830
I'll see you in the next lesson where we take a look at implementing something called a tilt shift effect

82
00:05:06,190 --> 00:05:07,480
using open TV.

83
00:05:07,660 --> 00:05:12,960
So it's a nice little project going to fancy going too long, that would, but it's cool up.

84
00:05:12,970 --> 00:05:14,710
But so you'll take a look at that shortly.

85
00:05:14,920 --> 00:05:15,340
Thank you.
