Video detection method and apparatus, device, storage medium, and product
Using machine learning technology to extract features of video clips and combining it with the self-attention mechanism, the probability of authenticity of the video is detected, which solves the problem of low video detection accuracy in the existing technology and improves the accuracy and safety of video detection.
Patent Information
- Application Number
- PCT/CN2023/126646
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2022-11-15
- Filing Date
- 2023-10-26
- Publication Date
- 2024-09-19
AI Technical Summary
Existing video detection methods rely on binary supervision at the video level and are difficult to capture subtle forgery traces at the frame level, resulting in low video detection accuracy.
A video detection method based on machine learning technology is used to extract local features of video clips and obtain global features after fusion processing. It combines the self-attention mechanism and the pre-trained video detection model to detect the authenticity probability of the target object in the video.
It improves the accuracy of video detection and can more effectively identify the authenticity of videos, especially in face recognition systems, enhancing network and social security.
Smart Images

Figure CN2023126646_19092024_PF_FP_ABST
Abstract
Description
Video detection method, device, equipment, storage medium and product
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on November 15, 2022, with application number 202211431856.5 and entitled “Video Detection Methods, Devices, Equipment, Mechanisms and Products,” the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of computers and communications technology, and in particular to a video detection method, a video detection device, an electronic device, a computer-readable storage medium, and a computer program product.
[0003] background
[0004] With the rapid development of computer technology, video editing is becoming increasingly common, but this also poses certain threats to network and social security. For example, video can be forged by replacing the face in each frame of a video to perform facial recognition, posing a threat to the security of facial recognition systems. Therefore, video detection is necessary to ensure network and social security.
[0005] Technical content
[0006] Other features and advantages of the present application will become apparent from the following detailed description, or may be learned in part by practice of the present application.
[0007] According to an embodiment of the present application, a video detection method is provided, which is executed by an electronic device and includes: extracting multiple video clips of a video to be detected; extracting local features corresponding to each video clip based on motion information of a target object in each video clip, wherein the local features are used to characterize the temporal inconsistency of the video clip; fusing the local features corresponding to the multiple video clips to obtain global features of the video to be detected; detecting the authenticity probability of the target object in the video to be detected based on the global features, and obtaining a detection result of the video to be detected based on the authenticity probability.
[0008] According to an embodiment of the present application, a video detection device is also provided, which includes: an extraction module for extracting multiple video clips of a video to be detected; a feature module for extracting local features corresponding to each video clip based on motion information of a target object in each video clip, wherein the local features are used to characterize the temporal inconsistency of the video clips; a fusion module for fusing the multiple local features to obtain global features of the video to be detected; and a detection module for detecting the authenticity probability of the target object in the video to be detected based on the global features, and obtaining a detection result of the video to be detected based on the authenticity probability.
[0009] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising one or more processors; and a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the video detection method as described above.
[0010] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor of an electronic device, the electronic device executes the video detection method as described above.
[0011] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device performs the video detection method as described above.
[0012] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings are incorporated into and constitute a part of the specification, illustrating embodiments consistent with the present application and, together with the specification, serving to explain the principles of the present application. Obviously, the drawings described below are merely some embodiments of the present application, and a person of ordinary skill in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0014] FIG1 is a schematic diagram of an implementation environment involved in this application;
[0015] FIG2 is a flow chart of a video detection method shown in an exemplary embodiment of the present application;
[0016] FIG3 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0017] FIG4 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0018] FIG5 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0019] FIG6 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0020] FIG7 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0021] FIG8 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0022] FIG9 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0023] FIG10 is a flow chart of another video detection method shown in an exemplary embodiment of the present application;
[0024] FIG11 is a flowchart of a video detection method shown in another exemplary embodiment of the present application;
[0025] FIG12 is a flow chart of another video detection method shown in another exemplary embodiment of the present application;
[0026] FIG13 is a framework diagram of a model to be trained shown in another exemplary embodiment of the present application;
[0027] FIG14 is a schematic diagram of motion information extraction shown in another exemplary embodiment of the present application;
[0028] FIG15 is a schematic comparison diagram of a video detection result shown in another exemplary embodiment of the present application;
[0029] FIG16 is a schematic comparison diagram of another video detection result shown in another exemplary embodiment of the present application;
[0030] FIG17 is a structural block diagram of a data processing device shown in an exemplary embodiment of the present application;
[0031] FIG18 shows a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
[0032] Implementation Method
[0033] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. When the following description refers to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0034] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. That is, these functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0035] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, while others may be combined or partially combined. Therefore, the actual execution order may vary depending on the actual situation.
[0036] It should also be noted that the term "plurality" used in this application refers to two or more. "And / or" describes the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.
[0037] The technical solutions of the embodiments of the present application relate to the field of artificial intelligence (AI) technology. Before introducing the technical solutions of the embodiments of the present application, a brief introduction to AI technology is given. AI is a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, AI is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. AI is also about studying the design principles and implementation methods of various intelligent machines, so that machines have the functions of perception, reasoning and decision-making.
[0038] Machine learning (ML) is a multidisciplinary field that encompasses probability theory, statistics, approximation theory, convex analysis, and algorithmic complexity theory. It specifically studies how computers can simulate or implement human learning behaviors to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is at the core of AI and the fundamental way to make computers intelligent. Its applications span all areas of AI. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and learning through demonstration.
[0039] In related technologies, video-based editing detection methods rely solely on binary supervision at the video level to learn and model. Subtle traces of forgery at the frame level are almost impossible to capture, resulting in low video detection accuracy.
[0040] Therefore, the embodiments of the present application provide a video detection method, a video detection device, an electronic device, a computer-readable storage medium, and a computer program product, which can improve the accuracy of video detection.
[0041] The technical solution of the embodiment of the present application specifically relates to machine learning technology in AI, and specifically implements authenticity detection of videos based on machine learning technology. The technical solution of the embodiment of the present application is described in detail below:
[0042] Please refer to Figure 1, which is a schematic diagram of an implementation environment involved in this application. The implementation environment includes a terminal 10 and a server 20, and the terminal 10 and the server 20 communicate with each other via a wired or wireless network.
[0043] Among them, the terminal 10 can be the initiator of video detection, that is, the initiator of the video detection request. For example, it can run an application for video authenticity detection, which is used to perform authenticity detection tasks. Then, the terminal 10 can receive the video to be detected uploaded by the user through the application, and send the video to be detected to the server 20.
[0044] After receiving the video to be detected, the server 20 can perform corresponding video detection processing to obtain a detection result for the video to be detected, including whether the video to be detected is a real video or a fake video. For example, the server 20 can extract multiple video clips of the video to be detected; extract local features corresponding to each video clip based on the motion information of the target object in each video clip, wherein the local features are used to characterize the temporal inconsistency of the video clip; then fuse the local features corresponding to the multiple video clips to obtain the global features of the video to be detected, and finally detect the authenticity probability of the target object in the video to be detected based on the global features to obtain the detection result of the video to be detected. After generating the detection result of the video to be detected, the detection result can be sent to the terminal 10 so that the terminal can perform subsequent processes.
[0045] In some embodiments, the terminal 10 can also independently process the video to be detected. That is, after obtaining the text to be detected, the terminal 10 can extract multiple video clips of the video to be detected, extract the local features corresponding to each video clip based on the motion information of the target object in each video clip, and then fuse the local features corresponding to the multiple video clips to obtain the global features of the video to be detected. Then, the authenticity probability of the target object in the video to be detected is detected based on the global features to obtain the detection result of the video to be detected. After obtaining the detection result of the video to be detected, the detection result can be directly displayed.
[0046] It should be noted that the technical solution of the embodiment of the present application can process various videos to be detected that contain moving objects. For example, it can process videos to be detected that contain faces, and then detect the authenticity of the faces. Taking the community face recognition access control system as an example, the application on the terminal provides a face detection entrance to the object. When the detection is triggered, the terminal can call the camera to collect the video of the face to be detected. The terminal then sends the video of the face to be detected to the server. The server detects whether the face is a real face or a fake face based on the video of the face to be detected, and then obtains the detection result of the video. The server sends the detection result to the terminal, and the terminal determines whether to open the door for the object based on the detection result.
[0047] The aforementioned terminals can be electronic devices such as smart phones, tablets, laptops, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc.; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), big data, intelligent platforms and other basic cloud computing services. This section does not impose any restrictions on this.
[0048] It should be noted that in the specific implementation of this application, the video to be detected and / or the target object involve object-relatedness. When the embodiment of this application is applied to a specific product or technology, it is necessary to obtain the object's permission or consent, and the collection, use and processing of relevant information need to comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0049] The following describes in detail the various implementation details of the technical solutions of the embodiments of the present application:
[0050] As shown in Figure 2, Figure 2 is a flow chart of a video detection method according to an embodiment of the present application. The method can be applied to the implementation environment shown in Figure 1. The method can be executed by an electronic device, which can be a terminal or a server. In some embodiments, the method can be executed by a terminal or a server, or by both a terminal and a server. In the embodiment of the present application, the method is executed by a server as an example. The video detection method can include steps S210 to S240, which are described in detail as follows:
[0051] S210: Extract multiple video clips of the video to be detected.
[0052] In the embodiment of the present application, the video to be detected is a video containing moving objects, including but not limited to people, animals, and movable plants (such as leaves swaying in the wind). The video to be detected has a certain video length and can be divided into multiple video segments. A video segment includes multiple continuous video frames. For example, if the video to be detected is a 1-minute video, the video segment can be 15 seconds.
[0053] In one example, the video to be detected can be obtained from the publisher of the video. For example, if a video is published on a certain video website, the video can be obtained from the video website.
[0054] In one example, the video to be detected may also be shot by the server or the terminal itself.
[0055] In an embodiment of the present application, the process of extracting multiple video segments of the video to be detected can be to divide the video to be detected into multiple video segments at equal intervals, or to randomly divide the video to be detected into multiple video segments, or to divide the video to be detected into multiple segments at equal intervals and then take the middle n frames in each segment to form a video segment, which is not limited here.
[0056] It is worth noting that the video to be detected in the embodiment of the present application may include one video or multiple videos.
[0057] It should be noted that in the specific implementation of this application, the object information obtained involves information related to the object. When the embodiment of this application is applied to a specific product or technology, it is necessary to obtain the object's permission or consent, and the collection, use and processing of relevant object information must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0058] S220 : Extracting local features corresponding to each video segment according to the motion information of the target object in each video segment, where the local features are used to characterize the temporal inconsistency of the video segment.
[0059] It is worth noting that the video to be detected includes a target object, which can be any moving object. After extracting multiple video clips of the video to be detected, each video clip also contains a target object, and the target objects contained in the video clips can be the same or different; for example, a video clip can contain multiple faces.
[0060] Since the target object is movable, the video clip also includes motion information of the target object. The motion information includes but is not limited to the motion direction, motion distance, and changes of the target object.
[0061] In the embodiment of the present application, the differences between the video clips can be determined based on the motion information of the target object in each video clip, and then the local features of the video clips can be extracted based on the differences.
[0062] Local features are used to characterize the temporal inconsistency of video clips, that is, the temporal inconsistency of different video clips due to the movement of the target object. For example, the temporal inconsistency of video clip A is the inconsistency between video clip A and video clip B. Inconsistency refers to the unnatural motion characteristics of the forged part in terms of timing, such as the presence of jitter.
[0063] S230 , fusing the local features corresponding to the multiple video clips to obtain the global features of the video to be detected.
[0064] In an embodiment of the present application, a fusion process is performed on the local features corresponding to the multiple video clips. The fusion process refers to combining the multiple local features so that information can be exchanged between the local features, thereby obtaining the global features of the video to be detected.
[0065] It is worth noting that local features are features at the video segment level, while global features are features at the overall video level obtained based on features at the video segment level.
[0066] S240 , detecting the authenticity probability of the target object in the video to be detected according to the global features, and obtaining a detection result of the video to be detected according to the authenticity probability.
[0067] In an embodiment of the present application, the global feature is a feature at the overall video level obtained based on the local features at the video clip level. Therefore, the authenticity probability of the target object in the video to be detected is detected through the global feature. The authenticity probability of the target object in the video to be detected is detected by combining the video clip level and the overall video level, and then the detection result of the video to be detected is obtained according to the authenticity probability of the target object.
[0068] The authenticity probability of the target object is divided into the probability that the target object is real and the probability that the target object is forged. It is understood that if the target object is real, the video to be tested is also real; if the target object is forged, the video to be tested is also forged. In some embodiments, if the probability that the target object in the video to be tested is forged is greater than a preset probability threshold, the video to be tested is determined to be a forged video. Otherwise, the video to be tested is determined to be real.
[0069] In an embodiment of the present application, after extracting multiple video clips of the video to be detected, local features corresponding to the video clips are extracted based on the motion information of the target object in each video clip, and the local features are used to reflect the essential timing inconsistency at the video clip level, and then the video clips corresponding to the multiple video clips are fused to obtain global features at the video level. On the one hand, the global features can reflect the timing inconsistency at the video clip level, and on the other hand, it can reflect the representation of the video level, and then the authenticity probability of the target object in the video to be detected is detected based on the global features. In this way, the authenticity probability of the target object is detected by combining local details and the global whole to make the detection result more accurate.
[0070] In one embodiment of the present application, another video detection method is provided. The video detection method can be applied to the implementation environment shown in Figure 1 or the implementation environment shown in Figure 2. The method can be executed by a terminal or a server, or can be executed jointly by a terminal and a server. In the embodiment of the present application, the method is executed by a server as an example for illustration. As shown in Figure 3, the video detection method is based on Figure 2, and S220 is expanded to S310~S330.
[0071] Steps S310 to S330 are described in detail as follows:
[0072] S310: Divide the target object into multiple regions according to the motion information of the target object in the video clip.
[0073] In an embodiment of the present application, the motion information of the target object in the video clip can reflect the changes of the target object, and the target object can be divided into multiple areas according to the changes of the target object. For example, when the target object is a human face, the face can be divided into eye area, mouth area and cheek area based on the changes of the eyes, mouth and cheeks in the face; for another example, when the target object is a human face, only the mouth and cheeks in the face have changed, and the mouth can be divided into multiple areas according to the changes of the mouth, and the cheeks can be divided into multiple areas according to the changes of the cheeks.
[0074] S320: Extract features from the video clips, and integrate the extracted features according to the time dimension to obtain multiple temporal convolution features.
[0075] As described above, a video clip contains multiple frames. When extracting features from a video clip, feature extraction can be performed on each frame. Since there are differences in the time dimension between multiple frames, the extracted features can be integrated according to the time dimension to obtain multiple temporal convolution features.
[0076] S330: Obtain local features of the video clip according to the multiple regions and the multiple temporal convolution features.
[0077] In an embodiment of the present application, after obtaining multiple region and multiple temporal convolution features, local features of the video clip can be obtained based on the relationship between the region and temporal convolution features.
[0078] In one example, a temporal convolution feature may be assigned to each region, where the relationship between the temporal convolution feature and the region may be determined based on the temporal convolution feature. For example, the temporal convolution feature is a one-hot vector, and the corresponding region is determined based on the position of "1" in the one-hot vector in the entire vector.
[0079] It should be noted that for other detailed descriptions of steps S210 and S230 to S240 shown in FIG3 , please refer to steps S210 and S230 to S240 shown in FIG2 , which will not be repeated here.
[0080] In an embodiment of the present application, the target object is divided into multiple regions based on the operation information of the target object, that is, the target object is refined, and the features extracted from the video clip are integrated according to the time dimension to obtain temporal convolution features, that is, refined features. Then, the local features of the video clip are guaranteed based on multiple regions and multiple temporal convolution features, which can accurately reflect the essential differences of the video clips.
[0081] An embodiment of the present application provides another video detection method, which can be applied to the implementation environment shown in Figure 1 or the implementation environment shown in Figure 2. The method can be executed by a terminal or a server, or can be executed by a terminal and a server together. In the embodiment of the present application, the method is executed by a server as an example for illustration. As shown in Figure 4, the video detection method is based on the method shown in Figure 2, and expands step S230 shown in Figure 2 to steps S410 to S430.
[0082] Steps S410 to S430 are described in detail as follows:
[0083] S410: Calculate self-attention features between video clips based on local features corresponding to the multiple video clips.
[0084] In an embodiment of the present application, the inter-segment attention mechanism is used to obtain information between video clips, and use the information of one video clip to process the information of another video clip to achieve information interaction between video clips; that is, information is transmitted from video clip A to video clip B, and at the same time, information is also transmitted from video clip B to video clip A.
[0085] The self-attention features between video clips can reflect the information features obtained through information interaction across video clips. The information interaction between local features corresponding to multiple video clips is realized through the inter-segment attention mechanism, and then the self-attention features are calculated.
[0086] S420: Normalize the self-attention features between video clips to obtain initial video features.
[0087] In an embodiment of the present application, the self-attention features between video clips are normalized. For example, the self-attention features between video clips can be normalized through layer-norm to obtain initial video features.
[0088] S430 , mapping the initial video features through an activation function to obtain global features of the video to be detected.
[0089] In an embodiment of the present application, the activation function may be a sigmoid function, which maps the initial video features to between 0 and 1 to obtain the global features of the video to be detected.
[0090] It should be noted that, for the detailed description of steps S210 to S220 and S240 shown in FIG4 , please refer to steps S210 to S220 and S240 shown in FIG2 , which will not be repeated here.
[0091] In an embodiment of the present application, information interaction between video clips is achieved through self-attention features, and the resulting global features can reflect detailed information of local features of multiple video clips. In addition, they can also reflect partial information of the entire video, thereby ensuring the accuracy of subsequent video detection.
[0092] An embodiment of the present application also provides another video detection method, which can be applied to the implementation environment shown in Figure 1 or the implementation environment shown in Figure 2. The method can be executed by a terminal or a server, or can be executed by a terminal and a server together. In an embodiment of the present application, the method is executed by a server as an example for illustration. As shown in Figure 5, the video detection method is based on that shown in Figure 2, and S240 is expanded to S510~S520.
[0093] Steps S510 to S520 are described in detail as follows:
[0094] S510: Input the global features into the fully connected layer of the pre-trained video detection model to perform category discrimination on the global features through the fully connected layer to obtain the authenticity probability of the target object in the video to be detected.
[0095] In an embodiment of the present application, a video detection model is pre-trained, which includes a fully connected layer. The global features are input into the fully connected layer. The fully connected layer can perform category discrimination based on the global features to determine the probability that the target object in the video to be detected to which the global features belong is real, and the probability that the target object is forged. The sum of the probability that the target object is real and the probability that the target object is forged is 1.
[0096] S520: If the probability that the target object in the video to be detected is forged is greater than a preset probability threshold, determine that the video to be detected is a fake video.
[0097] In an embodiment of the present application, if the probability that the target object in the video to be detected is forged is greater than a preset probability threshold, it indicates that the video to be detected is a forged video; if the probability that the target object in the video to be detected is forged is less than the preset probability threshold, it indicates that the video to be detected is a real video.
[0098] The preset probability threshold is a pre-set probability value. The specific probability value can be flexibly adjusted according to the actual situation. In different application scenarios, the preset probability threshold is different. For example, when performing identity recognition for the face of the video to be detected, the preset probability threshold is 98%, and when performing video screening for the video to be detected, the preset probability threshold is 80%.
[0099] It should be noted that for other detailed descriptions of steps S210 to S230 shown in FIG5 , please refer to steps S210 to S230 shown in FIG2 , which will not be repeated here.
[0100] In an embodiment of the present application, global features are input into the fully connected layer of the video detection model, and the authenticity probability of the target object in the video to be detected is calculated in turn. Only when the probability that the target object is forged is greater than a preset probability threshold, the video to be detected is determined to be a fake video, thereby further ensuring the accuracy of the detection results.
[0101] The embodiment of the present application provides another video detection method, which can be applied to the implementation environment shown in Figure 1 or the implementation environment shown in Figure 2. The method can be executed by a terminal or a server, or can be executed by a terminal and a server together. In the embodiment of the present application, the method is executed by a server as an example for explanation. The video detection method includes extracting local features corresponding to each video clip through a video detection model, fusing the local features corresponding to multiple video clips, and detecting the authenticity probability of the target object in the video to be detected based on the global features. As shown in Figure 6, the video detection method includes a model training process and a model application process. The video detection method includes: S610 to S660. Steps S610 to S660 are described in detail as follows:
[0102] S610: Obtain a source real sample video segment of a source real sample video, an anchor sample video segment of an anchor sample video, and a forged sample video segment of a forged sample video.
[0103] In an embodiment of the present application, it is necessary to extract video segments from a source real sample video (also referred to as a first real sample video), an anchor sample video, and a forged sample video, respectively, to obtain a source real sample video segment (also referred to as a first real sample video segment), an anchor sample video segment, and a forged sample video segment. The source real sample video and the anchor sample video are both real sample videos (also referred to as a second real sample video), and the real sample videos include source real sample videos and anchor sample videos with different contents. The source real sample video refers to one type of real sample video, and the anchor sample video refers to another type of real sample video, which is used to distinguish from the source real sample video. For example, the source real sample video is a real sample video of subject A speaking, the forged sample video is a forged sample video of subject A speaking, and the anchor video is a real sample video of subject A singing.
[0104] In one example, the same extraction method is used to extract sample video clips from different sample videos (source real sample video, anchor sample video and forged sample video), for example, the first frame, the middle frame and the last frame of the sample video are extracted to obtain sample video clips.
[0105] S620. Input the source real sample video clip, the anchor sample video clip and the forged sample video clip into the model to be trained, and obtain the source real sample local features of the source real sample video clip, the anchor sample local features of the anchor sample video clip and the forged sample local features of the forged sample video clip respectively.
[0106] In this embodiment of the present application, a source sample video clip, an anchor sample video clip, and a forged sample video clip are input into the training model. The training model then extracts local features from the sample video clips based on the motion information of the target object in each sample video clip. The process of extracting local features from the sample video clips is similar to that of extracting local features from the video clip to be detected, and will not be further described here.
[0107] S630: Construct a local contrast loss based on the comparison results of the local features of the source real sample, the local features of the anchor sample, and the local features of the forged sample.
[0108] As described above, local features are used to represent the temporal inconsistency of video clips. By performing comparative learning on the source real sample local features of the source real sample video clip, the anchor sample local features of the anchor sample video clip, and the forged sample local features of the forged sample video clip, the distance between the source real sample video clip and the anchor sample video clip is adjusted to shorten the distance between the two, and the distance between the anchor sample video clip and the forged sample video clip is adjusted to increase the distance between the two, thereby constructing a local contrast loss, wherein the comparison result can be the distance between the adjusted source real sample video clip and the anchor sample video clip, as well as the distance between the adjusted anchor sample video clip and the forged sample video clip.
[0109] S640: Train a video detection model based on the local contrast loss.
[0110] In this embodiment of the present application, the model parameters of the model to be trained are adjusted based on the local contrast loss. When the loss converges, the model parameters are optimized, and a video detection model is trained. After the model parameters of the model to be trained are adjusted using the local contrast loss, the model to be trained can distinguish which parts of the video clip are forged.
[0111] S650: Extract multiple video clips of the video to be detected.
[0112] S660: extracting local features corresponding to each video clip through a video detection model, fusing local features corresponding to multiple video clips, and detecting the authenticity probability of the target object in the video to be detected based on the global features.
[0113] After extracting video clips from the video to be detected, the multiple video clips are input into the video detection model. The video detection model performs a series of processing on the video clips to obtain the authenticity probability of the target object in the video to be detected. The specific processing details of the video detection model on the video clips are also referred to in the previous embodiment and will not be repeated here.
[0114] In an embodiment of the present application, the model to be trained is trained, and then the authenticity probability of the target object in the video to be detected is detected through the video detection module, so that it can be widely applied to various video detection scenarios; further, the local features of the sample video clip are obtained through the model to be trained, and then the local contrast loss is constructed according to the comparison results of the local features of the source real sample, the local features of the anchor sample and the local features of the forged sample. The local contrast loss allows the video detection model to pay attention to the temporal inconsistency of the video clip level to ensure the accuracy of subsequent video detection.
[0115] The present application provides another video detection method, which can be applied to the implementation environment shown in FIG1 or the implementation environment shown in FIG2. The method can be executed by a terminal or a server, or by both the terminal and the server. In the present application, the method is described as being executed by a server. As shown in FIG7, the video detection method is based on FIG6, and S630 shown in FIG6 is expanded into steps S710 to S720. Steps S710 to S720 are described in detail as follows:
[0116] S710: Construct a local loss function according to the distance between the local features of the source real sample and the local features of the anchor sample, and the distance between the local features of the anchor sample and the local features of the forged sample.
[0117] It is understandable that the local features of the source real sample and the local features of the anchor sample are both from the real sample video. The video clips from the two real sample videos can be regarded as positive pairs, that is, the local features of the source real sample and the local features of the anchor sample are similar. However, the forged video may be forged by part of the target object. Directly considering the source real sample video clip and the forged sample video clip as a negative pair is not very accurate. Therefore, in the embodiment of the present application, the distance between the anchor sample video clip and the forged sample video clip can be adjusted. By adjusting the distance between the local features of the source real sample and the local features of the anchor sample to shorten the distance between the two, and adjusting the distance between the local features of the anchor sample and the local features of the forged sample to increase the distance between the two, a local damage function is constructed.
[0118] In one example, the distance between sample video segments may be calculated using cosine similarity.
[0119] In an embodiment of the present application, while the local loss function brings the real sample video clip closer, it can also adaptively determine whether the video clip from the forged sample video participates in the calculation of the loss function. For example, if the sample video clip from the forged sample video is real, then the sample video clip suppresses the comparison with the sample video clip of the real sample video.
[0120] S720 , performing average processing on the local loss function according to the number of real sample video clips of the real sample video to obtain a local contrast loss.
[0121] As described above, the real sample video includes the source real sample video and the anchor real sample video. If the sample video clip from the forged sample video is real, when constructing the local loss function, the forged sample video of the forged sample video does not participate in the calculation of the loss function. Then, since the loss function is constructed by multiple real sample video clips, it is necessary to calculate the average of the local loss function according to the number of real sample video clips of the real sample video, and then obtain the local contrast loss.
[0122] It should be noted that, for the detailed description of steps S610 to S620 and S640 to S660 shown in FIG. 7 , please refer to steps S610 to S620 and S640 to S660 shown in FIG. 6 , which will not be repeated here.
[0123] In an embodiment of the present application, by adjusting the distance between the local features of the source real sample and the local features of the anchor sample to shorten the distance between the two, and adjusting the distance between the local features of the anchor sample and the local features of the forged sample to increase the distance between the two, the model to be trained can better compare and learn the differences between the real samples and the forged samples. On this basis, the local loss function is processed based on the number of real sample video clips of the real sample video, thereby ensuring that the local contrast loss is more accurate.
[0124] The present application provides another video detection method, which can be applied to the implementation environment shown in FIG1 or the implementation environment shown in FIG2. The method can be executed by a terminal or a server, or by both the terminal and the server. In the present application, the method is described by taking the method executed by the server as an example. As shown in FIG8, the video detection method is based on FIG6, and S620 shown in FIG6 is expanded into steps S810 to S850. Steps S810 to S850 are described in detail as follows:
[0125] S810: Input the sample video segment into the model to be trained to obtain a segment feature vector of the sample video segment generated by the convolutional layer of the model to be trained.
[0126] In an embodiment of the present application, the model to be trained includes a convolutional layer, which may be a 1*1 convolutional layer, for extracting features of the sample video segment and generating a segment feature vector for the sample video segment. Specifically, the source real sample segment, the anchor sample video segment, and the forged sample video segment can be input into the model to be trained, respectively, to obtain, through the convolutional layer, a segment feature vector for the source real sample segment, a segment feature vector for the anchor sample video segment, and a segment feature vector for the forged sample video segment.
[0127] S820 . Divide the segment feature vector according to the channel dimension to obtain a first feature vector.
[0128] In the embodiment of the present application, each segment feature vector is divided into two parts along the channel dimension, namely, a first feature vector and a second feature vector, and the second feature vector is not processed.
[0129] S830. Input the first feature vector into the adaptive pooling layer and two fully connected layers connected in sequence in the model to be trained to generate multiple temporal convolution features.
[0130] In an embodiment of the present application, the module to be trained also includes an adaptive pooling layer connected after the convolution layer, and two fully connected layers after the adaptive pooling layer; the first feature vector is input to the adaptive pooling layer, because the number of input neurons of the subsequent fully connected layer is fixed. If the number of neurons in the previous input does not match, the fully connected layer cannot run, and the first feature vector is pooled to a fixed size through the adaptive pooling layer, which corresponds to the fully connected layer. The two fully connected layers further process the time dimension to generate multiple temporal convolution features.
[0131] S840: Input the first feature vector into the motion extraction layer, the fully connected layer, and the gamma distribution activation layer connected in sequence in the model to be trained, so as to divide the target object in the sample video clip into multiple regions.
[0132] It should be noted that the first eigenvector is processed by two branches respectively, one branch is the adaptive pooling layer and two fully connected layers, and the other branch is the motion extraction layer, fully connected layer and gamma distribution activation layer connected in sequence in the model to be trained. Among them, the first eigenvector is input to the motion extraction layer. The motion extraction layer obtains the motion representation of the sample video clip based on the motion information of each pixel in the adjacent frames of the sample video clip. Then, a multi-dimensional one-hot vector is generated for each pixel position of the sample video clip through the fully connected layer and the gamma distribution activation layer. This vector is used to select the temporal convolution feature of each pixel position. Frames with the same vector can be regarded as belonging to the same region, thereby dividing the target object in the sample video clip into multiple regions.
[0133] Among them, the execution order of steps S830 and S840 can be to execute S830 first and then execute S840, or to execute S840 first and then execute S830, or to execute them simultaneously, which is not limited here.
[0134] S850: Obtain local features of the sample video clip according to the multiple temporal convolution features, the multiple regions, and the first feature vector.
[0135] In an embodiment of the present application, tensor product processing is performed based on multiple temporal convolution features and multiple regions to assign temporal convolution features to each region, and the first feature vector is convolved layer by layer with the assigned temporal convolution features to obtain the temporal inconsistency features of the sample video clip, that is, the local features.
[0136] It can be understood that the source real sample video clip, the anchor sample video clip and the forged sample video clip can obtain their respective corresponding local features through the above S810 to S850 respectively.
[0137] It should be noted that for other detailed descriptions of S610 and S630 to S660 shown in FIG8 , please refer to steps S610 and S630 to S660 shown in FIG6 , which will not be repeated here.
[0138] In the embodiment of the present application, the model to be trained obtains the local features of the sample video clip through two branches to ensure the reliability of the local feature extraction.
[0139] It is worth noting that the embodiment of the present application provides another video detection method, which can be applied to the implementation environment shown in Figure 1 or the implementation environment shown in Figure 2. The method can be executed by a terminal or a server, or by both the terminal and the server. In the embodiment of the present application, the method executed by the server is used as an example for explanation. As shown in Figure 9, the video detection method is based on the method shown in Figure 6, and step S640 is expanded to steps S910 to S930. Steps S910 to S930 are described in detail as follows:
[0140] S910. Input the source real sample local features, anchor sample local features and forged sample local features into the model to be trained to obtain the source real sample global features of the source real sample video, the anchor sample global features of the anchor sample video and the forged sample global features of the forged sample video.
[0141] In an embodiment of the present application, multiple local features of source real samples, multiple local features of anchor samples and multiple local features of forged samples are respectively input into the model to be trained. The model to be trained will fuse the multiple local features of the source real samples to obtain the global features of the source real samples; fuse the multiple local features of the anchor samples to obtain the global features of the anchor samples; and fuse the multiple local features of the forged samples to obtain the global features of the forged samples.
[0142] S920: Construct a global contrast loss based on the comparison results between the global features of the source real sample, the global features of the anchor sample, and the global features of the forged sample.
[0143] As described above, global features represent representations at the video level. By performing comparative learning on the global features of the source real sample, the global features of the anchor sample, and the global features of the forged sample, the distance between the source real sample video and the anchor sample video is adjusted to shorten the distance between the two, and the distance between the anchor sample video and the forged sample video is adjusted to increase the distance between the two, thereby constructing a global contrast loss.
[0144] S930: Obtain a video detection model based on local contrast loss and global contrast loss training.
[0145] In an embodiment of the present application, the local contrast loss represents the comparison result between the real sample video clip and the forged sample video clip, and the global contrast loss represents the comparison result between the real sample video and the forged sample video; the local contrast loss and the global contrast loss are used to reflect the local inconsistency and global inconsistency between the real and fake videos, and then after the training model is trained, the training model can pay attention to the inconsistency between the video clips and form a video-level representation based on the information interaction between local features.
[0146] It should be noted that, for the detailed description of steps S610 to S630 and S650 to S660 shown in FIG9 , please refer to steps S610 to S630 and S650 to S660 shown in FIG6 , which will not be repeated here.
[0147] In an embodiment of the present application, local features of the sample are obtained through the model to be trained, and then a global contrast loss is constructed based on the comparison results between the global features of the source real sample, the global features of the anchor sample and the global features of the forged sample. On the basis of the local contrast loss, the model to be trained is trained in combination with the global contrast loss, so that the video detection model can not only focus on the detailed content at the video clip level, but also focus on the overall content at the video level, thereby ensuring the accuracy of subsequent video detection.
[0148] In an embodiment of the present application, a video detection method is further provided. The method can be applied to the implementation environment shown in FIG1 or the implementation environment shown in FIG2 . The method can be executed by a terminal or a server, or can be executed by both the terminal and the server. In the embodiment of the present application, the method is described by taking the method executed by the server as an example. As shown in FIG10 , the video detection method is based on the method shown in FIG9 , but step S910 is expanded to S1010. Step S1010 is described in detail as follows:
[0149] S1010. Input the sample local features into the self-attention module, normalization layer and activation layer connected in sequence in the model to be trained to obtain the sample global features of the sample video.
[0150] In an embodiment of the present application, the model to be trained includes a self-attention module, a normalization layer connected after the self-attention module, and an activation layer connected after the normalization layer.
[0151] Among them, the self-attention module is used to realize the information interaction between the local features corresponding to multiple video clips, so as to calculate the self-attention features between sample video clips based on multiple sample local features; the self-attention module is an inter-segment self-attention module, and the self-attention features between sample video clips can reflect the information features obtained through information interaction across video clips. The self-attention features have undergone dimensionality reduction and the dimensionality has been increased through the normalization layer and the activation layer to obtain the sample global features of the sample video.
[0152] It should be noted that, for detailed descriptions of steps S610 to S630, S920 to S930, and S650 to S660 shown in FIG10 , please refer to steps S610 to S630, S920 to S930, and S650 to S660 shown in FIG9 , which will not be repeated here.
[0153] The embodiment of the present application obtains the sample global features of the sample video by sequentially connecting the self-attention module, normalization layer and activation layer in the model to be trained, thereby ensuring the reliability of the global features.
[0154] The present application provides another video detection method, which can be applied to the implementation environment shown in FIG1 or the implementation environment shown in FIG2. The method can be executed by a terminal or a server, or by both the terminal and the server. In the present application, the method is described by taking the method executed by the server as an example. As shown in FIG11, the video detection method is based on the method shown in FIG9, and step S920 is expanded to S1110 to S1120. Steps S1110 to S1120 are described in detail as follows:
[0155] S1110. Construct a global loss function based on the distance between the global features of the source real sample and the global features of the anchor sample, and the distance between the global features of the anchor sample and the global features of the forged sample.
[0156] In an embodiment of the present application, the source real sample global features and the anchor sample global features both come from real sample videos, and the source real sample global features and the anchor sample global features are similar. The distance between the source real sample global features and the anchor sample global features is adjusted to shorten the distance between the two. The forged sample global features contain forged parts, and the distance between the anchor sample global features and the forged sample global features needs to be adjusted to increase the distance between the two, thereby constructing a global loss function.
[0157] S1120 , averaging the global loss function according to the number of real sample videos to obtain a global contrast loss.
[0158] In an embodiment of the present application, the real sample video includes a source real sample video and an anchor sample video. The source real sample video includes multiple anchor sample videos. It is necessary to calculate the average of the global loss function according to the number of real sample videos to obtain the global contrast loss.
[0159] It should be noted that, for a detailed introduction of steps S610 to S630, S910, S930, S650 to S660 shown in FIG11 , please refer to steps S610 to S630, S910, S930, S650 to S660 shown in FIG9 , which will not be repeated here.
[0160] In an embodiment of the present application, by adjusting the distance between the global features of the source real sample and the global features of the anchor sample to shorten the distance between the two, and adjusting the distance between the global features of the anchor sample and the local features of the forged sample to increase the distance between the two, the model to be trained can better compare and learn the differences between the real sample video and the forged sample video. On this basis, the global loss function is processed based on the number of real sample videos, thereby ensuring that the global comparison loss is more accurate.
[0161] The present application provides another video detection method, which can be applied to the implementation environment shown in FIG1 or the implementation environment shown in FIG2. The method can be executed by a terminal or a server, or by both the terminal and the server. In the present application, the method is described as being executed by a server. As shown in FIG12, the video detection method is based on S930 shown in FIG9, and S930 is expanded into steps S1210 to S1240. Steps S1210 to S1240 are described in detail as follows:
[0162] S1210. Input the source real sample global features, anchor sample global features and forged sample global features into the model to be trained to obtain the video classification results output by the model to be trained for the source real sample global features, anchor sample global features and forged sample global features.
[0163] In an embodiment of the present application, the global features of the source real sample are input into the model to be trained, and the model to be trained outputs a video classification result based on the global features of the source real sample. The classification result is the probability that the source real sample video is real and the probability that it is forged. Similarly, a video classification result is output for the global features of the anchor sample, and a video classification result is output for the global features of the forged sample.
[0164] In some embodiments, the video classification result can be obtained through the fully connected layer of the model to be trained.
[0165] S1220: Construct a classification loss for the model to be trained based on the video classification result and the expected output result.
[0166] It can be understood that the sample video corresponds to an expected output result, which is the label carried by the sample video. For example, the label carried by the source real sample video is real, and the label carried by the forged sample video is forged. Then, the classification loss of the model to be trained can be constructed based on the probability that the sample video is real, the probability that it is forged, and the expected output result of the sample video.
[0167] S1230. Generate a total loss of the model to be trained based on the local contrast loss, the global contrast loss, and the classification loss.
[0168] In an example of an embodiment of the present application, the sum of the local contrast loss, the global contrast loss and the classification loss can be used as the total loss of the model to be trained.
[0169] In another example of the embodiment of the present application, weight values can be set for local contrast loss and global contrast loss, and a weighted sum of the local contrast loss and the global contrast loss is performed according to the set weight value, and the weighted sum value is added to the classification loss to obtain the total loss of the model to be trained. Among them, the weight value of the local contrast loss and the weight value of the global contrast loss can be flexibly adjusted according to actual conditions. For example, the weight value of the local contrast loss is greater than the weight value of the global contrast loss, the weight value of the local contrast loss is 0.6, and the weight value of the global contrast loss is 0.4.
[0170] S1240. Adjust the model parameters of the model to be trained according to the total loss to obtain a video detection model.
[0171] In some embodiments, when the model parameters of the model to be trained are adjusted according to the total loss, when the total loss converges, the model parameters are optimal, and a video detection model is obtained based on the optimal model parameters.
[0172] It should be noted that, for detailed descriptions of steps S610 to S630, S910 to S920, and S650 to S660 shown in FIG12 , please refer to steps S610 to S630, S910 to S920, and S650 to S660 shown in FIG9 , which will not be repeated here.
[0173] In an embodiment of the present application, based on the local contrast loss and the global contrast loss, a classification loss is constructed so that the detection result output by the model to be trained is close to the expected output result of the sample video, so that the video detection result of the video detection model is more accurate.
[0174] The following describes in detail the implementation details of the technical solution of the embodiment of the present application using a specific application scenario:
[0175] As shown in FIG13 , an embodiment of the present application provides a framework of a model to be trained, which includes an encoder f for mining local inconsistencies, a fusion module h for fusion of video segments, and a fully connected layer for detecting video categories.
[0176] This application takes a sample video containing a face as an example to illustrate the training of the training model.
[0177] Using OpenCV (a cross-platform computer vision and machine learning software library), facial videos were sampled at equal intervals of 150 frames. The open-source face detection algorithm MTCNN (Multi-task convolutional neural network) was then used to delimit the face region. The region centered on this frame was then expanded 1.2 times and cropped to encompass the entire face and part of the surrounding background. If multiple faces were detected in the same frame, all faces were saved to form a training sample set. Based on a mini-batch approach, small batches of samples were selected from the training sample set, with a batch size of 12. U = 4 video snippets, each containing T = 4 frames, were extracted as sample data for the training model.
[0178] From the original real sample video set N + Video (Contains U sampled snippets, each of size T×3×H×W), where T is the number of frames, H is the height, and W is the width. Its anchor video is defined as other real sample videos (N a represents the set of these anchor videos). In addition, the forged sample videos and the corresponding sets are and N - Similarly, for the real sample video Define its anchor and forge snippet as and
[0179] In an embodiment of the present application, the encoder includes a regional inconsistency module (RAIM), which is used to mine the temporal inconsistency features of different facial regions. As shown in Figure 14, the face is adaptively divided into r regions through the right branch (PWM-Conv-Gamble-Softmax). The r region-independent temporal convolutions are learned through the left branch (AdaP-FC-FC). Based on these two branches, each facial region receives the corresponding temporal convolution and the corresponding temporal inconsistency, which can be obtained through the convolution operation.
[0180] Specific, real sample video clips Through the 1*1 convolution layer in the encoder, the segment feature vector I∈R is obtained C×T×H×W , where C is the number of channels, and it is divided into two parts along the channel dimension X1∈R αC×T×H×W , X2∈R (1-α)C×T×H×W. Among them, X1 is used to extract regional inconsistencies, and X2 remains unprocessed. In the left branch, X1 is first obtained by adaptive pooling operation (AdaP) p ∈R αC×T×r Then the two fully connected layers FC1 and FC2 further process the time dimension to generate r temporal convolution features with a kernel size of k: [W1,W2,…,W r ]=FC2(ReLU(FC1(AdaP(X1)))) (1)
[0181] Where W i ∈R αC×k Represents the learned temporal convolutional features.
[0182] In the right branch, X1 first passes through the motion extraction layer (PWM) to extract the motion information at the pixel. As shown in Figure 14, the motion information extraction includes calculating the pixel points and the difference between two adjacent frames in different frames.
[0183] Among them, C t-1 , C t and C t+1 represents a 3×3 area centered on p0, point p0+p represents the surrounding pixels of the current pixel p0, w p Represents the weight at the point p0+p, PWM(X p0 ) represents the representation of the motion information of p0.
[0184] Based on this representation, an r-dimensional one-hot vector is generated for each position through a 1×1 convolution and a gamble softmax operation. This vector is used to select the temporal convolution at each position. Positions with the same vector can be considered to belong to the same region to obtain multiple regions.
[0185] The multiple temporal convolution features of the left branch and the multiple regions of the right branch are subjected to tensor product operations to obtain the temporal convolution assigned to the region. Finally, X1 is convolved layer by layer with the assigned temporal convolution to obtain the temporal inconsistency feature of the snippet.
[0186] For each real sample video clip Anchor sample video clips and fake sample video clips The temporal inconsistency feature, namely the aforementioned local feature, is obtained.
[0187] In an embodiment of the present application, RAIM is inserted before the second convolution of each resnet block in the resnet network, and the entire encoder f is obtained by combining the resnet network. As shown in Figure 14, RAIM is inserted before the second convolution (i.e., the 3*3 convolution layer) of each resnet block.
[0188] In the embodiment of the present application, a weighted NCE (noise contrastive estimation) loss function is constructed based on the local features of the sample video clip, as shown in formula (3).
[0189] where g l (·):R C →R 128 Is a mapping header, as well as φ(x,y) represents the cosine similarity between l2-normalized vectors. τ and β are the temperature coefficient and adjustable factor, respectively. The temperature coefficient is used to control the model's ability to distinguish forged sample video clips. β Dynamically decide whether snippets from fake videos participate in the loss function calculation That is, if the snippet from the fake video is real / fake, this term will be approximately 0 / 1, so it suppresses / activates the contrast between the snippet and the real video.
[0190] The local contrast loss is defined as:
[0191] Where N = |N + |·U and|N + | represents the true video set N + The number of videos in the video.
[0192] Based on the above process, local inconsistencies in video clips can be represented, and clips from real and fake videos can be compared; then, a video-level representation of the sample video, i.e., global features, can be obtained through a fusion module based on the local features of the video clips.
[0193] Multiple real sample video clips The local features of the input to the fusion module, through the fusion module to promote f(S i )∈R U×C′×T×H′×W′ For the convenience of description, the information interaction between i ) represents the local features of the video clip, through Represents multiple real sample video clips local features.
[0194] Among them, the fusion module includes the self-attention module, combined with the self-attention module in Figure 13, the inter-segment attention For real sample videos, Among them, W Q 、W K and W V Same, both are W I , is a learnable parameter used for dimensionality reduction
[0195] According to formula (5), we can get and Self-attention features.
[0196] Then Atten is used to weight the channels of f(V): h(f(V))=σ(Norm(Atten)W O )·f(V)(6)
[0197] Where W O Learnable parameters used for dimensionality increase. Norm(·) and σ are the layer-norm and sigmoid functions, respectively.
[0198] Formula (6) is the representation at the video level, that is, the global features of the sample video.
[0199] Furthermore, representations from real and fake videos can be compared:
[0200] where g g (·):R C →R 128 Is a mapping header, as well as φ(x,y) represents the cosine similarity between l2-normalized vectors. τ represents the temperature coefficient.
[0201] The video-level contrast loss can be written as:
[0202] in,
[0203] In the embodiment of the present application, after obtaining the global features of the video level of the sample video clip, the global features are input into the fully connected layer FC for category discrimination. The loss function of the fully connected layer can use the binary cross entropy loss L ce .
[0204] Then the total loss of the entire model to be trained is L = L ce+λ1L1+λ2L2. λ1 and λ2 are balance factors to adjust different items.
[0205] It is worth noting that the contrastive learning mapping heads in local contrastive loss and global contrastive loss are not used during model inference.
[0206] In some embodiments, the encoder uses a ResNet-50 backbone network, and the weights are pre-trained on ImageNet; and during training, the size of each input image frame is adjusted to 224×224. The Adam optimization algorithm is used to optimize the network with binary cross entropy loss and train for 60 cycles. In the cross-dataset generalization experiment, 45 cycles are trained. The initial learning rate is 10 -4 And it decreases by one tenth every 10 cycles. During training, only horizontal flipping is used for data expansion.
[0207] The pre-trained model is trained using the above process to obtain a video detection model. During the application of the video detection model, U = 8 snippets, each containing T = 4 frames, are sampled for testing. A test video is first divided into 8 equally spaced segments, and the middle 4 frames of each segment are taken to form the test video input. This is then fed into the pre-trained model and a probability value is obtained, indicating the probability that the video is face-edited (a higher probability value indicates a higher probability that the face in the video has been edited).
[0208] As shown in Figure 15, Figure 15 is the output feature visualization result, and the output of the network is visualized to show the model's area of interest. The forgery mask in the second row comes from the difference between the forged video and the original video, that is, the white highlight in the second row is the difference between the forged video and the real video. For the forgery type Deepfake (face forgery) generated by deep learning tools, as shown in (a) in Figure 15, the activation map of the network almost covers the entire face area. Similarly, as shown in (c) in Figure 15, the face-swapping part of the FaceSwap (face-swapping forgery) type is focused on through the embodiment of the present application. As shown in (b) and (d) in Figure 15, on the more challenging Face2Face (expression forgery) and NeuralTextures (mouth forgery), the forged local area can still be located.
[0209] The embodiment of the present application provides a method that aims to adaptively capture dynamic local representations for local contrast inconsistency learning. Here it is compared with ordinary temporal convolution and the corresponding attention map is visualized, as shown in Figure 16. The weights of ordinary temporal convolution are content-independent and treat all facial regions equally, so it is easy to focus on incomplete forged areas (the left part of the second row in (a) in Figure 16) or wrong areas (the right part of the second row in (a) in Figure 16). On the contrary, in the left and right parts of the third row in (a) in Figure 16, the embodiment of the present application generates region-specific temporal convolution to extract dynamic temporal information, so that a more complete temporal inconsistency representation can be used to identify forgeries, making the identification of forged areas more accurate.
[0210] Hierarchical contrast, at the snippet and video levels, brings positive samples closer together while increasing the distance between negative samples. To visually demonstrate its impact, Figure 16(b) directly illustrates its effect on network activation. From the left and right parts of the third row in Figure 16(b), we can see that for small forged areas, the hierarchical contrast loss acts as a regularizer, allowing the video detection model to focus on more precise locations. Furthermore, for large forged areas, it guides the model to focus on more comprehensive forged locations.
[0211] The device embodiment of the present application is introduced, which can be used to perform the video detection method in the above embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the embodiment of the video detection method in the above embodiment of the present application.
[0212] The embodiment of the present application provides a video detection device, as shown in FIG17 . The video detection device can be configured in a terminal or a server, and the device includes:
[0213] Extraction module 1710, used to extract multiple video segments of the video to be detected;
[0214] A feature module 1720 is configured to extract local features corresponding to each video segment based on motion information of the target object in each video segment, wherein the local features are used to characterize temporal inconsistencies of the video segments;
[0215] A fusion module 1730 is used to fuse multiple local features to obtain a global feature of the video to be detected;
[0216] The detection module 1740 is used to detect the authenticity probability of the target object in the video to be detected based on the global features to obtain the detection result of the video to be detected.
[0217] In one embodiment of the present application, based on the aforementioned scheme, the feature module 1720 is further used to divide the target object into multiple regions according to the motion information of the target object in the video clip; extract features from the video clip, and integrate the extracted features according to the time dimension to obtain multiple temporal convolution features; obtain local features of the video clip based on the multiple regions and the multiple temporal convolution features.
[0218] In one embodiment of the present application, based on the aforementioned scheme, the fusion model 1730 includes calculating the self-attention features between video clips according to the local features corresponding to multiple video clips; normalizing the self-attention features between video clips to obtain initial video features; and mapping the initial video features through an activation function to obtain the global features of the video to be detected.
[0219] In one embodiment of the present application, based on the aforementioned scheme, the detection module 1740 is further used to input the global features into the fully connected layer of a pre-trained video detection model, so as to perform category discrimination on the global features through the fully connected layer to obtain the authenticity probability of the target object in the video to be detected; if the probability that the target object in the video to be detected is forged is greater than a preset probability threshold, the video to be detected is determined to be a fake video.
[0220] In one embodiment of the present application, based on the aforementioned scheme, local features corresponding to each video clip are extracted through a video detection model, and the local features corresponding to multiple video clips are fused, and the authenticity probability of the target object in the video to be detected is detected according to the global features. The device also includes a training module for obtaining a first real sample video clip of a first real sample video, an anchor sample video clip of an anchor sample video, and a fake sample video clip of a fake sample video; the first real sample video and the anchor sample video belong to a second real sample video containing different content; the first real sample video clip, the anchor sample video clip and the fake sample video clip are input into the model to be trained, and the first real sample local features of the first real sample video clip, the anchor sample local features of the anchor sample video clip and the fake sample local features of the fake sample video clip are respectively obtained; according to the comparison results of the first real sample local features, the anchor sample local features and the fake sample local features, a local contrast loss is constructed; and training is performed according to the local contrast loss to obtain a video detection model.
[0221] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to construct a local loss function based on the distance between the local features of the first real sample and the local features of the anchor sample, and the distance between the local features of the anchor sample and the local features of the forged sample; and the local loss function is averaged according to the number of real sample video clips corresponding to the second real sample video to obtain the local contrast loss.
[0222] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to input the first real sample video clip, the anchor sample video clip and the forged sample video clip into the model to be trained to obtain the segment feature vectors corresponding to the first real sample video clip, the anchor sample video clip and the forged sample video clip respectively generated by the convolutional layer of the model to be trained; the segment feature vector is divided according to the channel dimension to obtain a first feature vector; the first feature vector is input to the adaptive pooling layer and two fully connected layers connected in sequence in the model to be trained to generate multiple temporal convolution features; the first feature vector is input to the motion extraction layer, the fully connected layer and the gamma distribution activation layer connected in sequence in the model to be trained to divide the target objects in the first real sample video clip, the anchor sample video clip and the forged sample video clip into multiple regions; the local features corresponding to the first real sample video clip, the anchor sample video clip and the forged sample video clip respectively are obtained according to the multiple temporal convolution features and the multiple regions, and the first feature vector.
[0223] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to input the first real sample local features, the anchor sample local features and the forged sample local features into the model to be trained to obtain the first real sample global features of the first real sample video, the anchor sample global features of the anchor sample video and the forged sample global features of the forged sample video; construct a global contrast loss based on the comparison results between the first real sample global features, the anchor sample global features and the forged sample global features; and obtain a video detection model through training based on the local contrast loss and the global contrast loss.
[0224] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to input the first real sample local features, the anchor sample local features and the forged sample local features into the self-attention module, normalization layer and activation layer connected in sequence in the model to be trained to obtain the sample global features of the sample video.
[0225] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to construct a global loss function based on the distance between the global features of the first real sample and the global features of the anchor sample, and the distance between the global features of the anchor sample and the global features of the forged sample; and the global loss function is averaged according to the number of the second real sample videos to obtain the global contrast loss.
[0226] In one embodiment of the present application, based on the aforementioned scheme, the training module is further used to input the first real sample global feature, the anchor sample global feature and the forged sample global feature into the model to be trained to obtain the video classification result output by the model to be trained for the first real sample global feature, the anchor sample global feature and the forged sample global feature; construct the classification loss of the model to be trained based on the video classification result and the expected output result; generate the total loss of the model to be trained based on the local contrast loss, the global contrast loss and the classification loss; adjust the model parameters of the model to be trained based on the total loss to obtain a video detection model.
[0227] It should be noted that the apparatus provided in the above embodiment and the method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.
[0228] An embodiment of the present application also provides an electronic device, comprising one or more processors and a storage device, wherein the storage device is used to store one or more computer programs. When the one or more computer programs are executed by one or more processors, the electronic device implements the above video detection method.
[0229] FIG18 shows a schematic structural diagram of a computer system suitable for implementing an electronic device according to an embodiment of the present application.
[0230] It should be noted that the computer system 1800 of the electronic device shown in FIG18 is merely an example and should not impose any limitations on the functions and scope of use of the embodiments of the present application, wherein the electronic device may be a terminal or a server.
[0231] As shown in Figure 18, computer system 1800 includes a processor (Central Processing Unit, CPU) 1801, which can perform various appropriate actions and processes according to the program stored in read-only memory (Read-Only Memory, ROM) 1802 or the program loaded from storage part 1808 into random access memory (Random Access Memory, RAM) 1803, such as executing the method in the above embodiment. Various programs and data required for system operation are also stored in RAM 1803. CPU 1801, ROM 1802 and RAM 1803 are connected to each other via bus 1804. Input / output (I / O) interface 1805 is also connected to bus 1804.
[0232] In some embodiments, the following components are connected to the I / O interface 1805: an input section 1806 including a keyboard, a mouse, and the like; an output section 1807 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 1808 including a hard disk; and a communication section 1809 including a network interface card such as a LAN (Local Area Network) card or a modem. The communication section 1809 performs communication processing via a network such as the Internet. A drive 1810 is also connected to the I / O interface 1805 as needed. Removable media 1811, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 1810 as needed, so that computer programs read therefrom can be installed into the storage section 1808 as needed.
[0233] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1809, and / or installed from a removable medium 1811. When the computer program is executed by the processor (CPU) 1801, the various functions defined in the system of the present application are executed.
[0234] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (Erasable Programmable Read Only Memory), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. A computer program embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wired, or any suitable combination thereof.
[0235] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, program segment, or part of the code, and the above-mentioned module, program segment, or part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and a computer program.
[0236] The units or modules described in the embodiments of the present application may be implemented in software or hardware, and the units or modules described may also be provided in a processor. The names of these units or modules do not, in certain circumstances, limit the units or modules themselves.
[0237] Another aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above. The computer-readable storage medium may be included in the electronic device described in the above embodiments, or may exist independently and not be incorporated into the electronic device.
[0238] Another aspect of the present application further provides a computer program product, the computer program product including a computer program stored in a computer-readable storage medium. A processor of an electronic device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the electronic device to perform the methods provided in the above-mentioned embodiments.
[0239] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the application, the features and functions of two or more modules or units described above can be concretized in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be concretized.
[0240] Other embodiments of the present invention will readily occur to those skilled in the art after considering the specification and practicing the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention that follow the general principles of this application and include common knowledge or customary techniques in the art that are not disclosed herein.
[0241] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. Ordinary technicians in this field can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A video detection method, performed by an electronic device, comprising: Extracting multiple video clips of the video to be detected; Extracting local features corresponding to each video segment according to motion information of the target object in each video segment, wherein the local features are used to characterize the temporal inconsistency of the video segment; Performing fusion processing on the local features respectively corresponding to the multiple video clips to obtain the global features of the video to be detected; The authenticity probability of the target object in the video to be detected is detected according to the global feature, and the detection result of the video to be detected is obtained according to the authenticity probability.
2. The method according to claim 1, wherein: The extracting of local features corresponding to each video segment according to the motion information of the target object in each video segment includes: Dividing the target object into a plurality of regions according to motion information of the target object in the video clip; Extracting features from the video clips, and integrating the extracted features according to a time dimension to obtain a plurality of temporal convolutional features; The local features of the video clip are obtained according to the multiple regions and the multiple temporal convolution features.
3. The method according to claim 1, wherein: The fusing the local features respectively corresponding to the multiple video clips to obtain the global features of the video to be detected includes: Calculating self-attention features between the video clips according to the local features respectively corresponding to the multiple video clips; Normalizing the self-attention features between the video clips to obtain initial video features; The initial video features are mapped through an activation function to obtain the global features of the video to be detected.
4. The method according to claim 1, wherein: Detecting the authenticity probability of the target object in the video to be detected according to the global feature, and obtaining the detection result of the video to be detected according to the authenticity probability, includes: Inputting the global features into a fully connected layer of a pre-trained video detection model, so as to classify the global features through the fully connected layer and obtain the authenticity probability of the target object in the video to be detected; If the probability that the target object in the video to be detected is forged is greater than a preset probability threshold, the video to be detected is determined to be a fake video.
5. The method according to any one of claims 1 to 4, wherein: Extracting local features corresponding to each video clip through a video detection model, fusing the local features corresponding to the multiple video clips, and detecting the authenticity probability of the target object in the video to be detected according to the global features; The video detection model is trained in the following way: Obtaining a first real sample video segment of a first real sample video, an anchor sample video segment of an anchor sample video, and a fake sample video segment of a fake sample video; the first real sample video and the anchor sample video belong to a second real sample video containing different contents; Inputting the first real sample video clip, the anchor sample video clip and the forged sample video clip into the to-be-trained model, and obtaining first real sample local features of the first real sample video clip, anchor sample local features of the anchor sample video clip and forged sample local features of the forged sample video clip respectively; Constructing a local contrast loss according to a comparison result of the first real sample local feature, the anchor sample local feature, and the forged sample local feature; The video detection model is obtained by training according to the local contrast loss.
6. The method according to claim 5, wherein: The constructing a local contrast loss according to the comparison result of the first real sample local feature, the anchor sample local feature and the forged sample local feature comprises: Constructing a local loss function according to the distance between the first real sample local feature and the anchor sample local feature, and the distance between the anchor sample local feature and the forged sample local feature; According to the number of real sample video segments corresponding to the second real sample video, the local loss function is averaged to obtain the local contrast loss.
7. The method according to claim 5, wherein: The step of inputting the first real sample video segment, the anchor sample video segment, and the forged sample video segment into the to-be-trained model to respectively obtain a first real sample local feature of the first real sample video segment, an anchor sample local feature of the anchor sample video segment, and a forged sample local feature of the forged sample video segment, comprises: The first real sample video segment, the anchor sample video segment and the forged sample video segment are input into the training sample video segment. In the training model, the segment feature vectors corresponding to the first real sample video segment, the anchor sample video segment and the forged sample video segment respectively are obtained, which are generated by the convolution layer of the model to be trained; Dividing the segment feature vector according to the channel dimension to obtain a first feature vector; Inputting the first feature vector into the adaptive pooling layer and two fully connected layers connected in sequence in the to-be-trained model to generate a plurality of temporal convolutional features; Inputting the first feature vector into a motion extraction layer, a fully connected layer, and an activation layer of a gamma distribution that are sequentially connected in the to-be-trained model to divide the target object in the first real sample video segment, the anchor sample video segment, and the forged sample video segment into a plurality of regions; Local features corresponding to the first real sample video segment, the anchor sample video segment, and the forged sample video segment are obtained according to the multiple temporal convolution features, the multiple regions, and the first feature vector.
8. The method according to claim 5, wherein: The step of obtaining the video detection model according to the local contrast loss training includes: Inputting the first real sample local feature, the anchor sample local feature and the forged sample local feature into the to-be-trained model to obtain the first real sample global feature of the first real sample video, the anchor sample global feature of the anchor sample video and the forged sample global feature of the forged sample video; constructing a global contrast loss according to a comparison result between the first real sample global feature, the anchor sample global feature, and the forged sample global feature; The video detection model is obtained by training according to the local contrast loss and the global contrast loss.
9. The method according to claim 8, wherein: Inputting the first real sample local feature, the anchor sample local feature and the forged sample local feature into the to-be-trained model to obtain the first real sample global feature of the first real sample video, the anchor sample global feature of the anchor sample video and the forged sample global feature of the forged sample video, including: The first real sample local feature, the anchor sample local feature and the forged sample local feature are input into the self-attention module, the normalization layer and the activation layer connected in sequence in the model to be trained to obtain the sample global feature of the sample video.
10. The method according to claim 8, wherein: The constructing a global contrast loss according to the comparison result between the first real sample global feature, the anchor sample global feature and the forged sample global feature comprises: Constructing a global loss function according to the distance between the first real sample global feature and the anchor sample global feature, and the distance between the anchor sample global feature and the forged sample global feature; According to the number of the second real sample videos, the global loss function is averaged to obtain the global contrast loss.
11. The method according to claim 8, wherein: The training according to the local contrast loss and the global contrast loss to obtain the video detection model includes: Inputting the first real sample global feature, the anchor sample global feature, and the forged sample global feature into the to-be-trained model to obtain a video classification result output by the to-be-trained model for the first real sample global feature, the anchor sample global feature, and the forged sample global feature; Constructing the classification loss of the model to be trained according to the video classification result and the expected output result; Generate a total loss of the model to be trained according to the local contrast loss, the global contrast loss and the classification loss; The model parameters of the model to be trained are adjusted according to the total loss to obtain the video detection model.
12. A video detection device, comprising: An extraction module, used for extracting multiple video clips of the video to be detected; A feature module, used to extract local features corresponding to each video segment according to motion information of the target object in each video segment, wherein the local features are used to characterize the temporal inconsistency of the video segment; A fusion module, used for fusing the plurality of local features to obtain the global features of the video to be detected; The detection module is used to detect the authenticity probability of the target object in the video to be detected according to the global feature, and obtain the detection result of the video to be detected according to the authenticity probability.
13. The device according to claim 12, wherein: The feature module is further used to divide the target object into multiple regions according to the motion information of the target object in the video clip; extract features from the video clip and integrate the extracted features according to the time dimension to obtain multiple temporal convolution features; and obtain local features of the video clip according to the multiple regions and the multiple temporal convolution features.
14. The device according to claim 12, wherein: The fusion model is used to calculate the self-attention features between the video clips according to the local features respectively corresponding to the multiple video clips; Normalizing the self-attention features between the video clips to obtain initial video features; mapping the initial video features through an activation function to obtain global features of the video to be detected.
15. The device according to claim 12, wherein: The detection module is further used to input the global features into the fully connected layer of a pre-trained video detection model, so as to perform category discrimination on the global features through the fully connected layer to obtain the authenticity probability of the target object in the video to be detected; if the probability that the target object in the video to be detected is forged is greater than a preset probability threshold, the video to be detected is determined to be a fake video.
16. The device according to any one of claims 12 to 15, wherein: Extracting local features corresponding to each video clip through a video detection model, fusing the local features corresponding to the multiple video clips, and detecting the authenticity probability of the target object in the video to be detected according to the global features, the device also includes a training module, obtaining a first real sample video clip of a first real sample video, an anchor sample video clip of an anchor sample video, and a forged sample video clip of a forged sample video; The first real sample video and the anchor sample video belong to a second real sample video containing different contents; the first real sample video clip, the anchor sample video clip and the forged sample video clip are input into the model to be trained, and the first real sample local features of the first real sample video clip, the anchor sample local features of the anchor sample video clip and the forged sample local features of the forged sample video clip are respectively obtained; according to the comparison results of the first real sample local features, the anchor sample local features and the forged sample local features, a local contrast loss is constructed; and training is performed according to the local contrast loss to obtain the video detection model.
17. The apparatus according to claim 16, wherein the training module is further used to construct a local loss function according to the distance between the first real sample local feature and the anchor sample local feature, and the distance between the anchor sample local feature and the forged sample local feature; According to the number of real sample video segments corresponding to the second real sample video, the local loss function is averaged to obtain the local contrast loss.
18. An electronic device, comprising: one or more processors; A storage device for storing one or more programs, which, when executed by the one or more processors, enables the electronic device to execute the method described in any one of claims 1 to 11.
19. A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor of an electronic device, enables the electronic device to execute the method according to any one of claims 1 to 11.
20. A computer program product, comprising a computer program, wherein the computer program is stored in a computer-readable storage medium, and a processor of an electronic device reads and executes the computer program from the computer-readable storage medium, so that the electronic device executes the method according to any one of claims 1 to 11.
