<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mussa Aman on Medium]]></title>
        <description><![CDATA[Stories by Mussa Aman on Medium]]></description>
        <link>https://medium.com/@moon1ight?source=rss-cd8e6827e92f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XQ8wRgFBaRt_SbJOCaCwDA.jpeg</url>
            <title>Stories by Mussa Aman on Medium</title>
            <link>https://medium.com/@moon1ight?source=rss-cd8e6827e92f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 14:48:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moon1ight/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deepfake Video Detection — Deep Learning, Paper explained]]></title>
            <link>https://medium.com/@moon1ight/deepfake-video-detection-deep-learning-paper-explained-481636e08feb?source=rss-cd8e6827e92f------2</link>
            <guid isPermaLink="false">https://medium.com/p/481636e08feb</guid>
            <category><![CDATA[deepfake-detection]]></category>
            <category><![CDATA[facial-recognition]]></category>
            <category><![CDATA[vision-transformer]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[deepfakes]]></category>
            <dc:creator><![CDATA[Mussa Aman]]></dc:creator>
            <pubDate>Sat, 17 Dec 2022 08:31:09 GMT</pubDate>
            <atom:updated>2022-12-19T07:45:38.978Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Deepfake Video Detection — Deep Learning, from definition to algorithm</strong></h3><p>The post aims to study DeepFake face image processing technology and detection methods. Moreover, this article lists four types of facial operations that are frequently met. Furthermore, this article also shows an example of the deepfake detection technology with the highest accuracy in paperswithcode.com.</p><blockquote>This post is for <a href="https://github.com/avalur/ml-course-kbtu">KBTU ML courses</a>.</blockquote><blockquote><em>DeepFakes and Beyond: A Survey of Face Manipulation and Fake Detection </em><a href="https://arxiv.org/pdf/2001.00179v3.pdf"><em>https://arxiv.org/pdf/2001.00179v3.pdf</em></a><em>.</em></blockquote><blockquote><em>Combining EfficientNet and Vision Transformers for Video Deepfake Detection </em><a href="https://arxiv.org/pdf/2107.02612v2.pdf"><em>https://arxiv.org/pdf/2107.02612v2.pdf</em></a></blockquote><h3>I What is Deepfake?</h3><p>Deepfake means creating fake images or videos, the technology based on deep learning to swap faces between different people. The abuse of deepfake mainly observed on the actresses, political leaders. It starts to be a heat topic again due to i) the large-scale public data, ii) the development of deep learning techniques like GAN, Variational AutoEconder. This makes anyone can create a fake image or video, even without any experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y3HLd4prWwc7hR-lNueQNQ.jpeg" /></figure><p><strong>GAN is stand for generative adversarial network, there are two parts:</strong></p><ol><li>The generator G(z) is neural network, learns to generate object x from noise z.</li><li>The discriminator learns to distinguish them from real object.</li></ol><p>As an example shown in Figure 1, you can see the generator create new data instances, and discriminator evaluate them for authenticity. In detail, it could be described in following steps:</p><ol><li>The generator takes the random numbers and returns a new face.</li><li>Then new face image will be sent into the discriminator with the real faces.</li><li>Finally, discriminator receive generated and real face, return the probabilities, fake or real.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*eKr-J2d71j5Grk9KFN3ikw.png" /><figcaption>Figure 1. Example of GAN <a href="https://github.com/avalur/ml-course-kbtu/tree/main/week11_autoencoder_gan">https://github.com/avalur/ml-course-kbtu/tree/main/week11_autoencoder_gan</a></figcaption></figure><p><strong>What is Variational Auto-Encoder?</strong></p><p>As an example, to generate a face manipulation we need to train 2 autoencorders separately as shown in Figure 2. The problem is that the 2 autoencorders won’t be compatible with each other, this is because their latent spaces represent different features.</p><p>For instance, Decoder A only trained with face A, to solve this, we need an approach to make them encode the same features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*kS3voCzNfq7qyVH18SeQcQ.png" /><figcaption>Figure 2. Training Auto-Encoder <a href="https://www.alanzucconi.com/2018/03/14/understanding-the-technology-behind-deepfakes/">https://www.alanzucconi.com/2018/03/14/understanding-the-technology-behind-deepfakes/</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*VSXbfAa3xYELGmc8PGecGQ.png" /></figure><p>So, the solution is that training them with one endcoer, and sharing it by the networks. As shown in Figure 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*VSXbfAa3xYELGmc8PGecGQ.png" /><figcaption>Figure 3. Generating DeepFake.</figcaption></figure><h3>II Types of f facial manipulations.</h3><p>The most commonly meet facial manipulation types are shown below:</p><h4><em>I Entire Face Synthesis.</em></h4><p>It will synthesis kinds of features and create a definitely new image, here is the example of StyleGAN shown in Figure 4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*h5pNuLGkZhvw2JInshBg7Q.png" /><figcaption>Figure 4. Entire Face Synthesis.</figcaption></figure><h4>II Identity swap.</h4><p>It will swap the face identities of one person to another person shown in Figure 5. This involves the face swap, here usually has two approaches to make it: i) the classical computer graphics-based techniques include FaceSwap 5, ii) the deep learning techniques.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*lp74-PdTug-KmlpFDM_UaA.png" /><figcaption>Figure 5. Identity Swap.</figcaption></figure><h4>III Attribute Manipulation</h4><p>It is commonly known as face editing, includes changing hair color, skin color, and other detailed features. Here is the example shown in Figure 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*ie_MzMVJ3gKhd8iA_2tccg.png" /><figcaption>Figure 6. Attribute Manipulation.</figcaption></figure><h4>IV Expression Swap.</h4><p>The last type means swap one’s expression to another. Here is the example shown in Figure 7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*MISnuFjR6bD40vaqQMNEJw.png" /><figcaption>Figure 7. Expression Swap</figcaption></figure><h3><strong>How to detect?</strong></h3><p>Most algorithms and techniques based on following methods:</p><ol><li>Look for inconsistencies in the video, such as sudden changes in the background or objects that appear and disappear without explanation.</li><li>Check the video’s metadata, which can sometimes contain clues about whether the video has been edited or manipulated.</li><li>Compare the video to other sources to see if the events depicted in the video are consistent with known facts.</li></ol><h3><strong>Cross Efficient Vision Transformer.</strong></h3><p>This is a new algorithm proposed by Davide et al. [1], which achieved an AUC of 0.951 and an F1 score of 88.0%, this is very close to the best result of DFDC shown in Figure 8.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*zj3ICwp7_eIt8y0xlrn7jw.png" /><figcaption>Figure 8. Cross Efficient Vision Transformer win a High Socre in DFDC.</figcaption></figure><p>DFDC is funded by Meta AI and partnered with may industry leaders and academic experts in September 2019. It is stand for Deepfake Detection Challenge, in this challenge consisting of more than 100,000 videos.</p><p>Now back to our topic, this algorithm combined various types of Vision Transformers and used the convolutional EfficientNet B as a feature extractor.</p><h4><strong>Step 1. Extract face from face video using MTCNN</strong></h4><p>This is proposed by Zhang et al. [2], it is a new CNN-based framework for joint face detection and alignment, furthermore, it provides a lightweight CNN architecture for real-time performance.</p><p>This step could be summarized as following stages shown in Figure 9:</p><ol><li>Exploit a CNN called proposal network (P net) to get the facial windows and bounding box regression box, then employ nonmaximal suppression to merge the candidates.</li><li>All the candidate data will be sent another CNN called refine network (R net), this stage will reject false candidates, then perform bounding box regression, and conducts NMS.</li><li>This stage aims to identify face regions with more supervision, especially output five facial landmarks’ position.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMBb63PvXx6_uukK0dnchA.png" /><figcaption>Figure 9. Extract Face.</figcaption></figure><p>The CNN architecture also has been designed to have a better performance, the filter has been changed 5*5 filter to 3*3 to reduce the computing and increase the depth as shown in Figure 10.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCzRwrOJvm9eNioAeKvsUQ.png" /><figcaption>Figure 10. Process of the networks.</figcaption></figure><h4><strong>Step 2. The Efficient ViT and Convolutional Cross ViT</strong></h4><p>What is going on when extracted the facial information?</p><p>When pre-extract the facial data, input them to the 2 architectures and output whether they’re manipulated, trained them in a supervised way to detect the fake samples. Hence, it could be considered as a binary classification problem.</p><p>Efficient ViT consists of 2 blocks, one is convolutional module to perform as a feature extractor, and the other is Transformer Encoder, the latter is like Vision Transformer.</p><p><em>What is Vision Transformer</em>?</p><p>It is proposed by et al. [3] Dosovitskiy, the architecture provides a better performance requiring substantially fewer computational resource. Since Vision Transformer applied directly to sequences of image patches can performa very well on image classification tasks. When pre-trained the large-scale data and transfer them to many medium size image recognition benchmarks, it provides a good performance.</p><p>The overview of the model is illustrated. To process 2D images, reshape the images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*AFSezrURt13eJPoKPJrlow.png" /></figure><p>Into a sequence of flattened 2D patches:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*tojeZGqoqueBzJ8N4j0epA.png" /></figure><p>Here (H, W) is the resolution of image, C is the number of channels, (P, P) means resolution of each image patch, and N= HW/ P­­­­­­­2 means the result of number of patches shown in Figure 11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*h1HDLM_9GHj8WvEidPUARQ.png" /><figcaption>Figure 11. the Architecture of Vision Transformer.</figcaption></figure><p>After recalling Vision Transformer, let’s back to our topic, the EfficientNet processes a visual feature for each chunk from input face. Every chunk is 7*7 pixels. After a linear projection, every feature from each spatial location is further processed by a Vision Transformer.</p><p>The Next Part is using EfficientNet Feature extractor to pre-train weight and initialize the last layers of the network to perform a better extraction as shown in Figure 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ADUWnxMvnrYIgqk18DFElw.png" /><figcaption>Figure 12. The proposed Architecture.</figcaption></figure><p>The Convolutional Cross ViT is based on EfficientNet and multi-scale Transformer architecture. Here are 2 branches in Convolutional Cross ViT, S-branch is designed to process the small-scale patches and L-branch is to perform the Large-scale patches.</p><p>The visual Tokens output by the Transformer encoders from the 2 branches are combined through cross-attention, furthermore, it is allowed to have the directly interaction between the 2 branches.</p><h4><strong>Step 3. Experiments.</strong></h4><p>They conducted some test of Deepfakes, Face2Face, FaceShifter, FaceSwap and NeuralTextures, also test the DFDC datasets which contains 5000 videos.</p><p>During the testing, standard binary cross-entropy loss is used as the objective. Moreover, the network is optimized end-to-end, using an SGD optimizer with a learning rate of 0.01.</p><p>At inference time, they set a real/fake threshold at 0.55, and a new functionality elaborated voting procedure, the scores of every face will be accumulated, once at least one face’s score more than 0.55 the threshold, it will be classified as fake, the process is shown in Figure 13. In additional, a F1-score varies with the number of faces considered at testing time. It showed that at the inference time, when the number of faces more than 30 seems statically useless.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hn3h00ex3xQ2KKtmg3Mkuw.png" /><figcaption>Figure 13. Inference</figcaption></figure><p>The result of the proposed model provides the great performance, especially in AUC and F1-socres as shown in Table 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*rMtnV99GeXiN9rBFBlbkWA.png" /></figure><p>Here is the some code of their proposed model, see more detailed data in <a href="https://github.com/davide-coccomini/Combining-EfficientNet-and-Vision-Transformers-for-Video-Deepfake-Detection">https://github.com/davide-coccomini/Combining-EfficientNet-and-Vision-Transformers-for-Video-Deepfake-Detection</a></p><pre><br>class Transformer(nn.Module):<br>    def __init__(self, dim, depth, heads, dim_head, mlp_dim, dropout = 0.):<br>        super().__init__()<br>        self.layers = nn.ModuleList([])<br>        self.norm = nn.LayerNorm(dim)<br>        for _ in range(depth):<br>            self.layers.append(nn.ModuleList([<br>                PreNorm(dim, Attention(dim, heads = heads, dim_head = dim_head, dropout = dropout)),<br>                PreNorm(dim, FeedForward(dim, mlp_dim, dropout = dropout))<br>            ]))<br><br>    def forward(self, x):<br>        for attn, ff in self.layers:<br>            x = attn(x) + x<br>            x = ff(x) + x<br>        return self.norm(x)<br><br># projecting CLS tokens, in the case that small and large patch tokens have different dimensions<br><br>class ProjectInOut(nn.Module):<br>    def __init__(self, dim_in, dim_out, fn):<br>        super().__init__()<br>        self.fn = fn<br><br>        need_projection = dim_in != dim_out<br>        self.project_in = nn.Linear(dim_in, dim_out) if need_projection else nn.Identity()<br>        self.project_out = nn.Linear(dim_out, dim_in) if need_projection else nn.Identity()<br><br>    def forward(self, x, *args, **kwargs):<br>        x = self.project_in(x)<br>        x = self.fn(x, *args, **kwargs)<br>        x = self.project_out(x)<br>        return x<br><br># cross attention transformer<br><br>class CrossTransformer(nn.Module):<br>    def __init__(self, sm_dim, lg_dim, depth, heads, dim_head, dropout):<br>        super().__init__()<br>        self.layers = nn.ModuleList([])<br>        for _ in range(depth):<br>            self.layers.append(nn.ModuleList([<br>                ProjectInOut(sm_dim, lg_dim, PreNorm(lg_dim, Attention(lg_dim, heads = heads, dim_head = dim_head, dropout = dropout))),<br>                ProjectInOut(lg_dim, sm_dim, PreNorm(sm_dim, Attention(sm_dim, heads = heads, dim_head = dim_head, dropout = dropout)))<br>            ]))<br><br>    def forward(self, sm_tokens, lg_tokens):<br>        (sm_cls, sm_patch_tokens), (lg_cls, lg_patch_tokens) = map(lambda t: (t[:, :1], t[:, 1:]), (sm_tokens, lg_tokens))<br><br>        for sm_attend_lg, lg_attend_sm in self.layers:<br>            sm_cls = sm_attend_lg(sm_cls, context = lg_patch_tokens, kv_include_self = True) + sm_cls<br>            lg_cls = lg_attend_sm(lg_cls, context = sm_patch_tokens, kv_include_self = True) + lg_cls<br><br>        sm_tokens = torch.cat((sm_cls, sm_patch_tokens), dim = 1)<br>        lg_tokens = torch.cat((lg_cls, lg_patch_tokens), dim = 1)<br>        return sm_tokens, lg_tokens<br><br># multi-scale encoder</pre><h3><strong>Conclusion</strong></h3><p>In this article explained what is deepfake, how it works, types of face manipulation, the main ideas to detect them, and one example of a robust algorithm.</p><p>Hope this could help you!</p><p>[1] Coccomini, Davide Alessandro, et al. “Combining efficientnet and vision transformers for video deepfake detection.” <em>International Conference on Image Analysis and Processing</em>. Springer, Cham, 2022.</p><p>[2] Zhang, K., Zhang, Z., Li, Z., Qiao, Y.: Joint face detection and alignment using multitask cascaded convolutional networks. IEEE Signal Processing Letters 23(10), 1499–1503 (2016)</p><p>[3] Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al.: An image is worth 16x16 words: Transformers for image recognition at scale. In: International Conference on Learning Representations (2020)</p><p>[4] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Łukasz Kaiser, and Illia Polosukhin. Attention is all you need. In NIPS, 2017</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=481636e08feb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>