-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeepFake.tex
More file actions
1816 lines (1488 loc) · 111 KB
/
Copy pathDeepFake.tex
File metadata and controls
1816 lines (1488 loc) · 111 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[12pt]{article}
\usepackage[breakable]{tcolorbox}
\usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
% Basic figure setup, for now with no caption control since it's done
% automatically by Pandoc (which extracts  syntax from Markdown).
\usepackage{graphicx}
% Keep aspect ratio if custom image width or height is specified
\setkeys{Gin}{keepaspectratio}
% Maintain compatibility with old templates. Remove in nbconvert 6.0
\let\Oldincludegraphics\includegraphics
% Ensure that by default, figures have no caption (until we provide a
% proper Figure object with a Caption API and a way to capture that
% in the conversion process - todo).
\usepackage{caption}
\DeclareCaptionFormat{nocaption}{}
\captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}
\usepackage{float}
\floatplacement{figure}{H} % forces figures to be placed at the correct location
\usepackage{xcolor} % Allow colors to be defined
\usepackage{enumerate} % Needed for markdown enumerations to work
\usepackage{geometry} % Used to adjust the document margins
\usepackage{amsmath} % Equations
\usepackage{amssymb} % Equations
\usepackage{textcomp} % defines textquotesingle
% Hack from http://tex.stackexchange.com/a/47451/13684:
\AtBeginDocument{%
\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
}
\usepackage{upquote} % Upright quotes for verbatim code
\usepackage{eurosym} % defines \euro
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\IfFileExists{alphabeta.sty}{
\usepackage{alphabeta}
}{
\usepackage[mathletters]{ucs}
\usepackage[utf8x]{inputenc}
}
\else
\usepackage{fontspec}
\usepackage{unicode-math}
\fi
\usepackage{fancyvrb} % verbatim replacement that allows latex
\usepackage{grffile} % extends the file name processing of package graphics
% to support a larger range
\makeatletter % fix for old versions of grffile with XeLaTeX
\@ifpackagelater{grffile}{2019/11/01}
{
% Do nothing on new versions
}
{
\def\Gread@@xetex#1{%
\IfFileExists{"\Gin@base".bb}%
{\Gread@eps{\Gin@base.bb}}%
{\Gread@@xetex@aux#1}%
}
}
\makeatother
\usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
\adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}
% The hyperref package gives us a pdf with properly built
% internal navigation ('pdf bookmarks' for the table of contents,
% internal cross-reference links, web links for URLs, etc.)
\usepackage{hyperref}
% The default LaTeX title has an obnoxious amount of whitespace. By default,
% titling removes some of it. It also provides customization options.
\usepackage{titling}
\usepackage{longtable} % longtable support required by pandoc >1.10
\usepackage{booktabs} % table support for pandoc > 1.12.2
\usepackage{array} % table support for pandoc >= 2.11.3
\usepackage{calc} % table minipage width calculation for pandoc >= 2.11.1
\usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
\usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
% normalem makes italics be italics, not underlines
\usepackage{soul} % strikethrough (\st) support for pandoc >= 3.0.0
\usepackage{mathrsfs}
% Colors for the hyperref package
\definecolor{urlcolor}{rgb}{0,.145,.698}
\definecolor{linkcolor}{rgb}{.71,0.21,0.01}
\definecolor{citecolor}{rgb}{.12,.54,.11}
% ANSI colors
\definecolor{ansi-black}{HTML}{3E424D}
\definecolor{ansi-black-intense}{HTML}{282C36}
\definecolor{ansi-red}{HTML}{E75C58}
\definecolor{ansi-red-intense}{HTML}{B22B31}
\definecolor{ansi-green}{HTML}{00A250}
\definecolor{ansi-green-intense}{HTML}{007427}
\definecolor{ansi-yellow}{HTML}{DDB62B}
\definecolor{ansi-yellow-intense}{HTML}{B27D12}
\definecolor{ansi-blue}{HTML}{208FFB}
\definecolor{ansi-blue-intense}{HTML}{0065CA}
\definecolor{ansi-magenta}{HTML}{D160C4}
\definecolor{ansi-magenta-intense}{HTML}{A03196}
\definecolor{ansi-cyan}{HTML}{60C6C8}
\definecolor{ansi-cyan-intense}{HTML}{258F8F}
\definecolor{ansi-white}{HTML}{C5C1B4}
\definecolor{ansi-white-intense}{HTML}{A1A6B2}
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
\definecolor{ansi-default-inverse-bg}{HTML}{000000}
% common color for the border for error outputs.
\definecolor{outerrorbackground}{HTML}{FFDFDF}
% commands and environments needed by pandoc snippets
% extracted from the output of `pandoc -s`
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\newenvironment{Shaded}{}{}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
\newcommand{\RegionMarkerTok}[1]{{#1}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
\newcommand{\NormalTok}[1]{{#1}}
% Additional commands for more recent versions of Pandoc
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
\newcommand{\ImportTok}[1]{{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
\newcommand{\BuiltInTok}[1]{{#1}}
\newcommand{\ExtensionTok}[1]{{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
% Define a nice break command that doesn't care if a line doesn't already
% exist.
\def\br{\hspace*{\fill} \\* }
% Math Jax compatibility definitions
\def\gt{>}
\def\lt{<}
\let\Oldtex\TeX
\let\Oldlatex\LaTeX
\renewcommand{\TeX}{\textrm{\Oldtex}}
\renewcommand{\LaTeX}{\textrm{\Oldlatex}}
% Document parameters
% Document title
\title{DeepFake}
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
\let\PY@ul=\relax \let\PY@tc=\relax%
\let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
\PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
\PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}
\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.61,0.40,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.80,0.25,0.22}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.46,0.46,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.41,0.47,0.13}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.36,0.12}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.64,0.35,0.47}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.52,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{0.89,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@ges}{\let\PY@bf=\textbf\let\PY@it=\textit}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.44,0.44,0.44}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{\string -\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.24,0.48,0.48}{##1}}}
\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother
% For linebreaks inside Verbatim environment from package fancyvrb.
\makeatletter
\newbox\Wrappedcontinuationbox
\newbox\Wrappedvisiblespacebox
\newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}}
\newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}}
\newcommand*\Wrappedcontinuationindent {3ex }
\newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox}
% Take advantage of the already applied Pygments mark-up to insert
% potential linebreaks for TeX processing.
% {, <, #, %, $, ' and ": go to next line.
% _, }, ^, &, >, - and ~: stay at end of broken line.
% Use of \textquotesingle for straight quote.
\newcommand*\Wrappedbreaksatspecials {%
\def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}%
\def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}%
\def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}%
\def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}%
\def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}%
\def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}%
\def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}%
\def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}%
\def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}%
\def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}%
\def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}%
\def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}%
\def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}%
\def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}%
}
% Some characters . , ; ? ! / are not pygmentized.
% This macro makes them "active" and they will insert potential linebreaks
\newcommand*\Wrappedbreaksatpunct {%
\lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}%
\lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}%
\lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}%
\lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}%
\lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}%
\lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}%
\lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}%
\catcode`\.\active
\catcode`\,\active
\catcode`\;\active
\catcode`\:\active
\catcode`\?\active
\catcode`\!\active
\catcode`\/\active
\lccode`\~`\~
}
\makeatother
\let\OriginalVerbatim=\Verbatim
\makeatletter
\renewcommand{\Verbatim}[1][1]{%
%\parskip\z@skip
\sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
\sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
\def\FancyVerbFormatLine ##1{\hsize\linewidth
\vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
\doublehyphendemerits\z@\finalhyphendemerits\z@
\strut ##1\strut}%
}%
% If the linebreak is at a space, the latter will be displayed as visible
% space at end of first line, and a continuation symbol starts next line.
% Stretch/shrink are however usually zero for typewriter font.
\def\FV@Space {%
\nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
\discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
{\kern\fontdimen2\font}%
}%
% Allow breaks at special characters using \PYG... macros.
\Wrappedbreaksatspecials
% Breaks at punctuation characters . , ; ? ! and / need catcode=\active
\OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
}
\makeatother
% Exact colors from NB
\definecolor{incolor}{HTML}{303F9F}
\definecolor{outcolor}{HTML}{D84315}
\definecolor{cellborder}{HTML}{CFCFCF}
\definecolor{cellbackground}{HTML}{F7F7F7}
% prompt
\makeatletter
\newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
\makeatother
\newcommand{\prompt}[4]{
{\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
}
% Prevent overflowing lines due to hard-to-break entities
\sloppy
% Setup hyperref package
\hypersetup{
breaklinks=true, % so long urls are correctly broken across lines
colorlinks=true,
urlcolor=urlcolor,
linkcolor=linkcolor,
citecolor=citecolor,
}
% Slightly bigger margins than the latex defaults
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
\setcounter{tocdepth}{3}
\begin{document}
\begin{titlepage}
\centering
{\Huge\bfseries DeepFake Detection \\[1cm]}
{\Huge Fine-tuning Pretrained Networks to Identify the Best Model for Distinguishing Real and Fake Faces \\[2cm]}
\includegraphics[width=0.5\textwidth]{liotru.png} \\[1cm]
{\huge\textbf{Giuseppe Leonardi}} \\[0.5cm]
{\Large 1000065630} \\[0.5cm]
{\Large Data Science - UNICT} \\[1.5cm]
\vfill
\end{titlepage}
\tableofcontents
\newpage
\section{Introduction}\label{introduction}
The goal of this project is to build and evaluate a system capable of
\textbf{distinguishing} between real and deep fake faces using
pre-trained neural networks. This system is intended to provide a robust
approach to identifying AI-generated images, which is crucial given the
growing prevalence of deep fake technologies.
Deep fake images and videos have raised concerns across various domains,
including cybersecurity, media authenticity, and personal privacy. The
development of reliable detection techniques is essential to mitigate
their misuse. This project explores the performance of pre-trained
models such as \emph{ResNet}, \emph{EfficientNet}, \emph{DenseNet} and
\emph{Vision Transformer} (ViT) for this task.
The dataset used in this project contains images of real faces and deep
fake faces, organized into two main categories:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
\textbf{Real Faces}: These images are stored in folders prefixed with
``0-''.
\item
\textbf{DeepFake Faces}: These images are stored in folders prefixed
with ``1-''.
\end{enumerate}
Each image represents a human face, with the deep fake images generated
using advanced artificial intelligence techniques such as StyleGAN or
StyleGAN2, which are widely used for generating synthetic facial images.
The real face images come from publicly available high-quality datasets
containing photographs of authentic human faces.
After mounting Google Drive on Colab to seamlessly access the dataset
without overloading Colab's memory, I extracted the zip files containing
the images, organized based on their creation method. I structured the
dataset into two main folders: \emph{Real} and \emph{Fake}.
Before diving into data preprocessing, I explored an intriguing step:
transitioning these images from the spatial domain to the frequency
domain using the two-dimensional Fourier transform. This approach
allowed me to investigate whether images generated by certain models
exhibit recurring patterns or atypical structures.
To achieve this, I transformed each image into its frequency domain
representation, calculated the average frequency spectrum for each
folder, and then computed the overall averages for both Real and Deep
Fake images. This analysis serves as a foundation to uncover unique
traits within each category.
Further details will be discussed in the next section.
\subsection{Fourier Spectra of the
Images}\label{fourier-spectra-of-the-images}
In the context of analyzing images, the \textbf{spatial domain} alone
may not reveal subtle differences. Generative models like GANs often
produce images that visually resemble real ones but exhibit
\emph{distinctive patterns} in their underlying frequency distributions.
The Fourier Transform provides a way to examine these frequency
characteristics. By converting images from the spatial domain to the
\textbf{frequency domain}, we can uncover artifacts introduced by
generative models, differences in energy distribution, insights into the
generative process.
This makes Fourier analysis a powerful tool for understanding and
comparing the properties of real and fake images beyond their
appearance, making it an essential choice for this study.
The 2D Fourier Transform is a fundamental tool for analyzing the spatial
frequencies of an image. When applied to an image:
\begin{itemize}
\item
\textbf{Low frequencies} (\emph{near the center of the spectrum}):
correspond to slow variations (large structures or smooth gradients).
\item
\textbf{High frequencies} (\emph{near the edges of the spectrum}):
correspond to fine details or rapid variations (textures or sharp
edges).
\end{itemize}
The result of the transform is an amplitude spectrum, representing the
energy of the spatial frequencies present in the image. In the
visualization the bright central region represents the dominance of low
frequencies (typical in natural images). Regular or symmetric patterns
indicate artifacts, often associated with synthetic images.
The Fourier Transform is particularly useful for analyzing differences
between real and artificially generated images. Generative models, such
as GANs (Generative Adversarial Networks), often introduce artifacts at
specific frequencies, which can be identified in the spectrum.
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{31}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{show\PYZus{}fourier}\PY{p}{(}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\prompt{Out}{outcolor}{31}{}
\begin{center}
\adjustimage{max size={0.8\linewidth}{0.8\paperheight}}{DeepFake_files/DeepFake_6_0.png}
\end{center}
{ \hspace*{\fill} \\}
Now, let's delve into the results obtained:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
\textbf{Real Images} (\emph{CelebA, FFHQ}): The spectra exhibit a
\textbf{dominant central peak} with a gradual decay toward higher
frequencies. These spectra are typical of natural images, where low
frequencies dominate due to the spatial coherence of structures.
\textbf{No periodic or symmetric patterns are observed}, indicating
the absence of artificial artifacts in the data.
\item
\textbf{Synthetic Images} (\emph{ATTGAN, GDWCT, StarGAN, STYLEGAN}):
\end{enumerate}
\begin{itemize}
\tightlist
\item
ATTGAN and GDWCT: Show less pronounced \textbf{regular patterns} but
still exhibit some periodic structures, indicating artifacts
introduced by the generative process.
\item
StarGAN and STYLEGAN: Display clear \textbf{grid-like patterns} and
pronounced symmetries, with visible periodic frequencies.
\end{itemize}
These artifacts are characteristic of GAN models, which tend to
introduce unwanted frequencies during the image generation process.
These patterns may stem from the convolutional operations in the
generator.
For a more in-depth consultation, I saved the resulting images on Drive,
ensuring they are readily accessible
\subsection{Preprocessing}\label{preprocessing}
The preprocessing steps were carried out to ensure robustness and prevent overfitting. The preprocessing
steps include:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
\emph{Resizing}: The images were resized to a consistent size (224x224
pixels), to ensure uniform processing.
\item
\emph{Normalization}: To improve convergence during training, the
images were normalized by a normalization standard to match the
distribution of training data from pre-trained models, such as
subtracting the mean and dividing by the standard deviation of the
ImageNet dataset.
\item
\emph{Augmentation}: To increase the variability of the images and
enhance model robustness, augmentation techniques were applied,
including rotation, translation, horizontal flipping, and brightness
adjustments, to generate different versions of the images for
training.
\end{enumerate}
The dataset was divided into three subsets:
\begin{itemize}
\tightlist
\item
\emph{Training Set}: Used to train the deep learning models. About
70\% of the images were allocated to training.
\item
\emph{Validation Set}: Used to fine-tune model parameters and prevent
overfitting. About 15\% of the images were allocated to validation.
\item
\emph{Test Set}: Used to evaluate the model's generalization
capability on unseen data. It will be used at the end of the studies.
\end{itemize}
This split allows for evaluating the model's effectiveness during and
after training, ensuring there is no bias and that the model can
generalize well to new images.
\section{Methodology}\label{methodology}
The following pre-trained models were selected for this project due to
their proven effectiveness in image classification tasks:
\texttt{DenseNet-121}: This model is known for its efficient
architecture that allows each layer to receive input from all previous
layers, facilitating better feature reuse and leading to improved
performance with fewer parameters. The number 121 refers to the number
of layers in the network, striking a balance between model complexity
and computational efficiency.
\texttt{ResNet-18}: ResNet (Residual Networks) are designed to combat
the vanishing gradient problem by using residual connections, allowing
for very deep networks without a significant loss in performance. The
``18'' refers to the number of layers in the network, which is the
smallest version of ResNet, making it ideal for tasks where
computational resources or training data are limited.
\texttt{EfficientNet-B0}: This model uses a novel compound scaling
method that scales depth, width, and resolution uniformly, providing
state-of-the-art accuracy with fewer parameters and lower computational
cost. EfficientNet has multiple variants (e.g., EfficientNet-B0, B1,
etc.), with the number indicating the model size. The larger the number,
the more computationally intensive and accurate the model becomes. For
this project, the B0 variant was selected based on the available
resources and required performance.
\texttt{Vision\ Transformer} (\texttt{ViT}): ViT leverages transformer
architectures, which have demonstrated remarkable performance in vision
tasks by processing image patches as sequences, similar to how text is
processed in NLP tasks. This model is known for its scalability and
performance on large datasets.
These models were selected for their ability to generalize well on image
classification tasks, as well as their diverse architectural
characteristics, which help explore different approaches to the problem.
\section{Training Process}\label{training-process}
The training process was designed to ensure efficient model learning
while preventing overfitting and handling limited GPU memory. The
following key steps were implemented.
\subsection{Training Setup}\label{training-setup}
Loss Function (Criterion): The CrossEntropyLoss was used as the
criterion to evaluate the model's performance during training and
validation. This loss function is commonly used for multi-class
classification tasks, which aligns with the binary classification
problem of distinguishing real and deep fake faces.
Optimizer: The Adam optimizer was chosen due to its adaptive learning
rate capabilities, which help in faster convergence and stability during
training. The learning rate was set to 1e-4, a commonly used value for
fine-tuning pre-trained models.
Learning Rate Scheduler: The ReduceLROnPlateau scheduler was implemented
to reduce the learning rate if the validation loss plateaus, helping to
refine the model's training by providing smaller updates when necessary.
This helps avoid overshooting the optimal weights as the model
approaches convergence.
\subsection{Training Loop}\label{training-loop}
The train\_one\_epoch function handles the training for each epoch. For
each batch of images, the model performs the following steps:
Forward Pass: The input images are passed through the model to generate
predictions.
Loss Calculation: The model's predictions are compared with the true
labels using CrossEntropyLoss, which is computed for the batch.
Gradient Accumulation: To simulate larger batch sizes while maintaining
memory efficiency, the loss is divided by the accumulation\_steps (set
to 4 in this case). Gradients are accumulated over several mini-batches,
and the model's weights are updated only after accumulating gradients
for accumulation\_steps mini-batches.
Accuracy Tracking: The training accuracy is calculated by comparing the
model's predictions with the true labels.
The validate\_one\_epoch\_with\_preds function is used for validating the
model at the end of each epoch:
Forward Pass: Like the training phase, the model generates predictions
for the validation dataset.
Loss and Accuracy Calculation: The loss and accuracy are computed for
the entire validation set.
Metrics Tracking: The true labels and predicted labels are stored to
calculate additional evaluation metrics (precision, recall, F1-score).
\subsection{Evaluation Metrics}\label{evaluation-metrics}
To monitor the model's performance during training, the following
metrics were computed:
Accuracy: Measures the percentage of correct predictions in both
training and validation sets.
Precision, Recall, and F1-Score: These metrics are calculated for the
validation set to assess the classifier's ability to correctly identify
real and deep fake faces, considering both false positives and false
negatives.
Confusion Matrix: The confusion matrix was computed at the end of each
epoch, providing a clear visualization of the model's classification
performance, including true positives, false positives, true negatives,
and false negatives.
\subsection{Optimization Techniques}\label{optimization-techniques}
To improve model training, the following techniques were employed:
Early Stopping: To prevent overfitting and unnecessary computation,
early stopping was implemented. If the validation loss does not improve
after a specified number of epochs (set to patience=3), training stops
early.
Batch Accumulation: Given the constraints on GPU memory, batch
accumulation was used to simulate larger batch sizes. This technique
allows for more effective weight updates without exceeding memory
limits, enabling the use of deeper and more complex models.
\subsection{Model Evaluation and Saving
Results}\label{model-evaluation-and-saving-results}
Best Model Selection: The model with the lowest validation loss was
saved as the best model. If the validation loss improved during an
epoch, the results (precision, recall, F1-score, and confusion matrix)
were updated.
Confusion Matrix Visualization: At the end of training, a heatmap of the
confusion matrix was generated, providing insights into the model's
classification performance across different classes (real vs.~fake
faces).
Results Storage: All the results (training and validation losses,
accuracies, and metrics for each epoch) were stored in a CSV file for
further analysis and visualization.
\section{The Training}\label{the-training}
Now, let's start to train each one of the choosen models, all of them
with all frozen layers, except for the last one, the Classifier.
\subsection{ResNet-18}\label{resnet-18}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{37}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{performance}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{ResNet\PYZhy{}18}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_26_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_26_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_26_2.png}
\end{center}
{ \hspace*{\fill} \\}
The model shows promising results overall, but there are areas where we
could see improvement.
The \textbf{training loss} is relatively low at \texttt{0.1441},
suggesting that the model has learned well from the training data.
However, the higher \textbf{validation loss} compared to the training
loss points to a potential issue of overfitting. This means that while
the model performs well on the training set, it might not generalize as
well to the validation set.
Looking at the training and validation accuracy, both values are fairly
close to each other, which is a positive sign, indicating that the model
is not significantly overfitting. The \textbf{training accuracy} of
\texttt{71.31\%} and \textbf{validation accuracy} of \texttt{72.25\%}
are both respectable, but there's still room to increase performance.
\textbf{Precision} stands at \texttt{68.85\%}, meaning that when the
model predicts a positive class, it is correct nearly 69\% of the time.
The \textbf{Recall} indicate that the model is identifying \texttt{70\%}
of the true positive cases. The F1 score is a combination of these two
metrics and reflects a good but improvable balance between them.
In terms of the \textbf{confusion matrix}, the model has correctly
classified \texttt{163\ true\ negatives} and
\texttt{126\ true\ positives}, which is good. However, there are some
errors: \texttt{57\ false\ positives} and \texttt{54\ false\ negatives}.
These errors could be minimized with model tuning, better feature
engineering, or even more training data.
\subsection{EfficientNet}\label{efficientnet}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{39}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{performance}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{EfficientNet}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_29_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_29_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_29_2.png}
\end{center}
{ \hspace*{\fill} \\}
The EfficientNet model demonstrates solid performance but leaves room
for improvement in some areas.
The \textbf{training loss} is relatively low at \texttt{0.1306},
indicating that the model has effectively learned patterns from the
training data. However, the higher \textbf{validation loss} of
\texttt{0.5223} suggests that the model may be struggling to generalize
to unseen data, which could be an indicator of mild overfitting.
When comparing the \textbf{training accuracy} of \texttt{80.87\%} with
the \textbf{validation accuracy} of \texttt{80.25\%}, the two values are
quite close. This consistency is a positive sign, as it implies that the
model is not significantly overfitting.
Looking deeper into the precision, recall, and F1 score:
\textbf{Precision} (\texttt{76.72\%}) shows that when the model predicts
a positive class, it is correct nearly 77\% of the time. \textbf{Recall}
(\texttt{80.56\%}) highlights that the model is successfully identifying
over 80\% of the true positive cases. The \textbf{F1 score}
(\texttt{78.59\%}) reflects a strong balance between precision and
recall, which is encouraging.
From the confusion matrix, we can see that the model correctly
classified:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\tightlist
\item
176 true negatives;
\item
145 true positives;
\end{enumerate}
However, there are notable errors that suggest potential areas for
improvement. For instance, reducing false negatives would boost recall,
while minimizing false positives would improve precision.
Overall, EfficientNet shows promise with good generalization, but there
is still scope for optimization to achieve higher performance.
\subsection{DenseNet-121}\label{densenet-121}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{41}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{performance}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{DenseNet121}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_32_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_32_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_32_2.png}
\end{center}
{ \hspace*{\fill} \\}
The \textbf{training loss} is relatively low at \texttt{0.1325}, which
indicates that the model has successfully learned patterns from the
training data. However, the \textbf{validation loss} of \texttt{0.5293}
is higher, suggesting that the model might be struggling to generalize
to new, unseen data. This discrepancy between the training and
validation losses could point to mild overfitting.
When comparing the \textbf{training accuracy} of \texttt{79.75\%} and
the validation accuracy of \texttt{80.75\%}, the close proximity between
the two values suggests that the model is not severely overfitting. This
is a positive sign, as it indicates that the model performs similarly on
both the training and validation sets.
Looking at precision, recall, and F1 score:
\textbf{Precision} (\texttt{78.30\%}) tells us that when the model
predicts a positive class (fake face), it is correct \texttt{78.30\%} of
the time. This is a good result, but there is still room for improvement
to reduce false positives (real faces misclassified as fake).
\textbf{Recall} (\texttt{84.26\%}) indicates that the model successfully
identifies 84.26\% of the true positives (fake faces). This is a strong
result, but further improvement could be made by reducing false
negatives (fake faces misclassified as real).
The \textbf{F1 score} (\texttt{81.17\%}) reflects a strong balance
between precision and recall, indicating that the model has achieved a
solid trade-off between these two metrics.
In summary, DenseNet-121 shows good generalization with a strong ability
to identify fake faces. However, there is still potential for
improvement, particularly in reducing misclassifications, such as false
positives and false negatives, to boost both precision and recall.
Further optimization can lead to better performance.
\subsection{ViT}\label{vit}
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{43}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{performance}\PY{p}{(}\PY{l+s+s2}{\PYZdq{}}\PY{l+s+s2}{Vit}\PY{l+s+s2}{\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_35_0.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_35_1.png}
\end{center}
{ \hspace*{\fill} \\}
\begin{center}
\adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{DeepFake_files/DeepFake_35_2.png}
\end{center}
{ \hspace*{\fill} \\}
The ViT (Vision Transformer) model shows promising results with room for
further improvement in some areas.
The \textbf{training loss} starts at \texttt{0.1851} and decreases to
\texttt{0.1231} by epoch 20, suggesting that the model effectively
learns patterns from the training data. However, the** validation loss**
remains higher, starting at \texttt{0.7129} and dropping to
\texttt{0.5204} by epoch 20. While the model's validation loss decreases
over time, it's still higher than the training loss, indicating some
level of overfitting. The model may be performing well on the training
data but struggling to generalize to unseen data.
When we look at the \textbf{training accuracy}, it increases from
\texttt{51.56\%} in the first epoch to \texttt{76.81\%} in the final
epoch, demonstrating an improvement in the model's ability to correctly
classify the training set. Similarly, the \textbf{validation accuracy}
starts at \texttt{55\%} and rises to \texttt{75.25\%} by epoch 20,
showing a consistent improvement.
\textbf{Precision} indicates that when the model predicts a positive
class (fake face), it is correct \texttt{75\%} of the time. The
\textbf{Recall} highlights that the model identifies \texttt{74.62\%} of
the true positives (fake faces). Although recall is relatively high,
further improvements could still reduce the number of false negatives
(fake faces misclassified as real). \textbf{F1 score} (\texttt{74.81\%})
represents a balanced performance between precision and recall,
indicating the model's strength in both correctly identifying fake faces
and minimizing misclassifications.
Looking at the \textbf{confusion matrix}, The presence of errors
suggests areas where the model could be further optimized, specifically
by reducing false positives to improve precision and false negatives to
enhance recall.
In summary, the ViT model performs well with solid generalization across
training and validation sets. While precision, recall, and F1 score are
strong, there is still potential to reduce misclassifications,
especially false positives and false negatives, through further tuning
and optimization.
\subsection{The Choice}\label{the-choice}
Now, compare each model to others to choose of them:
\begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{44}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{model\PYZus{}names} \PY{o}{=} \PY{p}{[}\PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{ResNet\PYZhy{}18}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{EfficientNet}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{DenseNet121}\PY{l+s+s1}{\PYZsq{}}\PY{p}{,} \PY{l+s+s1}{\PYZsq{}}\PY{l+s+s1}{Vit}\PY{l+s+s1}{\PYZsq{}}\PY{p}{]}
\PY{n}{recap}\PY{p}{(}\PY{n}{model\PYZus{}names}\PY{p}{)}
\end{Verbatim}