Video defect detection method and device, electronic equipment and storage medium
Through the shallow feature map and deep feature map detection method of video frames, combined with the attention mechanism, the problems of low efficiency and poor accuracy in video defect detection are solved, efficient and accurate defect identification and repair are achieved, and the video quality is improved. .
Patent Information
- Application Number
- CN202410658844.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-24
AI Technical Summary
The existing technology has low efficiency, poor accuracy, and high false detection rate in video defect detection, making it difficult to effectively identify and repair defects in videos, especially when there is no original video reference.
The detection method based on shallow feature maps and deep feature maps of video frames is used to detect and repair defects in video frames by extracting multi-scale features and introducing an attention mechanism to predict defect areas and evaluate the severity of defects.
It improves the efficiency and accuracy of video defect detection, reduces the false detection rate, can identify defective areas at the pixel level, supports efficient detection and repair of video media, and improves the audience's viewing experience.
Smart Images

Figure CN118570698A
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a video defect detection method and device, an electronic device, and a storage medium. Background Art
[0002] In modern multimedia communications, video has become one of the main carriers of information dissemination. However, in the process of video encoding, transcoding, transmission and decoding, various factors such as equipment performance and network conditions may cause various defects in the video, such as screen distortion, ghosting, and drawing. In addition, old films are often stored on film. During long-term storage, due to physical and chemical changes and environmental factors, various damages such as dirty spots and scratches are inevitable, which seriously affect the artistic expression and viewing quality of the film.
[0003] Video defect detection is the process of detecting defects in a video without the reference of the original video. These defects usually significantly reduce the quality of the video and seriously affect the user's viewing experience. Therefore, various video platforms need to conduct an overall assessment of the video media provided by the film company to determine the overall quality of the video, whether there are obvious defects, etc., and ultimately decide whether to accept the video media or produce ultra-high-definition video, or repair defective videos, such as repairing the video media of old films.
[0004] At present, the detection of video defects in the media production quality control system (also known as control work) mainly relies on manual viewing of a large number of video clips to make decisions, identify and mark various defects in the video frames. This process often takes a lot of time and is inefficient. On the other hand, manual evaluation mostly gives the overall viewing experience of the video, which is easily affected by subjective factors. Various defects are distributed irregularly in the picture and appear at random times. Some serious defective clips may be missed, resulting in low detection accuracy and high false detection rate. Summary of the invention
[0005] In view of this, the present disclosure proposes a video defect detection method and device, an electronic device and a storage medium, which can improve the efficiency and accuracy of video defect detection and reduce the false detection rate of video defect detection.
[0006] According to one aspect of the present disclosure, a video defect detection method is provided, including: obtaining a video frame of a video to be detected; extracting a shallow feature map and a deep feature map of the video frame; determining a defect map corresponding to the video frame based on the shallow feature map and the deep feature map, the defect map representing a defect area where a defect in the video frame is predicted to be located; determining a defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map and the defect map, the defect detection result being used to indicate whether the video frame has a defect.
[0007] In a possible implementation, extracting the shallow feature map and the deep feature map of the video frame includes: dividing the video frame into multiple image blocks; inputting the multiple image blocks into a converter module to obtain a multi-scale feature map extracted by N layers of converter units in the converter module, wherein a first scale feature map extracted by a first layer of converter units is used as the shallow feature map, and N is a positive integer; fusing the second scale feature map to the Nth scale feature map output by the second layer of converter units to the Nth layer of converter units in the converter module to obtain a first fused feature map; and determining the deep feature map based on the first fused feature map.
[0008] In a possible implementation, determining the deep feature map based on the first fused feature map includes: performing dimensionality reduction processing on the first fused feature map to obtain a second fused feature map; performing self-attention extraction processing on the second fused feature map using multiple window attention mechanisms to obtain multiple self-attention feature maps, wherein the window sizes used to extract self-attention in different window attention mechanisms are different; performing pooling processing on the second fused feature map to obtain a pooling feature map; performing channel splicing on the second fused feature map, the multiple self-attention feature maps and the pooling feature map to obtain a first spliced feature map; performing dimensionality reduction processing on the first spliced feature map to obtain the deep feature map.
[0009] In a possible implementation, determining the defect map corresponding to the video frame according to the shallow feature map and the deep feature map includes: performing dimensionality reduction processing on the shallow feature map to obtain a first shallow feature map; based on the resolution of the first shallow feature map, upsampling the deep feature map to obtain a first deep feature map, the first deep feature map and the first shallow feature map having the same resolution; channel-splicing the first shallow feature map and the first deep feature map to obtain a second spliced feature map; performing dimensionality reduction processing on the second spliced feature map to obtain a defect map; and based on the original resolution of the video frame, upsampling the defect map to obtain a target defect map that matches the original resolution of the video frame.
[0010] In a possible implementation, the defect detection result corresponding to the video frame is determined according to the shallow feature map, the deep feature map and the defect map, including: performing feature extraction on the shallow feature map to obtain a second deep feature map, and performing dimensionality reduction processing on the second deep feature map to obtain a first intermediate feature map; based on the resolution of the shallow feature map, upsampling the first intermediate feature map to obtain a second intermediate feature map, and the second intermediate feature map has the same resolution as the shallow feature map; performing dimensionality reduction processing on the shallow feature map, the first deep feature map and the defect map respectively to obtain a second shallow feature map, a third deep feature map and a first defect map; performing channel stitching on the second intermediate feature map, the second shallow feature map, the third deep feature map and the first defect map to obtain a third stitching feature map; performing dimensionality reduction processing on the third stitching feature map to obtain a defect confidence, and the defect detection result includes the defect confidence, and the defect confidence represents the probability that there is a defect in the video frame.
[0011] In a possible implementation, the method further includes: when the defect detection result indicates that the video frame has defects, determining the defect severity of the video frame based on at least one of the position, size and number of defect areas represented by the target defect map.
[0012] In a possible implementation manner, the method further includes: determining video segments in the video that have continuous defects according to defect detection results of multiple video frames in the video.
[0013] In a possible implementation manner, the method further includes: repairing the defective video frame according to a target defect map of the defective video frame to obtain a repaired video frame.
[0014] In one possible implementation, the method is implemented using a defect detection model, which includes a feature extractor, a defect locator, and a defect classifier; wherein the feature extractor is used to extract a shallow feature map and a deep feature map of the video frame, the defect locator is used to determine a defect map corresponding to the video frame based on the shallow feature map and the deep feature map, and the defect classifier is used to determine a defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map, and the defect map.
[0015] In a possible implementation, the defect detection model is trained using a sample data set; wherein the sample data set is obtained through the following process: obtaining a plurality of original video samples; performing random damage processing on the plurality of original video samples respectively to obtain damaged video samples corresponding to each original video sample, wherein each damaged video sample contains at least one damaged video frame with defects; according to the difference between each original video sample and the corresponding damaged video sample, obtaining a damaged video frame in each damaged video sample and a mask map corresponding to the damaged video frame, wherein the mask map is used to indicate a defective area where the defect is located in the damaged video frame; wherein the sample data set includes a plurality of damaged video samples corresponding to the plurality of original video samples, a mask map of the damaged video frame in each damaged video sample, and a category label of each video frame in each damaged video sample, wherein the category label is used to indicate whether the video frame is a damaged video frame or an original video frame that has not been damaged.
[0016] In a possible implementation, the defects in the video frame include a screen noise defect caused by partial data damage during video transmission; wherein, when the defect detection model is used to detect the screen noise defect, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: based on a preset damage model, the original video streams of the multiple original video samples are subjected to data damage processing to obtain damaged video streams corresponding to each original video sample; and the damaged video streams corresponding to each original video sample are parsed using a video parser to obtain damaged video samples corresponding to each original video sample; wherein the damage model is used to indicate the damage ratio, damage position and damage length, the damage ratio represents the ratio of the damaged video frame to the original video sample, the damage position represents the position of the damaged video frame in the original video sample, and the damage length represents the length of the defective area in the damaged video frame.
[0017] In a possible implementation, the defects in the video frames include ghosting defects caused by overlapping adjacent frames during video format conversion; wherein, when the defect detection model is used to detect the ghosting defects, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: for any original video sample, estimating the motion area of each frame of the original video sample, the object in the motion area has a motion state, and determining at least one candidate ghost frame according to the size of the motion area of each frame of the original video sample; overlapping each candidate ghost frame in the original video sample with each adjacent video frame of the candidate ghost frame to obtain a damaged video sample.
[0018] In one possible implementation, the defects in the video frame include wiredrawing defects caused by interpolating odd and even rows of different frames of the original frame rate video into the same frame of the new frame rate video during the frame rate conversion of the interlaced scanned video frame, and the wiredrawing defect has a horizontal comb tooth shape; wherein, when the defect detection model is used to detect wiredrawing defects, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: referring to the principle of generating the wiredrawing defect, the wiredrawing defect is randomly introduced into at least one video frame of each original video sample to obtain a damaged video sample corresponding to each original video sample.
[0019] In a possible implementation, the defects in the video frame include physical defects caused by physical damage to the video film; the physical defects include linear marks caused by physical scratches in the video film, and / or irregular spots caused by stains or impurities of non-image structures appearing on the chemical coating of the video film; wherein, when the defect detection model is used to detect the physical defects, the multiple original video samples are subjected to random damage processing respectively to obtain damaged video samples corresponding to each original video sample, including: obtaining multiple film scan images, and marking the regional boundaries of the physical defects in each film scan image, wherein the film scan image is an image obtained by scanning the video film with the physical damage; dividing each film scan image into multiple pixel areas of a specified size, and based on the regional boundaries of the physical defects marked in each film scan image, counting the number of defects of each physical defect appearing in each pixel area; and performing random damage processing on the multiple pixels by performing random damage processing on the multiple original video samples to obtain damaged video samples corresponding to each original video sample. The number of defects of each physical defect appearing in the area is estimated by maximum likelihood, and a gamma distribution model corresponding to each physical defect is fitted, and the gamma distribution model is used to characterize the quantity distribution characteristics of each physical defect; for any original video sample, based on the gamma distribution model corresponding to each physical defect, the target defect number of each physical defect to be added to the video frame in the original video sample is sampled; based on the target defect number of each physical defect, position information matching the target defect number is extracted for each physical defect from a preset spatial noise distribution, and a rotation angle matching the target defect number is extracted for each physical defect from a preset rotation angle range, the position information is used to indicate the pixel position of the physical defect, and the rotation angle is used to indicate the direction of the physical defect; based on the position information and rotation angle matching the target defect number of each physical defect, the physical defect matching the target defect number corresponding to each physical defect is fused into at least one video frame of the original video sample to obtain a damaged video sample.
[0020] According to another aspect of the present disclosure, a video defect detection device is provided, including: an acquisition module, used to acquire a video frame of a video to be detected; a feature extraction module, used to extract a shallow feature map and a deep feature map of the video frame; a defect map determination module, used to determine a defect map corresponding to the video frame based on the shallow feature map and the deep feature map, the defect map representing a defect area where a defect in the predicted video frame is located; and a result determination module, used to determine a defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map and the defect map, the defect detection result being used to indicate whether the video frame has a defect.
[0021] According to another aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0022] According to another aspect of the present disclosure, a non-volatile computer-readable storage medium is provided, on which computer program instructions are stored, wherein the computer program instructions implement the above method when executed by a processor.
[0023] According to another aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0024] According to various aspects of the present disclosure, pixel-level defect areas can be predicted based on shallow feature maps and deep feature maps based on video frames. This process is equivalent to preliminarily screening video frames with defects. By utilizing shallow feature maps, deep feature maps and defect maps, defect detection results can be determined more accurately, that is, whether there are defects in the video frames can be judged more accurately. In particular, the introduction of defect maps is equivalent to introducing an attention mechanism to pay more attention to defective areas. This can effectively improve the efficiency and accuracy of defect detection results, thereby helping to reduce the false detection rate of defect detection.
[0025] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate exemplary embodiments, features, and aspects of the disclosure and, together with the description, serve to explain the principles of the disclosure.
[0027] Figure 1 A flowchart of a video defect detection method according to an embodiment of the present disclosure is shown.
[0028] Figure 2 A schematic diagram showing a Transformer unit structure according to an embodiment of the present disclosure.
[0029] Figure 3 A structural schematic diagram of a defect detection model according to an embodiment of the present disclosure is shown.
[0030] Figure 4 A structural schematic diagram of a defect detection model according to an embodiment of the present disclosure is shown.
[0031] Figure 5 A structural schematic diagram of a defect detection model according to an embodiment of the present disclosure is shown.
[0032] Figure 6 A schematic diagram showing a process for detecting a screen defect according to an embodiment of the present disclosure is shown.
[0033] Figure 7 A schematic diagram showing a global defect detection process according to an embodiment of the present disclosure is shown.
[0034] Figure 8 A schematic diagram showing a physical defect detection process according to an embodiment of the present disclosure is shown.
[0035] Fig. 9 A block diagram of a video defect detection apparatus according to an embodiment of the present disclosure is shown.
[0036] Fig.10 A block diagram of an electronic device 1900 according to an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0037] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.
[0038] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.
[0039] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.
[0040] It should be understood that the terms "first", "second", "third", etc. in the claims, specifications and drawings of the present disclosure are used to distinguish different objects rather than to describe a specific order. The terms "include" and "comprise" used in the specifications and claims of the present disclosure indicate the presence of the described features, wholes, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or their collections.
[0041] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.
[0042] In order to better understand the solutions of the embodiments of the present disclosure, relevant terms and concepts that may be involved in the embodiments of the present disclosure are first introduced below.
[0043] (1) Media Quality Control (MQC): refers to the process of verifying whether media files meet standards and specifications.
[0044] (2) H.264 Advanced Video Coding (AVC): refers to video bitstreams compressed using the H.264 coding standard, which has the advantages of efficient transmission and storage. The H.264 encoder has high compression rate and video quality, making it the mainstream choice in the field of video transmission and storage. Among them, frame data occupies a major proportion in the H.264 bitstream (usually more than 99.9%) and is most susceptible to damage.
[0045] (3) H.265 High Efficiency Video Coding (HEVC): is a new video coding standard and the successor to H.264 / AVC. With a higher data compression ratio, it can reduce data traffic by about 50% while maintaining the same video quality. Due to its higher compression rate for video data, any data corruption encountered by H.265-encoded videos during transmission or storage may cause more obvious screen distortion problems.
[0046] (4) MPEG-2 (Moving Picture Experts Group 2): It is an early digital video compression standard, mainly used in television broadcasting and DVD video formats. Although its compression efficiency is not as good as H.264 and H.265, it is still widely used in some specific applications and early video materials. Compared with newer coding standards, when MPEG-2 encoded video is damaged during transmission, it will also cause visible distortion and defects in image quality.
[0047] (5)FFmpeg is an open source computer program that can be used to record, convert digital audio and video, and convert them into streams.
[0048] (6) Video Hit: During video transmission, due to software or hardware failures or network environment problems, video playback may experience video hits due to data packet loss or errors, manifested as abnormal color, blocky or striped distortion, etc., which seriously affects the audience's viewing experience.
[0049] (7) Video Global Artifacts: refers to defects whose formation principle is related to the overall overlap of the previous and next frames of the video, such as ghosting and drawing.
[0050] (8) Ghosting: Ghosting is caused by errors in shooting settings or format conversion after shooting. Due to the overlap of previous and next frames, the video will become jittery and blurry when viewed.
[0051] (9) Combing: When frame rate conversion is performed on interlaced video frames, combing defects are caused by interpolating odd and even lines of different frames of the original frame rate video into the same frame of the new frame rate video. Combing defects have horizontal comb teeth shape, and the audience will perceive obvious silk-like horizontal stripes.
[0052] (10) Scratches: Film damage may cause physical damage such as scratches, which usually appear as regular or irregular linear marks on the image. These physical defects will destroy the continuity and integrity of the original image and reduce the image quality.
[0053] (11) Dirt: Non-image structure stains or impurities that appear on the chemical coating of the film (usually the emulsion layer). After imaging, they appear as physical defects such as small black spots, white spots or irregular spots of other colors on the photo or movie screen.
[0054] (12) Perlin Noise: It is a natural noise generation algorithm widely used in computer graphics. This algorithm is mainly used to create smooth, continuous and seemingly random textures or patterns to simulate many phenomena in nature, such as terrain undulations, cloud distribution, water flow fluctuations, etc.
[0055] (13) Transformer: Transformer uses the self-attention mechanism to process sequence data. It does not need to rely on sequential calculations and can process each element of the input sequence in parallel, thereby greatly improving training efficiency.
[0056] (14) Window Attention (WinAttn): An attention mechanism that divides the input feature map into different windows so that the model can perform self-attention calculation on each window.
[0057] As mentioned above, in the early quality control work of the media production quality control system, the delivery of video media and whether to produce ultra-high-definition video mainly rely on manual viewing of the entire film to screen defects and make subjective judgment decisions. The traditional method of manual viewing of the entire film is not only time-consuming, but also time-consuming and labor-intensive. It is also difficult to meet the needs of large-scale high-resolution video defect detection. In addition, although some existing defect detection methods can identify and locate the defect position to a certain extent, they are often not highly accurate, making it impossible for the defect video repair process to utilize the accurate location information of the defect, resulting in poor repair effects.
[0058] The video defect detection method of the disclosed embodiment can provide the media production quality control system with video defect (such as screen distortion, ghosting, brushing, scratches, dirty spots, etc.) detection capability, effectively supports video medium delivery, ultra-high-definition video selection, old film restoration and other businesses, can accurately identify and evaluate various defects in video media and video streams, realize pixel-level defect area detection, and can provide pixel-scale defect areas and corresponding precise defect parameters (such as the location, size, number, etc. of the defect area), as well as defect video frame severity assessment, thereby reducing the cost of manual review.
[0059] The video defect detection method of the disclosed embodiment has efficient data processing capabilities and accurate image analysis capabilities, and can perform pixel-level analysis on each frame, accurately identify defective areas, reduce workload, and provide efficient and accurate video defect detection and evaluation for media production quality control systems. This not only significantly improves the performance and accuracy of defect detection, but also enables rapid identification of defect quality issues in multiple business scenarios such as video media delivery and ultra-high-definition video selection, effectively ensuring the audience's high-quality viewing experience.
[0060] In practical applications, the video defect detection method of the embodiment of the present disclosure can be deployed on various terminal devices through software or hardware modification. The terminal device involved in the present application can refer to a device with a wireless connection function. The wireless connection function means that it can be connected to other terminal devices through wireless connection methods such as wifi and Bluetooth. The terminal device of the present application can also have the function of communicating through a wired connection. The terminal device of the present application can be a touch screen, a non-touch screen, or a screenless device. The touch screen can control the terminal device by clicking and sliding on the display screen with fingers, stylus, etc. The non-touch screen device can be connected to an input device such as a mouse, keyboard, touch panel, etc., and the terminal device can be controlled through the input device. The device without a screen can be, for example, a Bluetooth speaker without a screen. For example, the terminal device of the present disclosure can be a computer, a smart phone, a netbook, a tablet computer, a laptop computer, a wearable electronic device (such as a smart bracelet, a smart watch, etc.), a TV, a virtual reality device, etc.
[0061] The video defect detection method of the embodiment of the present disclosure can also be deployed on a server. The server can be located in the cloud or locally. It can be a physical device or a virtual device, such as a virtual machine, a container, etc., and has a wireless communication function, wherein the wireless communication function can be set in the chip (system) or other parts or components of the server. It can refer to a device with a wireless connection function. The wireless connection function refers to the ability to connect to other servers or terminal devices through wireless connection methods such as Wi-Fi and Bluetooth. The server of the present disclosure can also have the function of communicating through a wired connection. For example, the server of the present disclosure can be located in the cloud and communicate with the terminal device. The server receives the video to be detected sent by the terminal device, and uses the video defect detection method deployed on the server to perform defect detection on the video, and obtains the defect detection result of the video frame in the video. The defect detection result and the video frame with defects can be returned to the terminal device to display the defect detection result of the video frame through the terminal device.
[0062] The following Figures 1 to 8 The video defect detection method of the embodiment of the present disclosure is introduced in detail.
[0063] Figure 1 FIG. 1 is a flow chart showing a method for detecting video defects according to an embodiment of the present disclosure. The method may be executed by the above-mentioned terminal device or server, such as Figure 1 As shown, the video defect detection method includes: step S11 to step S14.
[0064] In step S11, a video frame of a video to be detected is obtained.
[0065] The video to be detected may be, for example, a video captured by a video capture device (such as a camera), or a video transmitted from a local storage or other electronic device, or a video obtained by digitally scanning a film of a movie. The disclosed embodiment does not limit the method of obtaining the video. It should be understood that the disclosed embodiment does not limit the content, format (such as mp4, avi, mkv, etc.), type (such as a video stream or a video frame sequence), duration, etc. of the video to be detected.
[0066] The video frame of the video can be every video frame in the video, that is, the video frames in the video can be tested frame by frame for defects. Considering that the video quality control objects in some scenes are mostly medium-length videos, that is, the length of the video to be tested may be long. For example, the number of video frames of a movie is about 100,000. In order to achieve a balance between detection accuracy and detection efficiency, it is also possible not to perform defect detection on all video frames of the video, or the video can be sampled to extract some video frames for defect detection.
[0067] For example, after obtaining the video to be detected, the video can be analyzed to obtain information such as the video's frame rate, duration, resolution, and bit rate. Then, based on this information and in combination with preset sampling rules, an adaptive sampling interval is generated, and the video is extracted according to the adaptive sampling interval. For example, the FFmpeg tool can be used to extract frames according to the sampling interval to obtain a group of video frames for subsequent defect detection. This can significantly improve the video defect detection performance while covering the entire video, greatly reduce the operating cost of defect detection, and improve detection efficiency.
[0068] In step S12, a shallow feature map and a deep feature map of the video frame are extracted.
[0069] Among them, the deep feature map represents the deep features of the video frame extracted in the deeper layer (such as the middle layer or close to the output layer) of the feature extractor, and the shallow feature map represents the shallow features of the video frame extracted in the shallower layer (such as the first layer or the first few layers) of the feature extractor. In practical applications, encoders known in the art can be used to extract shallow feature maps and deep feature maps of video frames. For example, an encoder of DeepLabV3+ (a semantic segmentation model of deep learning) can be used as a feature extractor, and the feature map output by the first layer of the feature extractor can be used as a shallow feature map (for example, it can be a feature map with 1 / 4 resolution of the input video frame), and the feature map output by the last layer of the feature extractor can be used as a deep feature map.
[0070] Optionally, the embodiment of the present disclosure further provides a feature extraction method implemented by using a Transformer architecture, which can capture more fine-grained image context information and extract rich multi-scale features. Specifically, the shallow feature map and deep feature map of the extracted video frame include:
[0071] Divide a video frame into multiple image blocks;
[0072] Inputting the plurality of image blocks into the converter module, obtaining a multi-scale feature map extracted by N layers of converter units in the converter module, wherein the first scale feature map extracted by the first layer of converter units is used as a shallow feature map, and N is a positive integer;
[0073] Fusing the second scale feature map to the Nth scale feature map output by the second layer converter unit to the Nth layer converter unit in the converter module to obtain a first fused feature map;
[0074] According to the first fused feature map, a deep feature map is determined.
[0075] For example, the OPM (Overlapped Patch Merging) mechanism can be used to process the input video frame, and the video frame can be divided into multiple image blocks as the input of the converter module. The multiple image blocks into which the video frame is divided can be overlapped as the input of the converter module, which is equivalent to processing the video frame into serialized data. This makes it easier for the Transformer to capture contextual information and extract more detailed multi-scale features.
[0076] In practical applications, each layer of the transformer unit (ie, Transformer Block) in the transformer module can adopt the existing Transformer unit structure, for example, Figure 2 A Transformer unit structure (i.e., a Transformer Block structure) is shown, which mainly includes an attention module (Attention Block), a feed forward neural network (Feed Forward Network) and a normalization layer (LayerNorm), which is not limited to the embodiments of the present disclosure. By using a converter module, it is possible to be more sensitive to extracting detailed features of video frames, which is conducive to extracting feature maps with more details. For example, multi-scale feature maps (i.e., multi-level features) of 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the original video frame resolution can be obtained through multi-layer converter units.
[0077] Among them, the higher the level of the converter unit in the converter module (the closer to the output), the smaller the scale (i.e., resolution) of the feature extraction extracted by the converter unit and the higher the channel dimension. Therefore, the first scale feature map extracted by the first layer converter unit can be used as a shallow feature map; then the second scale feature map to the Nth scale feature map output by the second layer converter unit to the Nth layer converter unit in the converter module are subjected to multi-scale feature fusion processing. For example, the different scale feature maps can be uniformly mapped to a size of 1 / 8 of the original image resolution through a linear layer (such as MLP), and then feature fusion is performed by using channel splicing combined with dimensionality reduction mapping. In this way, in-depth fusion of contextual information between feature maps of different scales can be achieved, thereby obtaining a more refined and feature-rich first fused feature map, that is, the first fused feature map contains contextual information between feature maps of different scales, which is beneficial to obtaining a deep feature map with rich depth features based on the first fused feature map, which is beneficial to improving the accuracy of subsequent defect maps and defect detection results.
[0078] Among them, a feature fusion method known in the art can be used to implement fusion processing of the second-scale feature map to the N-th scale feature map output by the second-layer converter unit to the N-th layer converter unit in the converter module. For example, the second-scale feature map to the N-th scale feature map can be first reduced to a low dimension and unified to the same scale through dimensionality reduction and upsampling processing to obtain N-1 intermediate feature maps with the same scale and low dimension, and then the N-1 intermediate feature maps are channel-joined to obtain a first fused feature map.
[0079] For example, the deep feature map can be obtained by performing dimensionality reduction processing, pooling processing, adding an attention mechanism, etc. on the first fused feature map. In order to improve the richness of the deep feature map, the deep feature map can include global features and local features of various granularities. Therefore, in a possible implementation, the above-mentioned determination of the deep feature map based on the first fused feature map includes:
[0080] Performing dimensionality reduction processing on the first fused feature map to obtain a second fused feature map;
[0081] Using multiple window attention mechanisms to perform self-attention extraction processing on the second fused feature map respectively, to obtain multiple self-attention feature maps, wherein the window sizes used for extracting self-attention in different window attention mechanisms are different;
[0082] Performing pooling processing on the second fused feature map to obtain a pooled feature map;
[0083] Channel-joining the second fused feature map, multiple self-attention feature maps, and the pooling feature map to obtain a first joint feature map;
[0084] The first concatenated feature map is subjected to dimensionality reduction processing to obtain a deep feature map.
[0085] As mentioned above, the first fused feature map can be obtained by splicing multiple feature maps, so the higher-dimensional first fused feature map can be first reduced in dimension. For example, the first fused feature map of 512 channels can be reduced in dimension to the second fused feature map of 128 channels, where the dimensionality reduction process can be understood as mapping the features of the high-dimensional space to the low-dimensional space, which can reduce the computational complexity. At the same time, the second fused feature map still contains the contextual information between feature maps of different scales.
[0086] It should be understood that the embodiments of the present disclosure do not limit the specific implementation method of the dimensionality reduction processing. For example, a multilayer perceptron (MLP) or a convolutional network may be used, and the embodiments of the present disclosure do not limit this.
[0087] Among them, the window size of the window attention mechanism is different, and the granularity of the local features extracted is different. Specifically, the smaller the window, the finer the granularity of the local features extracted. By using multiple window attention mechanisms with different window sizes, multiple self-attention feature maps can be extracted, and each self-attention mechanism can characterize local features of various granularities. It should be understood that the embodiment of the present disclosure does not limit the number of window attention mechanisms and the window sizes used by each. For example, window sizes of ratios R=2, 4, and 8 can be used respectively, and a window of ratio R contains R feature blocks (feature patches), such as a window of R=2 contains 2 feature patches, and a window of R=4 contains 4 feature patches.
[0088] Among them, the second fused feature map may be pooled using a pooling method known in the art, such as average pooling, maximum pooling, random pooling, etc., which is not limited in the embodiments of the present disclosure. Pooling can be used to extract global features while reducing computational complexity.
[0089] It should be understood that by channel-splicing the second fused feature map, multiple self-attention feature maps and the pooled feature map, and then performing dimensionality reduction processing on the first spliced feature map to obtain a deep feature map, the deep feature map can be integrated with the contextual information contained in the second fused feature map, the local features of various granularities contained in the multiple self-attention feature maps, and the global features contained in the pooled feature map, thereby improving the refinement and richness of the deep feature map, and at the same time helping to reduce the computational complexity of subsequent deep feature maps.
[0090] It can be seen that for a feature map of size PxP (that is, the number of feature patches in the feature map is PxP), each feature patch needs to calculate attention with all other feature patches. Therefore, the amount of calculation required to calculate the window self-attention is proportional to the size of the feature map PxP. For example, for a window attention of ratio R (R=2,4,8), the feature map of PxP will be expanded to RPxRP and then the self-attention will be calculated. The amount of calculation is increased by RxR times. Therefore, in order to reduce the computational cost, when using the window attention mechanism to calculate self-attention, the expanded RPxRP feature map can be first pooled into the PxP feature map, and then the window attention is calculated. This reduces the amount of calculation while enhancing the global perception capability.
[0091] In step S13, a defect map corresponding to the video frame is determined according to the shallow feature map and the deep feature map, and the defect map represents the defect area where the defect in the predicted video frame is located.
[0092] Optionally, a decoder known in the art may be used, for example, a DeepLabV3+ decoder may be used to determine a defect map corresponding to a video frame based on a shallow feature map and a deep feature map, and this is not limited to the embodiments of the present disclosure.
[0093] Optionally, the shallow feature map and the deep feature map can be fused, and then the defect map can be determined based on the fused feature map, which is equivalent to supplementing the deep feature map with the shallow feature information in the shallow feature map, so that the deep feature map can be enhanced, so that the fused feature map enhances the shallow feature information of the image, so as to achieve more accurate pixel-level defect area prediction. Specifically, the above-mentioned determination of the defect map corresponding to the video frame based on the shallow feature map and the deep feature map can include:
[0094] Performing dimensionality reduction processing on the shallow feature map to obtain a first shallow feature map;
[0095] Based on the resolution of the first shallow feature map, upsampling the deep feature map to obtain a first deep feature map, where the first deep feature map has the same resolution as the first shallow feature map;
[0096] Channel-joining the first shallow feature map and the first deep feature map to obtain a second joined feature map;
[0097] Performing dimensionality reduction processing on the second spliced feature map to obtain a defect map;
[0098] Based on the original resolution of the video frame, the defect map is upsampled to obtain a target defect map that matches the original resolution of the video frame. The target defect map can be used to implement subsequent tasks such as evaluating the degree of defect verification and repairing defects.
[0099] Among them, a dimensionality reduction method known in the art can be adopted. For example, MLP can be used to implement dimensionality reduction processing on the shallow feature map to obtain a first shallow feature map. It should be understood that the first shallow feature map obtained after dimensionality reduction still contains shallow feature information of the video frame; then by upsampling the deep feature map (for example, it can be upsampled to 1 / 4 of the size of the input video frame), a first deep feature map with the same resolution as the first shallow feature map is obtained, which can facilitate the subsequent channel splicing of the first shallow feature map and the first deep feature map with the same resolution to obtain a second spliced feature map. The second spliced feature map integrates the shallow information in the shallow feature map and the deep information in the deep feature map, thereby realizing feature enhancement of the deep feature map.
[0100] Since the channel dimension of the second spliced feature map after splicing is relatively high, the second spliced feature map can be processed by dimensionality reduction, for example, it can be reduced to a single-channel defect map. At this time, the output defect map can characterize the defect area where the predicted video frame defect is located. Since the deep feature map and shallow feature map are extracted by dividing the video frame into multiple image blocks, the resolution of the defect map is usually smaller than the original resolution of the video frame. Therefore, the defect map can be upsampled to obtain a target defect map with the same original resolution as the video frame, so that the target defect map can represent a more accurate predicted pixel-level defect area. The above process can be briefly described as the deep feature map is upsampled, and the feature is spliced with the shallow feature map that has been processed by dimensionality reduction to achieve feature enhancement of the deep feature map, and then the predicted defect map is obtained on the basis of the second spliced feature map after shallow feature enhancement.
[0101] In step S14, a defect detection result corresponding to the video frame is determined based on the shallow feature map, the deep feature map and the defect map, and the defect detection result is used to indicate whether there is a defect in the video frame.
[0102] Optionally, the shallow feature map, the deep feature map and the defect map can be fused, and then the defect detection result corresponding to the video frame can be determined based on the fused feature map, wherein the fusion of the shallow feature map into the deep feature map can achieve feature enhancement. Since the defect map represents the defect area where the defect is located in the predicted video frame, introducing the defect map is equivalent to introducing an attention mechanism, which can make the fused feature map pay more attention to the defect area indicated by the defect map, thereby helping to improve the accuracy of the defect detection results.
[0103] As described above, in the above step S13, the first depth feature map can be extracted to determine the defect map, so that in step S14, the first depth feature map and the defect map can be used to more accurately determine the defect detection result. Specifically, in a possible implementation, the above-mentioned determination of the defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map and the defect map may include:
[0104] Performing feature extraction on the shallow feature map to obtain a second deep feature map, and performing dimensionality reduction processing on the second deep feature map to obtain a first intermediate feature map;
[0105] Based on the resolution of the shallow feature map, upsampling the first intermediate feature map to obtain a second intermediate feature map, where the second intermediate feature map has the same resolution as the shallow feature map;
[0106] Performing dimensionality reduction processing on the shallow feature map, the first deep feature map and the defect map respectively to obtain a second shallow feature map, a third deep feature map and a first defect map;
[0107] Channel-joining the second intermediate feature map, the second shallow feature map, the third deep feature map, and the first defect map to obtain a third joint feature map;
[0108] The third spliced feature map is subjected to dimensionality reduction processing to obtain a defect confidence. The defect detection result includes the defect confidence, and the defect confidence represents the probability that a defect exists in the video frame.
[0109] For example, a multi-layer convolutional network or a multi-layer converter unit can be used to implement feature extraction of a shallow feature map to obtain a second deep feature map, which can contain deep feature information characterizing a video frame category, wherein the video frame category can indicate whether the video frame has defects.
[0110] Among them, by performing dimensionality reduction processing on the second deep feature map and upsampling processing on the first intermediate feature map, it can be convenient for subsequent channel stitching, and the dimensionality reduction processing on the shallow feature map, the first deep feature map and the defect map can reduce the computational complexity; by performing channel stitching on the second intermediate feature map, the second shallow feature map, the third deep feature map and the first defect map, the third stitching feature map obtained by channel stitching can integrate feature information from various aspects, and then generate defect confidence based on the third stitching feature map that integrates feature information from various aspects, which can effectively improve the accuracy of the defect confidence, and thus help reduce the false detection rate of defect detection.
[0111] In practical applications, a confidence threshold (such as 95%) can be preset. When the confidence of the detected defect is greater than the confidence threshold, it is considered that there is a defect in the video frame. Conversely, when the confidence of the detected defect is less than or equal to the confidence threshold, it is considered that there is no defect in the video frame. It should be understood that the embodiments of the present disclosure do not limit the specific value of the confidence threshold. In this way, video frames with low defect confidence can be filtered out, which is conducive to reducing the false detection rate of defects.
[0112] After obtaining the defect detection result of the video frame, the defect severity of the detected video frame with defects can be evaluated based on the above-mentioned defect confidence and the defect area represented in the target defect map. In a possible implementation, the method may also include: when the defect detection result indicates that the video frame has defects, the defect severity of the video frame is determined according to at least one of the position, size and number of the defect area represented by the target defect map. Specifically, it is possible to first determine whether there is a defect in the video frame based on the defect confidence, and then determine the defect severity of the video frame according to at least one of the position, size and number of the defect area represented by the target defect map of the video frame with defects.
[0113] Among them, the position of the defective area can characterize the relative position of the defective area in the video frame, the size of the defective area can include area, length, width, etc., and the number of defective areas characterizes the number of defective areas in the video frame. It should be understood that those skilled in the art can determine the defect severity of the video frame according to the evaluation rules of the actual defect severity according to actual needs. For example, the evaluation rules can be set to the more central the position of the defective area, the larger the area, and the greater the number, the higher the defect severity is considered. The embodiments of the present disclosure are not limited to this. Exemplarily, the defect severity can be quantitatively scored based on at least one of the position, size and number of the defective area represented by the target defect map, and the defect severity of the video frame can be divided into the following levels: unnoticeable / mild, severe and bad, etc.
[0114] In practical applications, the defect detection results of multiple video frames can also be combined in the video dimension, and the time period of continuous defect detection can be used as a defective video segment. Therefore, in a possible implementation, the method can also include: determining a video segment in which defects are continuously present in the video according to the defect detection results of multiple video frames in the video. Determining a video segment in which defects are continuously present in the video means determining a defective video segment composed of multiple continuous video frames in which defects are continuously present in the video.
[0115] In practical applications, the video frames can also be repaired based on the target defect map of the defective video frames. Therefore, in a possible implementation, the method further includes: repairing the defective video frames according to the target defect map of the defective video frames to obtain repaired video frames. In particular, repairing defects in the video obtained by scanning the film of the old film can improve the viewing experience of the old film. It should be understood that those skilled in the art can use image restoration techniques known in the art to repair defective video frames, and the embodiments of the present disclosure are not limited to this. In this way, not only can the severity of the defective area in the video frame be accurately measured, but also the repair plan can be effectively guided, which is conducive to repairing the defective area to the greatest extent while ensuring the quality of the normal area.
[0116] In practical applications, the embodiments of the present disclosure can not only output single-frame defect confidence, target defect map, and defect severity, but also output representative defect frames (such as video frames with the highest defect severity) and video clips with serious defects (such as defective video clips with the highest average defect severity) that are obviously perceived by the human eye by combining the defect detection results and defect severity of all video frames of the video. In addition, a defect detection report can be generated based on the detected defect detection results, target defect map, defect severity, and detection information such as the above-mentioned representative defect frames and defective video clips. The report can include the above-mentioned various detection information, video production suggestions, and possible video repair solutions. It should be understood that those skilled in the art can design the information contained in the defect detection report according to actual needs, and the embodiments of the present disclosure are not limited to this. In this way, it is possible to provide a high-value reference for video quality control, greatly improve work efficiency, and effectively support various business scenarios such as video media delivery services, ultra-high-definition video selection services, and old film repair services.
[0117] According to the defect detection method of the embodiment of the present disclosure, the pixel-level defect area can be predicted by shallow feature maps and deep feature maps based on the video frames. This process is equivalent to the preliminary screening of video frames with defects. By using the shallow feature maps, deep feature maps and defect maps, the defect detection results can be determined more accurately, that is, it is possible to more accurately judge whether there are defects in the video frames. In particular, the introduction of the defect map is equivalent to introducing an attention mechanism to pay more attention to the defective areas. This can effectively improve the efficiency and accuracy of the defect detection results, thereby helping to reduce the false detection rate of defect detection.
[0118] The video defect detection method of the disclosed embodiment can support the input of video source media of any resolution, support accurate detection of defective areas and defect severity analysis, use the terminal display resolution (such as 4K) as the evaluation standard, and can output a multi-dimensional detection report for each defect: including single-frame defect confidence, single-frame target defect map, single-frame defect severity, video overall defect severity, video obvious defect segments, etc. The introduction of the video defect detection method of the disclosed embodiment in the media production quality control system can provide a reference for subsequent quality control and old film restoration, greatly improve work efficiency, and effectively support video media delivery, ultra-high-definition video selection, old film restoration and other businesses.
[0119] By utilizing the video defect detection method of the disclosed embodiment, the original solution for repairing old films will affect the normal area of the video frame when repairing dirty spots and scratches, resulting in poor repair effect. The method can output multi-dimensional information such as defect category, defect area map, defect feature parameters, single frame / video overall defect severity, and defective video clips, thereby providing an effective reference for manual judgment and greatly improving work efficiency. While ensuring accurate detection of defective areas, it can also provide accurate guidance for subsequent old film restoration work.
[0120] In practical applications, the defect detection method proposed in the above-mentioned embodiment of the present disclosure can also be implemented by designing a defect detection model, wherein the defect detection model includes a feature extractor, a defect locator and a defect classifier; wherein the feature extractor is used to extract the shallow feature map and the deep feature map of the video frame, the defect locator is used to determine the defect map corresponding to the video frame based on the shallow feature map and the deep feature map, and the defect classifier is used to determine the defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map and the defect map.
[0121] In a possible implementation, the present disclosure provides Figure 3 A defect detection model is shown in Figure 3 As shown, the feature extractor uses multiple transformer units (Transformer Block1, Transformer Block2, Transformer Block3, Transformer Block4) to extract multi-scale feature maps of multiple input image blocks. The first scale feature map F extracted by the first layer Transformer Block1 QAs a shallow feature map, three MLP layers, two upsampling layers (Upsample) and shortcut connections (Concat) are used to fuse the second scale feature map to the fourth scale feature map proposed by Transformer Block2, TransformerBlock3, and Transformer Block4 to obtain a first fused feature map, and then the MLP layer is used to reduce the dimension of the first fused feature map to obtain a second fused feature map F2; then, three window attention mechanism layers (WinAttn) are used to perform self-attention extraction on the second fused feature map to obtain three self-attention feature maps (F 31 、F 32 、F 33 ), use the image pooling layer (Image Pooling) to pool the second fusion feature map to obtain the pooled feature map F p ; Then the second fusion feature map F2, the three self-attention feature maps (F 31 、F 32 、F 33 ) and pooling feature map F p Perform channel splicing to obtain the first splicing feature map F C1 ; Then use an MLP layer to concatenate the first feature map F C1 Perform dimensionality reduction to obtain the deep feature map F S ;
[0122] Among them, the defect locator uses the MLP layer to calibrate the shallow feature map F Q Perform dimensionality reduction to obtain the first shallow feature map F Q1 , use the upsampling layer (Upsample) to the deep feature map F S Perform upsampling to obtain the first shallow feature map F Q1 The first deep feature map F with the same resolution S1 , and then the first shallow feature map F Q1 With the first deep feature map F S1 Perform channel splicing to obtain the second splicing feature map F C2 , and then use the MLP layer to concatenate the second feature map F C2 Perform dimensionality reduction to obtain the defect map F t1 , based on the original resolution of the video frame, the defect map F is t1 Perform upsampling processing to obtain a target defect map corresponding to the video frame;
[0123] Among them, the defect classifier uses superimposed multi-layer Transformer Blocks and MLP to classify the shallow feature map F QPerform feature extraction to obtain the second deep feature map, and perform dimensionality reduction processing on the second deep feature map to obtain the first intermediate feature map F a1 ; Use the upsampling layer (Upsample) to upsample the first intermediate feature map F a1 Perform upsampling to obtain the shallow feature map F Q The second intermediate feature map F with the same resolution a2 ; Use three MLP layers to analyze the shallow feature map F Q , the first deep feature map F S1 And defect map F t1 Perform dimensionality reduction to obtain the second shallow feature map F Q2 , the third deep feature map F S3 And the first defect map F t2 ; Then, the second intermediate feature map, the second shallow feature map, the third deep feature map and the first defect map are concatenated to obtain the third concatenated feature map F C3 ; Then use the MLP layer to concatenate the third feature map F C3 Perform dimensionality reduction (down to one dimension) to obtain defect confidence.
[0124] like Figure 3 As shown, a post-processing module can be used to determine the defect severity, defect video clips, representative defect frames, and generate defect detection reports based on the target defect image and defect confidence.
[0125] according to Figure 3In the defect detection model shown in the figure, in the feature extractor part, compared with the traditional DeepLabV3+ model, a more powerful Transformer architecture is selected as the backbone network of the feature extractor, which makes the model more sensitive to the feature details of the input image and improves the model's feature extraction ability for the input video frame. By dividing the video frame into multiple image blocks as the input of the Transformer Block, more fine-grained image information can be captured and rich multi-scale feature extraction can be achieved. By fusing between multi-scale feature maps, refined feature representations can be obtained, further promoting the in-depth fusion of features and context information. Using multiple window attention mechanism layers and image pooling layers, context information from different scales can be integrated to effectively capture local features and global features of various granularities. In the defect locator, the deep feature map output by the feature extractor will be upsampled to the same scale as the shallow feature map, and then fused with the shallow feature map through the linear layer (i.e., MLP layer) and feature concatenation. This process enhances the shallow feature information of the image for the deep feature map, so as to achieve more accurate pixel-level defect area prediction. In the defect classifier, by realizing the interactive fusion of features between different feature maps, not only the efficiency of the model in processing single classification task learning is improved, but also the robustness of the model in complex scenarios is improved, while the false detection rate is reduced.
[0126] In practical applications, when the defects in the video frame are small (such as scratches and dirty spots), the detection effect of the defect classifier may be poor. Therefore, it is also possible to determine whether there are defects in the video frame only by the presence or absence of defect areas in the target defect map. Figure 4 As shown, only the target defect map output by the feature extractor and the defect locator is used to implement defect detection, and the embodiments of the present disclosure are not limited to this.
[0127] As described above, the encoder in DeepLabV3+ can also be used as a feature extractor in the defect detection model, and the decoder in DeepLabV3+ can be used as a defect locator in the defect detection model. Therefore, the embodiment of the present disclosure also provides Figure 5 A defect detection model is shown in Figure 5 As shown in the figure, the encoder in DeepLabV3+ is used as the feature extractor, and the backbone network (i.e., the Deep Convolution Neural Network model (DCNN)) is used to output the shallow feature map F QAnd the backbone feature map, among which the lightweight network MobileNetV2 can be selected as the backbone network in the feature extractor. The lightweight network MobileNetV2 can ensure the model performance, and then use the ASPP (AtrousSpatialPyramidPooling, spatial pyramid pooling with atrous convolution (Atrous Conv)) module to generate the deep feature map F based on the backbone feature map S In ASPP, multiple dilated convolution blocks with different dilation rates (such as 3×3Conv rate 6 represents a dilated convolution block with a convolution kernel size of 3×3 and a dilation rate of 6) and an image pooling layer (ImagePooling) are used to perform dilated convolution and pooling processing on the backbone feature map extracted by DCNN, and then the feature maps output by each dilated convolution layer and the image pooling layer are spliced, and then a 1×1 convolution layer (1×1Conv) is used to reduce the dimension of the spliced feature map to obtain a deep feature map Fs; further, the defect locator using the decoder in DeepLabV3+ adopts convolution, upsampling (Upsample by 4 represents 4 times upsampling), channel connection, etc. to realize the deep feature map Fs based on the shallow feature map. Q With the deep feature map F S Output defect map and target defect map, so that shallow features and deep features are further integrated while introducing multi-scale information, effectively improving the accuracy of the model in detecting defect areas; the defect classifier mainly uses multi-layer residual convolution blocks (Residual Conv Blocks) to extract the second deep feature map of the shallow feature map, and mainly uses convolution blocks for dimensionality reduction processing to realize channel splicing of multiple feature maps; due to Figure 5 The feature extractor in the network mainly uses the convolution structure, so when using Figure 5 When performing defect detection using the defect detection model shown, there is no need to divide the video frame into multiple image blocks. The video frame can be directly input into the defect detection model to output the target defect map and defect confidence.
[0128] according to Figure 5 Compared with DeepLabV3+, the defect detection model shown in the figure introduces a defect classifier to fuse the feature maps output by the feature extractor and the defect locator. This allows the defect classifier to output defect detection results more accurately, which is equivalent to first roughly screening the candidate defect frames through the defect locator, and then filtering out the video frames with low confidence in the candidate defect frames through the defect locator, thereby significantly reducing the defect false detection rate and improving the defect detection accuracy.
[0129] In practical applications, the above defect detection model can be trained using a sample data set; wherein the sample data set is obtained through the following process:
[0130] Step S61, obtaining multiple original video samples;
[0131] Step S62, performing random damage processing on the multiple original video samples respectively to obtain damaged video samples corresponding to the original video samples, wherein each damaged video sample contains at least one damaged video frame with defects;
[0132] Step S63, obtaining a damaged video frame in each damaged video sample and a mask image corresponding to the damaged video frame according to the difference between each original video sample and the corresponding damaged video sample, wherein the mask image is used to indicate a defective area where a defect is located in the damaged video frame;
[0133] The sample data set includes multiple damaged video samples corresponding to multiple original video samples, a mask map of the damaged video frame in each damaged video sample, and a category label of each video frame in each damaged video sample. The category label is used to indicate whether the video frame is a damaged video frame or an original video frame that has not been damaged.
[0134] In step S61, original video samples with different resolutions can be collected to ensure that different scenes, motion modes and texture complexities can be covered. Original video samples with different video coding standards can also be collected, for example, original video samples with video coding standards such as H.264, H.265, and MPEG-2 can be collected; when collecting original video samples with different video coding standards, attention can be paid to the processing methods of frame data in the compression process of these coding standards, because the damage of frame data is particularly important for the video quality during decoding. Whether it is H.264, H.265 or MPEG-2 encoded video, due to the dependence on inter-frame compression technology, once the key frame data is damaged, all subsequent frames that rely on the frame may have defects during decoding, resulting in a significant decrease in video quality. Therefore, by collecting original video samples of multiple video coding standards and conducting detailed analysis and preprocessing, a solid foundation can be laid for the subsequent training of defect detection models.
[0135] As mentioned above, the defects in the video frames include flower screen defects, ghosting defects, brushing defects and physical defects (scratches, dirty spots). Therefore, different sample data sets can be constructed for different types of defects to train defect detection models for detecting different types of defects. For example, a sample data set with flower screen defects can be used to train a defect detection model for detecting flower screen defects, and a sample data set with ghosting defects can be used to train a defect detection model for detecting ghosting defects, and so on.
[0136] Therefore, in a possible implementation, when the defect detection model is used to detect the flower screen defect, in the above step S62, a plurality of original video samples are respectively subjected to random damage processing to obtain damaged video samples corresponding to each original video sample, including:
[0137] Based on a preset damage model, data damage processing is performed on the original video streams of multiple original video samples to obtain damaged video streams corresponding to each original video sample;
[0138] The damaged video stream corresponding to each original video sample is parsed by using a video parser to obtain a damaged video sample corresponding to each original video sample;
[0139] Among them, the damage model is used to indicate the damage ratio, damage position and damage length. The damage ratio represents the proportion of damaged video frames in the original video samples, the damage position represents the position of the damaged video frame in the original video samples, and the damage length represents the length of the defective area in the damaged video frame.
[0140] Data corruption can include data loss or errors (such as disorder). In order to efficiently simulate various data corruption situations that may be encountered in the transmission, storage and processing of video content in the real world, a three-parameter corruption model (P, L, S) is designed, where P represents the corruption ratio, which can be randomly selected from 0 (no corruption) to 1 (all corruption); L represents the corruption position, which can be based on the coding unit size (GOP, Group of Pictures) and specific bitstream types are used to locate the damage position. For example, for the H264 bitstream, data loss or error is simulated near the key frame to produce a flower screen effect. S represents the damage length, which characterizes the length of the defect area. The upper and lower limits of S can be set according to the actual situation. It should be understood that the flower screen defect is caused by data damage such as data loss or error in the video stream. The more data is damaged in the video stream, the longer (that is, the larger) the defect area is. Therefore, the length of the data to be damaged in the video stream (that is, the number of serialized data to be damaged) can be selected through S to control the length of the defect area. Then, according to this damage model, the original video stream of each original video sample can be subjected to random packet loss or disorder damage processing to obtain the damaged video stream corresponding to each original video sample. Then, for the damaged video streams with different video coding standards, a bitstream parser (that is, a video parser) compatible with various video coding standards such as H.264, H.265 and MPEG-2 can be used to parse the damaged damaged video stream to generate a damaged video sample with a flower screen defect.
[0141] It should be understood that the defective area where the screen noise defect is located in the damaged video sample generated by the above damage model is unknown, so the above step S63 can be used to obtain the damaged video frame in each damaged video sample and the mask map corresponding to the damaged video frame according to the difference between each original video sample and the corresponding damaged video sample. In other words, the damaged video sample and the original video sample can be compared to generate a damaged video sequence (that is, multiple damaged video frames) and a mask map (that is, a mask sequence) for indicating the defective area. These mask maps can accurately point out the defective area where the screen noise defect is located in each damaged video frame. Then, the damaged video sequence and the corresponding mask sequence can be combined to construct a sample data set corresponding to the screen noise defect to train a defect detection model for detecting the screen noise defect.
[0142] In a possible implementation, when the defect detection model is used to detect ghosting defects, in the above step S62, a plurality of original video samples are respectively subjected to random damage processing to obtain damaged video samples corresponding to the respective original video samples, including:
[0143] For any original video sample, estimating the motion region of each video frame in the original video sample, where the object in the motion region has a motion state, and determining at least one candidate ghost frame according to the size of the motion region of each video frame in the original video sample;
[0144] Each candidate ghost frame in the original video sample is overlapped with a video frame adjacent to each candidate re-frame to obtain a damaged video sample.
[0145] In practical applications, motion estimation techniques known in the art, such as optical flow estimation methods, can be used to estimate the motion region of each video frame in the original video sample; then, based on the size of the motion region of each video frame in the original video sample, video frames with larger motion regions (i.e., larger motion degrees) can be selected as candidate ghost frames. For example, the video frames can be sorted in descending order according to the size of the motion region and then the video frames in the first m positions can be selected as candidate ghost frames, or at least one video frame can be sampled as a candidate ghost frame based on the descending order result, and the embodiments of the present disclosure are not limited to this. In this way, a damaged video sample with ghosting defects can be effectively constructed by selecting video frames with larger motion regions.
[0146] Among them, referring to the generation principle of ghosting defects, each candidate ghosting frame in the original video sample can be overlapped with the video frame adjacent to each candidate re-frame to obtain a damaged video sample; then, through the above step S63, according to the difference between each original video sample and the corresponding damaged video sample, the damaged video frame in each damaged video sample and the mask map corresponding to the damaged video frame are obtained. At this time, the mask map can indicate the defect area where the ghosting defect is located, wherein the difference between the damaged video frame and the original video frame can be used to obtain the pixel-level label (i.e., the mask map) of the defect area and the category label of the damaged video frame. Among them, it is also possible to manually label and screen out effective damaged video samples to construct a sample data set corresponding to the ghosting defect, for example, a sample data set of 100,000 can be constructed and labeled. By constructing a sample data set corresponding to the ghosting defect, a defect detection model for detecting ghosting defects can be trained. It should be understood that those skilled in the art can design and develop relevant program codes according to the generation principle of ghosting defects to simulate ghosting defects in the original video sample, and the embodiment of the present disclosure does not limit the generation method of ghosting defects.
[0147] In a possible implementation, when the defect detection model is used to detect wire drawing defects, in the above step S62, a plurality of original video samples are randomly damaged to obtain damaged video samples corresponding to each original video sample, including: referring to the generation principle of wire drawing defects, randomly introducing wire drawing defects into at least one video frame of each original video sample to obtain damaged video samples corresponding to each original video sample. As described above, the wire drawing defect is caused by putting different frames of the original frame rate video into odd and even lines and interpolating them into the same frame of the new frame rate video when performing frame rate conversion on the interlaced scanned video frame. Therefore, those skilled in the art can design and develop relevant degree codes according to the generation principle of the wire drawing defect to randomly introduce wire drawing defects into at least one video frame of the original video sample to construct damaged video samples with wire drawing defects. Then, according to the difference between each original video sample and the corresponding damaged video sample, the damaged video frame in each damaged video sample and the mask map corresponding to the damaged video frame are obtained through the above step S63, and the mask map can indicate the defect area where the wire drawing defect is located. By constructing a sample data set corresponding to the wire drawing defect, a defect detection model for detecting wire drawing defects can be trained.
[0148] As described above, the defects in the video frame also include physical defects caused by physical damage to the video film, and the physical defects include linear marks (i.e. scratches) caused by physical scratches in the video film, and / or irregular spots (i.e. dirty spots) caused by stains or impurities of non-image structures appearing on the chemical coating of the video film. In a possible implementation, when the defect detection model is used to detect physical defects, in the above step S62, a plurality of original video samples are respectively subjected to random damage processing to obtain damaged video samples corresponding to each original video sample, including:
[0149] Acquire multiple film scan images and mark the region boundary of the physical defect in each film scan image, wherein the film scan image is an image obtained by scanning a video film having the physical damage;
[0150] Each film scan image is divided into a plurality of pixel regions of a specified size, and based on the region boundaries of the physical defects marked in each film scan image, the number of defects of each physical defect occurring in each pixel region is counted respectively;
[0151] By performing maximum likelihood estimation on the number of defects of each physical defect occurring in multiple pixel regions, a gamma distribution model corresponding to each physical defect is fitted, wherein the gamma distribution model is used to characterize the quantity distribution characteristics of each physical defect;
[0152] For any original video sample, based on the gamma distribution model corresponding to each physical defect, a target defect number of each physical defect to be added to the video frame in the original video sample is sampled;
[0153] Based on the target defect quantity of each physical defect, extracting position information matching the target defect quantity for each physical defect from a preset spatial noise distribution, and extracting a rotation angle matching the target defect quantity for each physical defect from a preset rotation angle range, the position information being used to indicate a pixel position of the physical defect, and the rotation angle being used to indicate a direction of the physical defect;
[0154] Based on the position information and the rotation angle that match the target defect quantity of each physical defect, the physical defects that match the target defect quantity corresponding to each physical defect are fused into at least one video frame of the original video sample to obtain a damaged video sample.
[0155] In practical applications, a batch of severely damaged 4K resolution film scan images can be collected, and then the polygonal boundaries of each physical defect in the film scan images can be marked. Each physical defect can then be extracted and converted into a square area boundary using zero-filling, thus creating a sample library containing physical defects.
[0156] Among them, in order to accurately record the number of dirty spots and scratches, each film scan image can be divided into multiple pixel areas of 256x256 size, and the number of two types of defects (scratches and dirty spots) can be counted for each pixel area, that is, the number of defects of each physical defect in each film scan image is counted, and then the maximum likelihood estimation is performed on the counted number of defects of each physical defect, and the gamma distribution model that best represents the defect data characteristics of each physical defect is fitted. Then, for each original video sample, the target number of defects can be sampled based on the gamma distribution model corresponding to each physical defect, that is, the gamma distribution is used for sampling for each physical defect to obtain the target number of defects for each physical defect to be added to the video frame in the original video sample.
[0157] Among them, Perlin noise can be used to approximate the preset spatial noise distribution (that is, spatial defect density, spatial density noise distribution, etc., that is, the distribution of noise in three-dimensional space), so that each physical defect can independently extract its position information from the simulated spatial density noise distribution (that is, the noise value extracted from the spatial density noise distribution is used as the position information of the physical defect), and a rotation angle can be extracted from the uniform distribution within a preset rotation angle range (such as [-180°, 180°]) to simulate the physical defects in any direction in two-dimensional space. The physical defects of the same shape can be rotated by the rotation angle, so that physical defects with more distribution forms can be generated.
[0158] Among them, physical defects matching the target defect quantity of each physical defect can be generated based on the position information and rotation angle matching the target defect quantity of each physical defect, and then the generated physical defects can be superimposed on the normal video frame of the original video sample by using image fusion technology known in the art, such as Alpha Blending, and then the pixel transparency of each physical defect can be adjusted so that the physical defects and the video frame background can be naturally integrated, which is conducive to making the physical defects in the damaged video sample have a more realistic fusion and superposition effect.
[0159] Then, the damaged video frames in each damaged video sample and the mask images corresponding to the damaged video frames can be obtained according to the differences between each original video sample and the damaged video sample corresponding to each original video sample in step S63. At this time, the mask images can indicate the defective areas where the physical defects are located. By constructing a sample data set corresponding to the physical defects, a defect detection model for detecting physical defects can be trained.
[0160] It should be understood that those skilled in the art can use a model training method known in the art to train a defect detection model using a sample data set, and the embodiments of the present disclosure are not limited to this. Those skilled in the art can use sample data sets corresponding to different types of defects to train a defect detection model for detecting different defects, and then can use the trained defect detection model to implement video defect detection.
[0161] For example, Figure 6 A schematic diagram showing a process of detecting a flower screen defect is shown in FIG. Figure 6 As shown, the three-parameter damage model can be used to construct a flower screen dataset (i.e., a sample dataset corresponding to the flower screen defect), and the flower screen dataset can be used to train the defect detection model. Then, the trained flower screen defect detection model can be used to output a flower screen defect map (i.e., a target defect map used to characterize the defect area of the predicted flower screen defect) and a flower screen defect confidence (i.e., the probability of the existence of a flower screen defect in the video frame); based on the flower screen defect map and the flower screen defect confidence, the defect severity of the flower screen defect in the video frame is evaluated, that is, the flower screen defects in the video frame are divided into unobvious / mild, severe and bad.
[0162] For example, Figure 7 A schematic diagram showing a global defect (ghost defect or wire drawing defect) detection process is shown in FIG. Figure 7 As shown, the video can be extracted based on an adaptive sampling interval to obtain a group of video frames, and then the extracted video frames can be input frame by frame into a video global defect detection model (i.e., a defect detection model for detecting ghosting defects or wiredrawing defects), and defect confidence and a target defect map can be output; based on the defect confidence and the target defect map, the defect severity of the global defects in the video frame can be evaluated; finally, a detection report can be output, which may include severity statistics "a total of 56 ghosting items were detected, of which 9 were bad and 47 were serious", production recommendations "the video ghosting defect is serious, and it is recommended not to produce ultra-high-definition video", and repair solutions "the current repair link does not support ghosting defect repair, and it is recommended to change the film source", and other information, which is not limited to the embodiments of the present disclosure.
[0163] For example, Figure 8 A schematic diagram showing a physical defect (scratches, dirt spots) detection process is shown, Figure 8 As shown, a defect simulation dataset is constructed (that is, a sample dataset with physical defects is constructed), a defect detection model including a feature extractor and a defect locator is trained, and the trained defect detection model is used to realize accurate positioning and identification of physical defects in video frames, that is, output a target defect map of the video frame, and then the severity of the defects can be analyzed based on the target defect map, that is, the physical defects in the video frame can be classified into mild, severe, and bad. For example, the more the number of physical defects and the more central the location, the greater the severity.
[0164] According to the embodiments of the present disclosure, starting from the data perspective, a three-parameter damage model is innovatively designed based on the principle of flower screen generation, thereby creating a flower screen data set with high simulation, automatically constructing a sample data set containing flower screen defects and a corresponding damaged area mask sequence, effectively solving the problem of data scarcity, and providing large-scale, high-quality training samples for model training; on the other hand, at the model level, a multi-task defect detection model based on deep learning is proposed, which can accurately detect flower screens in video frames and finely locate defect areas, and use a defect locator to output a target defect map of the flower screen area at the pixel level with high precision, thereby achieving accurate detection and identification of flower screen defects; and, based on the feature extractor and the defect locator, a flower screen classifier is introduced, and the flower screen detection accuracy is effectively improved through feature interaction fusion, while eliminating false alarms with low confidence, further improving the detection accuracy and robustness of the model, and being able to perform pixel-level recognition on video frames containing flower screens, and output a target defect map, defect confidence, and defect severity, and can also provide efficient and accurate video flower screen defect detection and evaluation for the video quality control system, provide precise guidance for subsequent video repair solutions, and effectively support services such as ultra-high-definition video selection.
[0165] According to the embodiments of the present disclosure, by formulating detailed defect definitions and annotation standards on the data side, the formation principles of global defects such as ghosting and wire drawing are deeply studied. Then, based on the formation principles of ghosting and wire drawing defects, a set of automated paired defect frame / target defect map generation processes are developed by introducing corresponding distortions into normal video frames. That is, a set of defect data set automatic generation processes are designed, which can construct a large-scale global defect data set with pixel-level labels (target defect map) and whole-image defect category labels, making it possible to train a global defect detection model driven by big data; based on the defect data set with pixel-level target defect map labels built by the data side, a global defect detection model driven by big data is constructed. According to the data collected, on the algorithm side, an end-to-end defect detection model based on a multi-task learning architecture is proposed to accurately identify ghosting and brushing defects in the video. The defect locator is used to output a precise target defect map, and the defect area at the pixel level can be output. The defect classifier is used to interactively fuse various features, which can help to accurately filter out video frames with low confidence, significantly reducing the false detection rate of defects. It can accurately detect multi-dimensional information such as defect confidence, pixel-level target defect map, image single frame / video overall defect severity, defective video clips, etc., to realize business implementation and effectively support video media delivery, ultra-high-definition video selection, old film restoration and other businesses.
[0166] According to the embodiments of the present disclosure, a data construction scheme simulating real film damage is designed on the data side based on the principle of formation of dirty spots and scratch defects, and a sample data set for defect simulation is constructed. On the model side, a feature extractor based on the Transformer module + multi-scale feature fusion accurately segments the defect area. By training the deep learning model, the model gradually masters various defect features during the learning process, and can accurately identify frames or images containing defects at the pixel level. It can provide efficient and accurate detection and evaluation of dirty spots and scratches for the video quality control system, and can also support the old film restoration business and assist related algorithms in improving the video restoration effect.
[0167] According to the embodiments of the present disclosure, an automated construction process for a defect dataset simulating real film damage is proposed to create a sample dataset containing dirty spot scratch defect video frames, which is used to simulate real old film damage to generate defect frames or target defect maps containing dirty spot scratch defects, and successfully introduce corresponding defects into normal video frames, which greatly enriches the source of training data and solves the problem of dirty spot scratch detection in old films in the industry; on the model side, a defect detection model based on Transformer module + multi-scale feature fusion is proposed, which can perform pixel-level recognition of video frames containing defects to achieve accurate segmentation of defective areas, and train the model using the constructed sample dataset. By gradually mastering the characteristics of various defects, it is possible to perform pixel-level analysis and identification of frames or images containing defects, and realize pixel-level identification of video frames containing dirty spots and scratches. A set of defect severity evaluation standards are proposed based on actual business needs. For each detected dirty spot or scratch defect, its position, number, area, length, width, grayscale difference and other characteristic parameters can be calculated, and the number of defects can be used as a standard to measure the severity of the damage. According to the degree of impact on the visual effect, the defects are divided into minor, serious and severe levels. Finally, the defect characteristic parameters and defect severity can be output to provide precise guidance for subsequent old film restoration algorithms, effectively supporting ultra-high-definition video selection and old film restoration.
[0168] Fig. 9 A block diagram of a video defect detection device according to an embodiment of the present disclosure is shown as follows: Figure 8 As shown, the device comprises:
[0169] An acquisition module 901 is used to acquire a video frame of a video to be detected;
[0170] A feature extraction module 902 is used to extract a shallow feature map and a deep feature map of the video frame;
[0171] A defect map determining module 903 is used to determine a defect map corresponding to the video frame according to the shallow feature map and the deep feature map, wherein the defect map represents a defect area where a defect in the video frame is predicted to be located;
[0172] The result determination module 904 is used to determine the defect detection result corresponding to the video frame according to the shallow feature map, the deep feature map and the defect map, and the defect detection result is used to indicate whether the video frame has defects.
[0173] In a possible implementation, extracting the shallow feature map and the deep feature map of the video frame includes: dividing the video frame into multiple image blocks; inputting the multiple image blocks into a converter module to obtain a multi-scale feature map extracted by N layers of converter units in the converter module, wherein a first scale feature map extracted by a first layer of converter units is used as the shallow feature map, and N is a positive integer; fusing the second scale feature map to the Nth scale feature map output by the second layer of converter units to the Nth layer of converter units in the converter module to obtain a first fused feature map; and determining the deep feature map based on the first fused feature map.
[0174] In a possible implementation, determining the deep feature map based on the first fused feature map includes: performing dimensionality reduction processing on the first fused feature map to obtain a second fused feature map; performing self-attention extraction processing on the second fused feature map using multiple window attention mechanisms to obtain multiple self-attention feature maps, wherein the window sizes used to extract self-attention in different window attention mechanisms are different; performing pooling processing on the second fused feature map to obtain a pooling feature map; performing channel splicing on the second fused feature map, the multiple self-attention feature maps and the pooling feature map to obtain a first spliced feature map; performing dimensionality reduction processing on the first spliced feature map to obtain the deep feature map.
[0175] In a possible implementation, determining the defect map corresponding to the video frame according to the shallow feature map and the deep feature map includes: performing dimensionality reduction processing on the shallow feature map to obtain a first shallow feature map; based on the resolution of the first shallow feature map, upsampling the deep feature map to obtain a first deep feature map, the first deep feature map and the first shallow feature map having the same resolution; channel-splicing the first shallow feature map and the first deep feature map to obtain a second spliced feature map; performing dimensionality reduction processing on the second spliced feature map to obtain a defect map, the defect map representing a defect area where the predicted video frame defect is located; based on the original resolution of the video frame, upsampling the defect map to obtain a target defect map that matches the original resolution of the video frame.
[0176] In a possible implementation, the defect detection result corresponding to the video frame is determined according to the shallow feature map, the deep feature map and the defect map, including: performing feature extraction on the shallow feature map to obtain a second deep feature map, and performing dimensionality reduction processing on the second deep feature map to obtain a first intermediate feature map; based on the resolution of the shallow feature map, upsampling the first intermediate feature map to obtain a second intermediate feature map, and the second intermediate feature map has the same resolution as the shallow feature map; performing dimensionality reduction processing on the shallow feature map, the first deep feature map and the defect map respectively to obtain a second shallow feature map, a third deep feature map and a first defect map; performing channel stitching on the second intermediate feature map, the second shallow feature map, the third deep feature map and the first defect map to obtain a third stitching feature map; performing dimensionality reduction processing on the third stitching feature map to obtain a defect confidence, and the defect detection result includes the defect confidence, and the defect confidence represents the probability that there is a defect in the video frame.
[0177] In one possible implementation, the device also includes: a severity assessment module for determining the defect severity of the video frame based on at least one of the position, size and number of defect areas represented by the target defect map when the defect detection result indicates that the video frame has defects.
[0178] In a possible implementation, the device further includes: a defect segment determination module, configured to determine video segments in the video that have continuous defects based on defect detection results of a plurality of video frames in the video.
[0179] In a possible implementation, the device further includes: a repair module, configured to repair the defective video frame according to a target defect map of the defective video frame to obtain a repaired video frame.
[0180] In a possible implementation, the device described using a defect detection model includes a feature extractor, a defect locator and a defect classifier; wherein the feature extraction module is used to use the feature extractor to extract a shallow feature map and a deep feature map of the video frame, the defect map determination module is used to use the defect locator to determine the defect map corresponding to the video frame according to the shallow feature map and the deep feature map, and the result determination module is used to use the defect classifier to determine the defect detection result corresponding to the video frame according to the shallow feature map, the deep feature map and the defect map.
[0181] In a possible implementation, the defect detection model is trained using a sample data set; wherein the sample data set is obtained through the following process: obtaining a plurality of original video samples; performing random damage processing on the plurality of original video samples respectively to obtain damaged video samples corresponding to each original video sample, wherein each damaged video sample contains at least one damaged video frame with defects; according to the difference between each original video sample and the corresponding damaged video sample, obtaining a damaged video frame in each damaged video sample and a mask map corresponding to the damaged video frame, wherein the mask map is used to indicate a defective area where the defect is located in the damaged video frame; wherein the sample data set includes a plurality of damaged video samples corresponding to the plurality of original video samples, a mask map of the damaged video frame in each damaged video sample, and a category label of each video frame in each damaged video sample, wherein the category label is used to indicate whether the video frame is a damaged video frame or an original video frame that has not been damaged.
[0182] In a possible implementation, the defects in the video frame include a screen noise defect caused by partial data damage during video transmission; wherein, when the defect detection model is used to detect the screen noise defect, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: based on a preset damage model, the original video streams of the multiple original video samples are subjected to data damage processing to obtain damaged video streams corresponding to each original video sample; and the damaged video streams corresponding to each original video sample are parsed using a video parser to obtain damaged video samples corresponding to each original video sample; wherein the damage model is used to indicate the damage ratio, damage position and damage length, the damage ratio represents the ratio of the damaged video frame to the original video sample, the damage position represents the position of the damaged video frame in the original video sample, and the damage length represents the length of the defective area in the damaged video frame.
[0183] In a possible implementation, the defects in the video frames include ghosting defects caused by overlapping adjacent frames during video format conversion; wherein, when the defect detection model is used to detect the ghosting defects, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: for any original video sample, estimating the motion area of each frame of the original video sample, the object in the motion area has a motion state, and determining at least one candidate ghost frame according to the size of the motion area of each frame of the original video sample; overlapping each candidate ghost frame in the original video sample with each adjacent video frame of the candidate ghost frame to obtain a damaged video sample.
[0184] In one possible implementation, the defects in the video frame include wiredrawing defects caused by interpolating odd and even rows of different frames of the original frame rate video into the same frame of the new frame rate video during the frame rate conversion of the interlaced scanned video frame, and the wiredrawing defect has a horizontal comb tooth shape; wherein, when the defect detection model is used to detect wiredrawing defects, the multiple original video samples are randomly damaged respectively to obtain damaged video samples corresponding to each original video sample, including: referring to the principle of generating the wiredrawing defect, the wiredrawing defect is randomly introduced into at least one video frame of each original video sample to obtain a damaged video sample corresponding to each original video sample.
[0185] In a possible implementation, the defects in the video frame include physical defects caused by physical damage to the video film; the physical defects include linear marks caused by physical scratches in the video film, and / or irregular spots caused by stains or impurities of non-image structures appearing on the chemical coating of the video film; wherein, when the defect detection model is used to detect the physical defects, the multiple original video samples are subjected to random damage processing respectively to obtain damaged video samples corresponding to each original video sample, including: obtaining multiple film scan images, and marking the regional boundaries of the physical defects in each film scan image, wherein the film scan image is an image obtained by scanning the video film with the physical damage; dividing each film scan image into multiple pixel areas of a specified size, and based on the regional boundaries of the physical defects marked in each film scan image, counting the number of defects of each physical defect appearing in each pixel area; and performing random damage processing on the multiple pixels by performing random damage processing on the multiple original video samples to obtain damaged video samples corresponding to each original video sample. The number of defects of each physical defect appearing in the area is estimated by maximum likelihood, and a gamma distribution model corresponding to each physical defect is fitted, and the gamma distribution model is used to characterize the quantity distribution characteristics of each physical defect; for any original video sample, based on the gamma distribution model corresponding to each physical defect, the target defect number of each physical defect to be added to the video frame in the original video sample is sampled; based on the target defect number of each physical defect, position information matching the target defect number is extracted for each physical defect from a preset spatial noise distribution, and a rotation angle matching the target defect number is extracted for each physical defect from a preset rotation angle range, the position information is used to indicate the pixel position of the physical defect, and the rotation angle is used to indicate the direction of the physical defect; based on the position information and rotation angle matching the target defect number of each physical defect, the physical defect matching the target defect number corresponding to each physical defect is fused into at least one video frame of the original video sample to obtain a damaged video sample.
[0186] According to the device of the embodiment of the present disclosure, pixel-level defect areas can be predicted by shallow feature maps and deep feature maps based on video frames. This process is equivalent to preliminarily screening video frames with defects. By using shallow feature maps, deep feature maps and defect maps, defect detection results can be determined more accurately, that is, whether there are defects in the video frames can be judged more accurately. In particular, the introduction of defect maps is equivalent to introducing an attention mechanism to pay more attention to defective areas. This can effectively improve the accuracy of defect detection results, thereby helping to reduce the false detection rate of defect detection.
[0187] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0188] The embodiment of the present disclosure also provides a computer-readable storage medium on which computer program instructions are stored, and the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium can be a volatile or non-volatile computer-readable storage medium.
[0189] An embodiment of the present disclosure further proposes an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to implement the above method when executing the instructions stored in the memory.
[0190] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above method.
[0191] Fig.10 1 is a block diagram of an electronic device 1900 according to an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal device. Fig.10 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.
[0192] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as Windows Server 2003. TM , Mac OS X TM , Unix TM ,Linux TM , FreeBSD TM or similar.
[0193] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.
[0194] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.
[0195] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.
[0196] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.
[0197] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.
[0198] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.
[0199] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0200] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.
[0201] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.
[0202] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.
Claims
1. A video defect detection method, characterized in that: include: Obtain a video frame of the video to be detected; Extracting a shallow feature map and a deep feature map of the video frame; Determine a defect map corresponding to the video frame according to the shallow feature map and the deep feature map, wherein the defect map represents a defect area where a defect in the video frame is predicted to be located; A defect detection result corresponding to the video frame is determined according to the shallow feature map, the deep feature map and the defect map, and the defect detection result is used to indicate whether the video frame has defects.
2. The method according to claim 1, characterized in that The extracting of the shallow feature map and the deep feature map of the video frame includes: Dividing the video frame into a plurality of image blocks; Inputting the plurality of image blocks into a converter module to obtain a multi-scale feature map extracted by N layers of converter units in the converter module, wherein a first-scale feature map extracted by a first-layer converter unit is used as the shallow feature map, and N is a positive integer; Fusing the second scale feature map to the Nth scale feature map output by the second layer converter unit to the Nth layer converter unit in the converter module to obtain a first fused feature map; The deep feature map is determined according to the first fused feature map.
3. The method according to claim 2, characterized in that The step of determining the deep feature map according to the first fused feature map comprises: Performing dimensionality reduction processing on the first fused feature map to obtain a second fused feature map; Using multiple window attention mechanisms to perform self-attention extraction processing on the second fused feature map respectively, to obtain multiple self-attention feature maps, wherein the window sizes used for extracting self-attention in different window attention mechanisms are different; Performing pooling processing on the second fused feature map to obtain a pooled feature map; Channel-joining the second fused feature map, the multiple self-attention feature maps, and the pooled feature map to obtain a first joined feature map; Perform dimensionality reduction processing on the first concatenated feature map to obtain the deep feature map.
4. The method according to any one of claims 1 to 3, characterized in that: The step of determining a defect map corresponding to the video frame according to the shallow feature map and the deep feature map includes: Performing dimensionality reduction processing on the shallow feature map to obtain a first shallow feature map; Based on the resolution of the first shallow feature map, upsampling the deep feature map to obtain a first deep feature map, where the first deep feature map has the same resolution as the first shallow feature map; Channel-joining the first shallow feature map and the first deep feature map to obtain a second joined feature map; Performing dimensionality reduction processing on the second splicing feature map to obtain the defect map; Based on the original resolution of the video frame, the defect map is upsampled to obtain a target defect map that matches the original resolution of the video frame.
5. The method according to claim 4, characterized in that The determining, according to the shallow feature map, the deep feature map and the defect map, a defect detection result corresponding to the video frame includes: Performing feature extraction on the shallow feature map to obtain a second deep feature map, and performing dimensionality reduction processing on the second deep feature map to obtain a first intermediate feature map; Based on the resolution of the shallow feature map, upsampling the first intermediate feature map to obtain a second intermediate feature map, where the second intermediate feature map has the same resolution as the shallow feature map; Performing dimensionality reduction processing on the shallow feature map, the first deep feature map and the defect map respectively to obtain a second shallow feature map, a third deep feature map and a first defect map; Perform channel stitching on the second intermediate feature map, the second shallow feature map, the third deep feature map, and the first defect map to obtain a third stitching feature map; A dimension reduction process is performed on the third splicing feature map to obtain a defect confidence, and the defect detection result includes the defect confidence, and the defect confidence represents the probability that a defect exists in a video frame.
6. The method according to claim 4, characterized in that The method further comprises: When the defect detection result indicates that the video frame has defects, the defect severity of the video frame is determined according to at least one of the position, size and number of defect areas represented by the target defect map.
7. The method according to claim 1, characterized in that The method further comprises: According to defect detection results of a plurality of video frames in the video, video segments in the video that continuously have defects are determined.
8. The method according to claim 4, characterized in that The method further comprises: According to the target defect map of the defective video frame, the defective video frame is repaired to obtain a repaired video frame.
9. The method according to any one of claims 1 to 5, characterized in that: Implementing the method according to any one of claims 1 to 5 using a defect detection model, wherein the defect detection model comprises a feature extractor, a defect locator, and a defect classifier; Among them, the feature extractor is used to extract the shallow feature map and the deep feature map of the video frame, the defect locator is used to determine the defect map corresponding to the video frame based on the shallow feature map and the deep feature map, and the defect classifier is used to determine the defect detection result corresponding to the video frame based on the shallow feature map, the deep feature map and the defect map.
10. The method according to claim 9, characterized in that The defect detection model is trained using a sample data set; wherein the sample data set is obtained through the following process: Obtain multiple original video samples; Performing random damage processing on the multiple original video samples respectively to obtain damaged video samples corresponding to the original video samples, wherein each damaged video sample includes at least one damaged video frame with defects; According to the difference between each original video sample and the corresponding damaged video sample, a damaged video frame in each damaged video sample and a mask image corresponding to the damaged video frame are obtained, wherein the mask image is used to indicate a defective area where a defect is located in the damaged video frame; The sample data set includes multiple damaged video samples corresponding to the multiple original video samples, a mask map of the damaged video frame in each damaged video sample, and a category label of each video frame in each damaged video sample, wherein the category label is used to indicate whether the video frame is a damaged video frame or an original video frame that has not been damaged.
11. The method according to claim 10, characterized in that The defects in the video frame include a screen defect caused by partial data damage during video transmission; Wherein, when the defect detection model is used to detect the flower screen defect, the multiple original video samples are randomly damaged to obtain damaged video samples corresponding to the original video samples, including: Based on a preset damage model, performing data damage processing on the original video streams of the multiple original video samples to obtain damaged video streams corresponding to the respective original video samples; The damaged video stream corresponding to each original video sample is parsed by using a video parser to obtain a damaged video sample corresponding to each original video sample; Among them, the damage model is used to indicate the damage ratio, damage position and damage length. The damage ratio represents the ratio of the damaged video frame to the original video sample, the damage position represents the position of the damaged video frame in the original video sample, and the damage length represents the length of the defective area in the damaged video frame.
12. The method according to claim 10, characterized in that The defects in the video frames include ghosting defects caused by overlapping of adjacent frames during video format conversion; Wherein, when the defect detection model is used to detect the ghosting defect, the random damage processing is performed on the multiple original video samples respectively to obtain damaged video samples corresponding to the respective original video samples, including: For any original video sample, estimating a motion region of each video frame in the original video sample, wherein an object in the motion region has a motion state, and determining at least one candidate ghost frame according to the size of the motion region of each video frame in the original video sample; Each candidate ghost frame in the original video sample is overlapped with a video frame adjacent to each candidate re-frame to obtain a damaged video sample.
13. The method according to claim 10, characterized in that The defects in the video frame include wire drawing defects caused by interpolating odd and even lines of different frames of the original frame rate video to the same frame of the new frame rate video during the frame rate conversion of the interlaced scanned video frame; Wherein, when the defect detection model is used to detect the wire drawing defect, the multiple original video samples are subjected to random damage processing respectively to obtain damaged video samples corresponding to the respective original video samples, including: Referring to the generation principle of the wire drawing defect, the wire drawing defect is randomly introduced into at least one video frame in each original video sample to obtain a damaged video sample corresponding to each original video sample.
14. The method according to claim 10, characterized in that The defects in the video frame include physical defects caused by physical damage to the video film; the physical defects include linear marks caused by physical scratches in the video film, and / or irregular spots caused by stains or impurities of non-image structures appearing on the chemical coating of the video film; Wherein, when the defect detection model is used to detect the physical defect, the random damage processing is performed on the multiple original video samples to obtain damaged video samples corresponding to the respective original video samples, including: Acquire multiple film scan images and mark the region boundary of the physical defect in each film scan image, wherein the film scan image is an image obtained by scanning a video film having the physical damage; Each film scan image is divided into a plurality of pixel regions of a specified size, and based on the region boundaries of the physical defects marked in each film scan image, the number of defects of each physical defect occurring in each pixel region is counted respectively; By performing maximum likelihood estimation on the number of defects of each physical defect occurring in multiple pixel regions, a gamma distribution model corresponding to each physical defect is fitted, wherein the gamma distribution model is used to characterize the quantity distribution characteristics of each physical defect; For any original video sample, based on the gamma distribution model corresponding to each physical defect, a target defect number of each physical defect to be added to the video frame in the original video sample is sampled; Based on the target defect quantity of each physical defect, extracting position information matching the target defect quantity for each physical defect from a preset spatial noise distribution, and extracting a rotation angle matching the target defect quantity for each physical defect from a preset rotation angle range, the position information being used to indicate a pixel position of the physical defect, and the rotation angle being used to indicate a direction of the physical defect; Based on the position information and the rotation angle that match the target defect quantity of each physical defect, the physical defects that match the target defect quantity corresponding to each physical defect are fused into at least one video frame of the original video sample to obtain a damaged video sample.
15. A video defect detection device, characterized in that: include: An acquisition module, used for acquiring a video frame of a video to be detected; A feature extraction module, used to extract a shallow feature map and a deep feature map of the video frame; A defect map determining module, used to determine a defect map corresponding to the video frame according to the shallow feature map and the deep feature map, wherein the defect map represents a defect area where a defect in the predicted video frame is located; A result determination module is used to determine the defect detection result corresponding to the video frame according to the shallow feature map, the deep feature map and the defect map, and the defect detection result is used to indicate whether the video frame has defects.
16. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to implement the method described in any one of claims 1 to 14 when executing the instructions stored in the memory.
17. A non-volatile computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 14 is implemented.
Citation Information
Patent Citations
Blurred screen detection method and apparatus, device and medium
CN112183289A
Method for identifying blurred screen, device thereof and equipment and storage medium
CN113177529A
Transformer-based false video detection method
CN113837147A
Video frame deduplication method and device, electronic equipment and storage medium
CN114298992A
Remote sensing image change detection method based on local-global Transform network
CN116434069A
Cited By
Instrument processing production line management system based on artificial intelligence
CN119204831A
Video conference equipment inspection method, device, equipment, medium and product
CN120825572A
Video conference equipment inspection method, device, equipment, medium and product
CN120825572B
