Video enhancement method, device, equipment, readable storage medium and program product
Through multi-level feature distillation layer and channel merging technology, combined with the self-attention mechanism, it solves the problems of artifacts and clarity improvement in existing video enhancement technology, and achieves efficient video enhancement effects.
Patent Information
- Application Number
- CN202410918169.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-07-10
AI Technical Summary
Existing video enhancement technologies are prone to artifacts, such as jagged edges and color blocks, and have poor enhancement effects, making it difficult to effectively improve video clarity.
The video enhancement model uses a multi-level feature distillation layer to extract deep-level details through multi-level distillation of frame images. It combines channel merging and self-attention mechanisms to generate enhanced feature maps to avoid the acquisition of irrelevant details and ensure the enhancement effect.
Significantly improves the video enhancement effect, removes video compression artifacts, improves video picture clarity, and enhances the naturalness and effect of video enhancement.
Smart Images

Figure CN118469838B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of video processing technology, and in particular to a video enhancement method, device, equipment, readable storage medium and program product. Background Art
[0002] With the rapid development of computer technology, video has gradually become an indispensable medium for information dissemination, and its clarity is crucial to the efficiency and accuracy of information transmission. Therefore, the requirements for video clarity are getting higher and higher nowadays.
[0003] In related technologies, video sharpening is usually used to enhance the clarity of a video, for example, the pixel intensity of the high-frequency part of a frame image in a video is enhanced to achieve the purpose of enriching edge information. However, this video enhancement method is prone to artifacts, such as edge jaggedness, color blocks, etc., and the video enhancement effect is poor. Summary of the invention
[0004] Based on this, it is necessary to provide a video enhancement method, device, equipment, readable storage medium and program product that can improve the video enhancement effect in response to the above technical problems.
[0005] The present application provides a video enhancement method, comprising:
[0006] Acquire multiple frame images of an input video, and for each frame image, input the frame image into a trained video enhancement model, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each of the basic network units includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation;
[0007] In the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and the effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0008] According to the enhanced feature map corresponding to the final basic network unit, an enhanced image corresponding to the frame image is obtained, and according to the enhanced image corresponding to each frame image, an enhanced video corresponding to the input video is obtained.
[0009] The present application also provides a video enhancement device, comprising:
[0010] An image acquisition module is used to acquire multiple frame images of an input video, and for each frame image, the frame image is input into a trained video enhancement model, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each of the basic network units includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation;
[0011] A first channel merging module is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and to merge the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0012] The video enhancement module is used to obtain an enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the final basic network unit, and to obtain an enhanced video corresponding to the input video according to the enhanced image corresponding to each frame image.
[0013] In some embodiments, the video enhancement model also includes a normalization layer and a channel expansion layer, and the device also includes an initial feature map determination module, the initial feature map determination module is used to use the normalization layer to standardize the frame image to obtain a standard image; use the channel expansion layer to perform channel expansion on the standard image to obtain the initial feature map of the frame image.
[0014] In some embodiments, when the current basic network unit is not the first basic network unit among the at least two basic network units, the first channel merging module is further used to perform a first-level distillation operation on the enhanced feature map corresponding to the previous basic network unit of the current basic network unit in the first-level distillation layer of the multi-level feature distillation layer to obtain a first-level distillation feature map; in the middle distillation layer of the multi-level feature distillation layer, obtain a remaining channel feature map obtained by performing channel separation on the distillation feature map obtained by the previous-level distillation operation, perform a distillation operation on the remaining channel feature map, and obtain an intermediate-level distillation feature map; in the last distillation layer of the multi-level feature distillation layer, obtain a remaining channel feature map obtained by performing channel separation on the distillation feature map obtained by the previous-level distillation operation, perform a last-level distillation operation on the remaining channel feature map, and obtain an effective channel feature map obtained by the last-level distillation operation; and perform channel merging on the effective channel feature maps in the distillation feature maps obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit.
[0015] In some embodiments, the device also includes a channel characteristic graph determination module, which is used to perform channel separation on the distillation characteristic graph obtained by the previous level distillation operation to obtain channel characteristic graphs of each channel; starting from the first channel, according to the channel order of each channel, the channel characteristic graphs of a preset number of channels with later channel numbers are used as valid channel characteristic graphs in the distillation characteristic graph obtained by the previous level distillation, and the channel characteristic graphs of the remaining channels are used as the remaining channel characteristic graphs in the distillation characteristic graph obtained by the previous level distillation.
[0016] In some embodiments, each basic network unit also includes a channel activation layer based on a self-attention mechanism, and the device also includes a distillation feature map determination module, which is used to input the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit into the channel activation layer in the current basic network unit, and perform channel activation processing on the multi-level distillation feature map based on the self-attention mechanism to obtain a channel-activated multi-level distillation feature map.
[0017] In some embodiments, the device also includes an enhanced feature map determination module, which is used to obtain an enhanced feature map corresponding to the current basic network unit in the current basic network unit based on the multi-level distillation feature map corresponding to the current basic network unit, the multi-level distillation feature map activated by the channel, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0018] In some embodiments, the multi-level distillation feature map corresponding to the current basic network unit includes channel distillation feature maps of each channel. The distillation feature map determination module is further used to perform a self-attention mechanism on the multi-level distillation feature map to determine the importance corresponding to each channel in the multi-level distillation feature map; and perform dot multiplication of the importance corresponding to each channel and the channel distillation feature map to obtain a channel-activated multi-level distillation feature map.
[0019] In some embodiments, the enhanced feature map determination module is used to superimpose the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel to obtain a superimposed feature map; perform channel transformation on the superimposed feature map to obtain a transformed feature map, and superimpose the transformed feature map and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit to obtain an enhanced feature map corresponding to the current basic network unit.
[0020] In some embodiments, the video enhancement module is used to superimpose the initial feature map of the frame image and the enhanced feature map corresponding to the last basic network unit to obtain a target enhanced feature map, and determine the enhanced image corresponding to the frame image based on the target enhanced feature map.
[0021] In some embodiments, the video enhancement model also includes a denormalization layer and a channel shrinkage layer, and the video enhancement module is further used to use the channel shrinkage layer to perform channel shrinkage processing on the target enhancement feature map to obtain an output feature map, and the number of channels of the output feature map is the same as the number of channels of the frame image; and use the denormalization layer to perform denormalization processing on the output feature map to obtain an enhanced image corresponding to the frame image.
[0022] The present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned video enhancement method when executing the computer program.
[0023] The present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned video enhancement method are implemented.
[0024] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned video enhancement method when executed by a processor.
[0025] The above-mentioned video enhancement method, device, equipment, readable storage medium and program product obtain an input video to determine multiple frame images of the input video. For each frame image, the frame image is input into a trained video enhancement model. The video enhancement model includes at least two basic network units, each of which is connected in sequence. Each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation. In the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined. The distillation feature map obtained by the first-level distillation is channel-separated to obtain an effective channel feature map that can reflect deep-level details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation as the remaining channel feature map obtained by the previous level of distillation, the deep-level details are continued to be distilled out, and the effective channel feature map corresponding to each level of distillation is accurately extracted. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature maps obtained by each remaining level of distillation are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. In this way, the effective extraction of useful details in the input of the current basic network unit is achieved, and the acquisition of irrelevant details is avoided, ensuring the enhancement effect. Among them, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. Finally, according to the enhanced feature map corresponding to the last basic network unit, the frame image can be effectively enhanced, and the enhanced image corresponding to each frame image can be obtained. Then, based on the enhanced image corresponding to each frame image, the enhanced video corresponding to the input video with good enhancement effect can be obtained, thereby improving the video enhancement effect.
[0026] The present application provides a video enhancement model processing method, including:
[0027] Acquire training samples, each of the training samples includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image;
[0028] Inputting the second sample frame image into a video enhancement model to be trained, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, each of which includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation;
[0029] In the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and effective channel feature maps in the distillation feature map obtained by each level of distillation are channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0030] According to the enhanced feature map corresponding to the final basic network unit, a sample enhanced image corresponding to the second sample frame image is obtained. Based on the difference between the sample enhanced image and the first sample frame image, a target loss is constructed. The video enhancement model is updated with minimizing the target loss as the training goal.
[0031] The present application also provides a video enhancement model processing device, comprising:
[0032] A sample acquisition module, used for acquiring training samples, each of the training samples includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image;
[0033] An image input module, used for inputting the second sample frame image into a video enhancement model to be trained, wherein the video enhancement model comprises at least two basic network units, each of which is connected in sequence, each of which comprises a multi-level feature distillation layer, and the multi-level feature distillation layer comprises at least two levels of distillation;
[0034] A second channel merging module is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and to merge the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0035] The model updating module is used to obtain a sample enhanced image corresponding to the second sample frame image according to the enhanced feature map corresponding to the final basic network unit, construct a target loss based on the difference between the sample enhanced image and the first sample frame image, and update the video enhancement model with minimizing the target loss as the training goal.
[0036] In some embodiments, a sample acquisition module is used to acquire a first sample video, wherein the first sample video includes multiple first sample frame images; blurring the first sample video to obtain a blurred video; performing video compression on the blurred video to obtain a second sample video; and constructing a training sample based on acquiring the first sample frame image and the second sample frame image at the same timestamp from the first sample video and the second sample video.
[0037] The present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned video enhancement model processing method when executing the computer program.
[0038] The present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the above-mentioned video enhancement model processing method are implemented.
[0039] The present application also provides a computer program product, including a computer program, which implements the steps of the above-mentioned video enhancement model processing method when executed by a processor.
[0040] The video enhancement model processing method, device, computer equipment, computer-readable storage medium and computer program product obtain training samples to determine that each training sample includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image. The second sample frame image is input into the video enhancement model to be trained, and the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; in the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined, and the distillation feature map obtained by the first-level distillation is channel-separated to obtain an effective channel feature map that can reflect deep-level details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation as the remaining channel feature map obtained by the previous level of distillation, the deep-level details are continued to be distilled out, so as to obtain the effective channel feature map corresponding to each level of distillation. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature map obtained by each remaining level of distillation are channel-merged, and all the details extracted by the multi-level distillation are integrated to determine the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. Wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. According to the enhanced feature map corresponding to the basic network unit at the end, a sample enhanced image corresponding to the second sample frame image is obtained. Based on the difference between the sample enhanced image and the first sample frame image, a target loss is constructed. Taking minimizing the target loss as the training goal, the video enhancement model is updated to obtain a trained video enhancement model. When performing video enhancement processing, the trained video enhancement model can not only remove video compression artifacts, but also improve video picture clarity, thereby improving the video enhancement effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0042] Figure 1 A schematic diagram of the image comparison before and after video enhancement in the related technology;
[0043] Figure 2 A schematic diagram of the image comparison before and after the enhancement of the intensity in the related art;
[0044] Figure 3 A schematic diagram of contrast between subtitles before and after enhancing the intensity in the related art;
[0045] FIG4 is a diagram showing an application environment of a video enhancement method in one embodiment;
[0046] Figure 5 is a schematic flow chart of a video enhancement method in one embodiment;
[0047] Figure 6 A schematic flow chart of the steps for determining a characteristic diagram of a multi-stage distillation in an implementation;
[0048] Figure 7 is a schematic diagram of a model structure of a video enhancement model in one embodiment;
[0049] Figure 8 is a schematic diagram of a unit structure of a basic network unit in an embodiment;
[0050] Fig. 9 A schematic diagram of a process flow of a video enhancement model processing method in one embodiment;
[0051] Fig.10 A schematic diagram of constructing a training sample in one embodiment;
[0052] Fig.11 A schematic diagram of model training in one embodiment;
[0053] Fig.12 is a schematic flow chart of a video enhancement process in one embodiment;
[0054] Fig.13 is a structural block diagram of a video enhancement device in one embodiment;
[0055] Fig.14 is a structural block diagram of a video enhancement model processing device in one embodiment;
[0056] FIG. 15 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0058] To facilitate understanding, the relevant concepts are first explained.
[0059] JPEG is one of the most widely used image compression algorithms and formats, favored for its simplicity and fast encoding / decoding speed. JPEG compression divides the image into 8×8 blocks and applies a discrete cosine transform (DCT) to each block. The DCT coefficients involved in the DCT transform are then rounded to the nearest integer through a quantization table. It should be noted that the elements in the quantization table control the compression ratio and the rounding operation is the only lossy operation in the entire process. Among them, the quantization table is usually represented by an integer called a quality factor (QF), ranging from 0 to 100, where a lower quality factor means a smaller storage size, but there is more information loss.
[0060] Video compression artifacts: Specific visual errors caused by quantization noise during the video compression process.
[0061] Sampling without replacement: A sampling method in which individuals are selected one by one without returning them to the population for the next selection.
[0062] L1 loss function: A loss function in deep learning that measures the similarity between the predicted image and the true image, also known as the mean absolute error (MAE). Given P as the predicted image, G as the true image, h, w, c as the height, width, and number of channels of P and G, respectively, the L1 loss function is constructed using the following formula:
[0063]
[0064] in, represents the intensity value of the pixel at the position of channel k in row i, column j in P. Similarly, Represents the intensity value of the pixel at the i row, j column and k channel position in G.
[0065] Perceptual loss function: A loss function in deep learning that measures the similarity between the predicted image and the true image in the feature space.
[0066] Error backpropagation: A common method for training neural networks used in conjunction with an optimizer such as gradient descent. This method calculates the gradient of the loss function for all parameters in the neural network, and this gradient is fed back to the optimizer to update the parameters to minimize the loss function.
[0067] Optimizer: A method that guides a neural network to update its parameters based on gradients.
[0068] The video enhancement method provided in the embodiment of the present application involves artificial intelligence (AI) technology. Artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that the machines have the functions of perception, reasoning and decision-making.
[0069] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. Basic artificial intelligence technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, and mechatronics. Among them, the pre-trained model is also called a large model or a basic model. After fine-tuning, it can be widely used in downstream tasks in various major directions of artificial intelligence. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning. The video enhancement method provided in the embodiment of the present application specifically relates to computer vision technology.
[0070] In related technologies, video sharpening technology is usually used to enhance videos. Among them, video sharpening technology is a technology that enhances image edges frame by frame. For example, Unsharp Mask (USM) is a commonly used and easy-to-control video sharpening algorithm. Its basic principle is to first subtract the low-pass filtered image from the original image to obtain a high-frequency image, and then multiply the high-frequency image by a manually controllable enhancement intensity coefficient and add it to the original image, thereby enhancing the pixel intensity of the high-frequency part of the original image and achieving the purpose of enriching edge information.
[0071] However, the above-mentioned video enhancement principle is simple, the video enhancement effect is limited, and artifacts (video compression artifacts) are prone to occur, such as edge jaggedness, color block or ringing. Figure 1 As shown in FIG. , it is a schematic diagram of the image comparison before and after video enhancement in the related art. Figure 1 The original image in is unsharp masked and obtained Figure 1 In the enhanced image 1, there is obvious jagged edge phenomenon at the outline of the cartoon character in the enhanced image 1, and there is obvious color block phenomenon on the forehead of the cartoon character, and the enhancement effect is not good.
[0072] Related technologies also improve the enhancement effect by increasing the enhancement intensity. However, this method is prone to problems such as excessive local enhancement, artifacts, and unnaturalness, resulting in poor image quality. Figure 2 As shown in FIG. 1 , it is a schematic diagram of the image comparison before and after the enhancement in the related art. Figure 2 When the original image is enhanced by unsharp mask, the enhancement strength is increased to obtain Figure 2 Enhanced image 2 in the figure. The jagged edge phenomenon of the cartoon character's outline in enhanced image 2 still exists, and compared with enhanced image 1, the jagged feeling is more serious. The color block phenomenon on the cartoon character's forehead in enhanced image 2 still exists, and compared with enhanced image 1, the color block is more serious.
[0073] When there are subtitles in the original image, when the unsharp mask is used for enhancement, the subtitles will still have ringing phenomenon after increasing the enhancement strength. Figure 3 As shown, it is a schematic diagram of subtitle comparison before and after enhancement in the related art. Figure 3 The original subtitles are the subtitles in the original image, and the enhanced subtitles are the subtitles in the enhanced image 3, which is an image obtained by enhancing the intensity of the original image. Comparing the original subtitles and the enhanced subtitles, the enhanced subtitles produce oscillations at the places where the grayscale changes drastically, that is, the enhanced subtitles produce ringing.
[0074] In summary, it can be seen that the enhanced video obtained by the related technology is very easy to produce artifacts and the video enhancement effect is not good.
[0075] In view of this, an embodiment of the present application provides a video enhancement method, which obtains an input video to determine multiple frame images of the input video. For each frame image, the frame image is input into a trained video enhancement model, and the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation. In the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined. Channel separation is performed on the distillation feature map obtained by the first-level distillation to obtain an effective channel feature map that can reflect deep details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation to the remaining channel feature map obtained by the previous level of distillation, the deep details are continued to be distilled out, and the effective channel feature map corresponding to each level of distillation is accurately extracted. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature map obtained by each remaining level of distillation are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. In this way, the effective extraction of useful details in the input of the current basic network unit is achieved, and the acquisition of irrelevant details is avoided, ensuring the enhancement effect. Among them, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. Finally, according to the enhanced feature map corresponding to the last basic network unit, the frame image can be effectively enhanced, and the enhanced image corresponding to each frame image can be obtained. Then, based on the enhanced image corresponding to each frame image, the enhanced video corresponding to the input video with good enhancement effect can be obtained, thereby improving the video enhancement effect.
[0076] The video enhancement method provided in the embodiment of the present application can be applied in the application environment shown in FIG4. In which, the terminal 402 communicates with the server 404 through the network. The data storage system can store the data that the server 404 needs to process. The data storage system can be set up separately, can be integrated on the server 404, or can be placed on the cloud or other network servers.
[0077] In some embodiments, the terminal 402 can cooperate with the server 404 to perform the video enhancement method. Specifically, the terminal 402 sends the input video to the server 404, and the server 404 obtains multiple frame images of the input video. For each frame image, the frame image is input into the trained video enhancement model. The video enhancement model includes at least two basic network units, each of which is connected in sequence, and each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; in the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is multi-level distilled, and the server 404 merges the effective channel feature map in the distillation feature map obtained by each level of distillation to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit; wherein, the first level of distillation The input of the current basic network unit is targeted, and each remaining level of distillation is targeted at the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; the server 404 obtains the enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the last basic network unit, and obtains the enhanced video corresponding to the input video according to the enhanced image corresponding to each frame image. Optionally, the server 404 can return the enhanced video to the terminal 402.
[0078] In other embodiments, the terminal 402 and the server 404 may respectively execute the video enhancement method separately. In the case where the video enhancement model is deployed on the terminal 402 or the server 404, the video enhancement method provided by the embodiment of the present application may be executed on the input video respectively.
[0079] In some embodiments, the video enhancement model processing method can also be applied to the application environment shown in FIG. 4. For example, the terminal 402 sends the first sample video containing the first sample frame image to the server 404. The server 404 performs blur and compression processing on the obtained first sample video to obtain a second sample video. According to the first sample video and the second sample video, a training sample is determined. Each training sample includes a first sample frame image and a second sample frame image. The image quality of the first sample frame image is higher than the image quality of the second sample frame image. The server 404 inputs the second sample frame image into the video enhancement model to be trained. The video enhancement model includes at least two basic network units. Each basic network unit is connected in sequence. Each basic network unit includes a multi-level feature distillation layer. The multi-level feature distillation layer includes at least two levels of distillation. In the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is multi-level distilled. The effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit. The multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit. Among them, the first-level distillation is for the current basic network unit. The input of the unit, each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; the server 404 obtains the sample enhanced image corresponding to the second sample frame image according to the enhanced feature map corresponding to the last basic network unit, constructs the target loss based on the difference between the sample enhanced image and the first sample frame image, takes minimizing the target loss as the training goal, updates the video enhancement model, and obtains the trained video enhancement model.
[0080] Exemplarily, the server 404 may send the trained video enhancement model to the terminal 402 so that the terminal 402 can deploy the trained video enhancement model locally, so that the terminal 402 can independently execute the video enhancement method based on the trained video enhancement model.
[0081] It should be noted that the trained video enhancement model in the video enhancement method provided in the embodiment of the present application is obtained by using the video enhancement model processing method provided in the embodiment of the present application.
[0082] The terminal 402 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. The IoT devices may be smart TVs, smart car devices, etc. The portable wearable devices may be smart watches, smart bracelets, etc. The server 404 may be implemented by an independent server or a server cluster consisting of multiple servers, or by a cloud server.
[0083] In an exemplary embodiment, Figure 5 As shown, a video enhancement method is provided, and the method is applied to a computer device (for example, the terminal 402 in FIG. 4 or the server 404) as an example for description, including the following steps S502 to S506. Among them:
[0084] Step S502, obtain multiple frame images of the input video, and for each frame image, input the frame image into a trained video enhancement model, the video enhancement model includes at least two basic network units, each basic network unit is connected in sequence, each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation.
[0085] The input video is a video to be enhanced. Exemplarily, the input video may also be a video to be enhanced that contains at least one video compression artifact, for example, the video compression artifact may be but is not limited to edge jagged phenomenon, color block phenomenon, and ringing phenomenon.
[0086] Exemplarily, the input video may be a long video or a short video in a video client, or a recorded video obtained by recording a certain scene or a certain user by a multimedia device, etc. The frame image is an image obtained by decoding the input video.
[0087] The trained video enhancement model is a neural network model for video enhancement, which specifically enhances the clarity of the video, and can also refer to enhancing the clarity of the video while removing video compression artifacts. The video enhancement model includes at least two basic network units.
[0088] The video enhancement model includes at least two basic network units, each basic network unit is connected in sequence, the first basic network unit is the first basic network unit of at least two basic network units, and the last basic network unit is the last basic network unit of at least two basic network units. Exemplarily, the video enhancement model includes n basic network units connected in sequence, where n is a positive integer greater than or equal to 2. For example, based on actual resources, computing power and efficiency, the value of n can be set to any value such as 6, 12, 18, 24, etc. For example, 6 basic network units are connected in sequence, namely basic network unit 1, basic network unit 2, ..., basic network unit 6, wherein basic network unit 1 and basic network unit 6 are the first basic network unit and the last basic network unit, respectively.
[0089] Each basic network unit includes a multi-level feature distillation layer. The multi-level feature distillation layer is used to distill features. The multi-level feature distillation layer includes at least two levels of distillation, and each level of distillation (which can be understood as a distillation operation) is used to distill out useful (or effective) features. Exemplarily, the number of distillation levels (the number of distillation operations) involved in the multi-level feature distillation layer in each basic network unit can be determined based on actual resources, computing power, and efficiency.
[0090] Optionally, the computer device determines the input video to be enhanced from multiple locally stored input videos in response to user demand, or, whenever the computer device obtains a recorded video uploaded by a user, it uses the recorded video as the input video to be enhanced.
[0091] The computer device decodes the input video to obtain a plurality of frame images. For each frame image, the computer device calls a trained video enhancement model and inputs the frame image into the trained video enhancement model.
[0092] Step S504, in the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and the effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein, the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0093] The initial feature map of the frame image refers to the feature map obtained after channel expansion of the frame image. Channel expansion is used to increase the number of channels.
[0094] For example, when the frame image is an image in RGB (Red Green Blue) space, the frame image has a channel image of the R (Red) channel, a channel image of the G (Green) channel, and a channel image of the B (Blue) channel. Based on actual resources, computing power, and efficiency, the three channels of the frame image are expanded to channels, It is a positive integer greater than the number of channels of the frame image.
[0095] For example, Depends on the number of distillation stages m of the multi-stage distillation, for example, is an integer multiple of m. For example, when m is 4, then It can be any integer divisible by 4, such as 16, 32, 48, 64, etc.
[0096] When the current basic network is not the first basic network unit among at least two basic network units, the previous basic network unit is a basic network unit that is located before the current basic network unit and is adjacent to the current basic network unit. For example, n basic network units are connected in sequence, and for the current basic network unit j (j∈[2,n]), the previous basic network unit of the current basic network unit j is the basic network unit j-1.
[0097] The enhanced feature map is a feature map output by any basic network unit. Exemplarily, when the current basic network is the first basic network unit among at least two basic network units, the enhanced feature map corresponding to the current basic network unit is obtained by multi-stage distillation of the initial feature map of the frame image, and when the current basic network is not the first basic network unit among at least two basic network units, the enhanced feature map corresponding to the current basic network unit is obtained by multi-stage distillation of the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0098] The distillation feature graph refers to the feature graph obtained by distilling any level of a basic network unit. The distillation feature graph includes There are channel feature maps for each channel. Channel separation refers to The channels are divided into valid channels and remaining channels (non-valid channels). Optionally, the number of valid channels is less than the number of remaining channels.
[0099] The output of the multi-level feature distillation layer in each basic network unit is a multi-level distillation feature map, that is, a feature map obtained after multi-level distillation. The multi-level distillation feature map is used to determine the enhanced feature map of the corresponding basic network unit. It should be noted that the number of channels of each distillation feature map, each multi-level distillation feature map, and the initial feature map is the same. channels.
[0100] The effective channel refers to the channel that can reflect the useful features of deep details, and the remaining channel refers to the channel that needs to further explore more other useful features. It can be understood that the effective channel feature map refers to the feature map of the effective channel, and the remaining channel feature map is the feature map of the remaining channel.
[0101] Channel merging refers to the operation of merging the effective channel feature maps obtained from each level of distillation in order on the channel dimension according to the distillation order.
[0102] Optionally, after the computer device inputs the frame image into a trained video enhancement model, it obtains a corresponding initial feature map based on the frame image through channel expansion processing, inputs the initial feature map into the first basic network unit, performs multi-level distillation on the initial feature map to obtain a valid channel feature map obtained by each level of distillation, performs channel merging on each valid channel feature map to obtain a multi-level distillation feature map corresponding to the first basic network unit, and determines an enhanced feature map corresponding to the first basic network unit based on the multi-level distillation feature map corresponding to the first basic network unit.
[0103] Starting from the second basic network unit, multi-level distillation is performed on the enhanced feature map corresponding to the previous basic network unit to obtain the effective channel feature map obtained by each level of distillation. The effective channel feature maps are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit. Based on the multi-level distillation feature map corresponding to the current basic network unit, the enhanced feature map corresponding to the current basic network unit is determined.
[0104] Among them, during the multi-stage distillation process of the current basic network unit, if the current distillation is the first-stage distillation, the current distillation is used to distill the input of the current basic network unit; if the current distillation is not the first-stage distillation, the current distillation is used to distill the remaining channel characteristic graph obtained by the previous stage distillation, wherein the previous stage distillation is a distillation operation located before the current distillation and adjacent to the current distillation.
[0105] For example, the input of the first distillation of the first basic network unit is the initial feature map. The input of the first distillation of a non-first basic network unit is the enhanced feature map corresponding to the previous basic network unit. For the input of the non-first distillation of the first basic network unit, or for the input of the non-first distillation of the non-first basic network unit, the input of each distillation is the residual channel feature map obtained by channel separation of the distillation feature map obtained by the previous distillation.
[0106] In some embodiments, the video enhancement model also includes a normalization layer and a channel expansion layer, and the step of determining the initial feature map of the frame image includes: using the normalization layer to normalize the frame image to obtain a standard image; using the channel expansion layer to perform channel expansion on the standard image to obtain the initial feature map of the frame image.
[0107] The normalization layer is used to normalize the pixel values in the frame image. The standard image refers to the image output by the normalization layer. The channel expansion layer is used to perform channel expansion on the frame image. For example, the channel expansion layer can be a convolution layer with a convolution kernel of 3×3.
[0108] For example, for the image corresponding to channel c in the frame image , the following formula (1) is used for normalization to obtain the corresponding sub-image :
[0109] (1)
[0110] Among them, c is a channel in the frame image, c∈{R,G,B}, and They respectively represent the mean and standard deviation of the c channel obtained through statistics of a large amount of data.
[0111] The computer device merges the sub-images corresponding to each channel to obtain the standard image S corresponding to the frame image. After the computer device inputs the standard image S into the channel expansion layer, it uses the following formula (2) to perform channel expansion processing to obtain the corresponding initial feature map :
[0112] (2)
[0113] In formula (2) It is the convolution layer 1 with a convolution kernel of 3×3, which is the channel expansion layer.
[0114] In this embodiment, the frame image is standardized by using a standardization layer to adjust the distribution of pixel values in the frame image to unify the distribution of pixels and obtain a standard image, which is convenient for subsequent analysis and calculation and ensures the effectiveness of the enhancement process. The standard image is subjected to channel expansion processing by using a channel expansion layer to expand the number of channels of the feature map and obtain an initial feature map with a larger number of channels. In this way, more effective channel feature maps can be distilled out based on a larger number of channels, thereby ensuring the accuracy of multi-stage distillation and the video enhancement effect.
[0115] In some embodiments, Figure 6 As shown, it is a flowchart of the steps of determining a multi-level distillation characteristic graph in an implementation. When the current basic network unit is not the first basic network unit among at least two basic network units, multi-level distillation is performed on the input of the current basic network unit, and the effective channel characteristic graphs in the distillation characteristic graph obtained by each level of distillation are channel-merged to obtain a multi-level distillation characteristic graph corresponding to the current basic network unit, including:
[0116] Step S602: In a first-level distillation layer of the multi-level feature distillation layer, a first-level distillation operation is performed on an enhanced feature map corresponding to a previous basic network unit of the current basic network unit to obtain a first-level distillation feature map.
[0117] The multi-level feature distillation layer includes multiple distillation layers, each of which is used to perform a corresponding distillation operation. For example, the multi-level feature distillation layer includes a first-level distillation layer, a second-level distillation layer, ..., an m-th level distillation layer connected in sequence. Exemplarily, each distillation layer can be a convolution layer with a convolution kernel of 3×3.
[0118] The first-stage distillation characteristic diagram refers to the distillation characteristic diagram obtained by performing a first-stage distillation operation.
[0119] Step S604, in the middle distillation layer of the multi-level feature distillation layer, obtain the remaining channel feature graph obtained by performing channel separation on the distillation feature graph obtained by the previous level distillation operation, perform distillation operation on the remaining channel feature graph, and obtain the middle-level distillation feature graph.
[0120] The previous distillation operation is the previous distillation mentioned above. The intermediate distillation characteristic diagram refers to the distillation characteristic diagram obtained by performing an intermediate distillation operation (not the first distillation operation and not the last distillation operation). The intermediate distillation characteristic diagram includes an effective channel characteristic diagram and a residual channel characteristic diagram.
[0121] Step S606, in the last distillation layer of the multi-level feature distillation layer, obtain the remaining channel feature map obtained by performing channel separation on the distillation feature map obtained by the previous level distillation operation, perform the last level distillation operation on the remaining channel feature map, and obtain the effective channel feature map obtained by the last level distillation operation.
[0122] It can be understood that the last-stage distillation operation is the last distillation operation performed by the current basic network unit.
[0123] Step S608, merging the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit.
[0124] The above steps S602 to S608 are described by taking four-stage distillation as an example:
[0125] Step 6.1: For the current basic network unit k, in the first level distillation layer k.1 of the current basic network unit (kth basic network unit, k∈[1,4]), the computer device determines the input feature map input to the first level distillation layer k.1. If k is 1, the corresponding input feature map is the initial feature map of the frame image. ; If k is not 1, the corresponding input feature map is the enhanced feature map corresponding to the previous basic network unit k-1 .
[0126] The computer device uses the first-level distillation layer k.1 to perform convolution calculation on the input feature map and obtains Characteristic diagram of the first stage distillation of the channel , computer equipment Separate the channels and obtain Residual channel feature map of the channel and Effective channel feature map of the channel .
[0127] Step 6.2: In the second distillation layer k.2, the computer device uses the second distillation layer k.2 to Perform convolution calculation and get Second stage distillation characteristic diagram of the channel ,right Separate the channels and obtain Residual channel feature map of the channel and Effective channel feature map of the channel .
[0128] Step 6.3: In the third distillation layer k.3, the computer device uses the third distillation layer k.3 to Perform convolution calculation and get The third-stage distillation characteristic diagram of the channel ,right Separate the channels and obtain Residual channel feature map of the channel and Effective channel feature map of the channel .
[0129] Step 6.4: In the fourth distillation layer k.4, the computer device uses the fourth distillation layer k.4 to Perform convolution calculation and get Channel fourth-stage distillation characteristic diagram , directly Characteristic diagram of the effective channels obtained as the fourth stage of distillation.
[0130] Step 6.5: Computer equipment will , , and Merge channels in the channel dimension to obtain the multi-level distillation feature map corresponding to the kth basic network unit ,in, The number of channels is Computer equipment based on , determine the enhanced feature map corresponding to k basic network units .
[0131] In the above process, , It can be understood as the intermediate distillation feature map corresponding to the kth basic network unit. The effective channel feature map obtained by each level of distillation operation can be understood as the effective features (useful features) that can be distilled by the distillation layer of the current level of distillation operation.
[0132] In this embodiment, through each distillation layer in the multi-level feature distillation layer, the feature map input to the current distillation layer (such as the enhanced feature map of the previous basic network unit, the residual channel feature map obtained by the previous distillation layer, and the initial feature map) can be distilled again to further extract deep details. In this way, through the multi-level distillation operation, more useful features can be obtained to enhance the video clarity. At the same time, the extraction of useless features can be avoided to remove video compression artifacts, thereby improving the video enhancement effect.
[0133] In some embodiments, the effective channel feature map and the residual channel feature map may be separated in channel order. channels, at least one of the latter channels is regarded as a valid channel, and the other channels are regarded as remaining channels. Alternatively, at least one of the former channels is regarded as a valid channel, and the other channels are regarded as remaining channels. Then, the channel feature graphs belonging to the valid channels in the distillation feature graph are regarded as the valid channel feature graphs, and the channel feature graphs belonging to the remaining channels are regarded as the remaining channel feature graphs.
[0134] In this way, by determining the effective channels and the remaining channels in sequence, the channel separation can be completed more quickly and accurately, the efficiency of the separation process is ensured, and the omission of the effective channel feature map can be avoided.
[0135] In some embodiments, the method further includes: performing channel separation on the distillation characteristic graph obtained by the previous level of distillation operation to obtain channel characteristic graphs of each channel; starting from the first channel, according to the channel order of each channel, using the channel characteristic graphs of a preset number of channels with later channel numbers as valid channel characteristic graphs in the distillation characteristic graph obtained by the previous level of distillation, and using the channel characteristic graphs of the remaining channels as the remaining channel characteristic graphs in the distillation characteristic graph obtained by the previous level of distillation.
[0136] Exemplarily, after determining the channel characteristic graph of each channel by channel separation, the computer device determines the channel number of the distillation characteristic graph obtained by the previous distillation operation, and based on the channel number and the number of distillation stages involved in the multi-stage distillation, determines the channel numbers of the remaining channels and the effective channels, respectively. and .in, and The sum of is the number of channels of the distillation feature map .
[0137] The computer device sorts each channel, starting with the first channel. channels are determined as the remaining channels. For multiple channel feature maps obtained by the previous distillation, the channel feature maps belonging to the valid channels are regarded as the valid channel feature maps obtained by the previous distillation, and the channel feature maps belonging to the remaining channels are regarded as the remaining channel feature maps obtained by the previous distillation.
[0138] For example, and They are , , It is 16:00, and They are 12 and 4 respectively; the channel feature maps corresponding to the first 12 channels are used as the remaining channel feature maps, and the channel feature maps corresponding to the last 4 channels are used as the effective channel feature maps.
[0139] The step of determining the channel number of each of the above-mentioned effective channels and the remaining channels includes: a computer device determines the number of distillation stages involved in the multi-stage distillation, the reciprocal of the distillation stage number is the ratio of the channel number of effective channels in each stage of distillation to the channel number of the distillation characteristic diagram obtained in each stage of distillation, the product of the ratio and the channel number of the distillation characteristic diagram is used as the channel number of the effective channel in each stage of distillation, and the difference between the channel number of the distillation characteristic diagram and the channel number of the effective channel is used as the channel number of the remaining channels.
[0140] For example, the number of distillation stages is 4, the reciprocal of the number of distillation stages is 1 / 4, if the number of channels of the distillation characteristic diagram obtained in each distillation stage is 16, then the number of effective channels and the number of remaining channels in each distillation stage are 4 and 12 respectively.
[0141] In this embodiment, the distillation characteristic graph obtained from the previous distillation operation is channel separated to obtain channel characteristic graphs of each channel. The effective channel characteristic graph and the remaining channel characteristic graph of the previous distillation operation can be determined in an orderly and rapid manner according to the channel sequence, thereby ensuring the efficiency of determining the effective channel characteristic graph and the remaining channel characteristic graph.
[0142] Step S506, obtaining an enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the final basic network unit, and obtaining an enhanced video corresponding to the input video according to the enhanced image corresponding to each frame image.
[0143] The enhanced image corresponding to the frame image refers to the image after the frame image is enhanced. The enhanced video determined based on the enhanced image refers to the video after the input video is enhanced. Exemplarily, the enhanced video can be a video with video compression artifacts removed and enhanced definition.
[0144] Optionally, the computer device obtains an enhanced feature map corresponding to the last basic network unit, fuses the enhanced feature map with the initial feature map, and determines an enhanced image corresponding to the frame image. The computer device encodes the enhanced image corresponding to each frame image in the input video to obtain an enhanced video corresponding to the input video.
[0145] In some embodiments, an enhanced image corresponding to the frame image is obtained according to the enhanced feature map corresponding to the last basic network unit, including: superimposing the initial feature map of the frame image and the enhanced feature map corresponding to the last basic network unit to obtain a target enhanced feature map, and determining the enhanced image corresponding to the frame image based on the target enhanced feature map.
[0146] Exemplarily, when determining that each channel of the enhanced feature map corresponding to the final basic network unit is aligned with each channel of the initial feature map, the computer device directly superimposes the initial feature map of the frame image and the enhanced feature map corresponding to the final basic network unit to obtain a target enhanced feature map, and the computer device determines the enhanced image corresponding to the frame image through channel contraction processing based on the target enhanced feature map. The number of channels of the enhanced image is the same as the number of channels of the corresponding frame image.
[0147] In some embodiments, the video enhancement model also includes a denormalization layer and a channel shrinkage layer, and determines an enhanced image corresponding to the frame image based on the target enhancement feature map, including: using the channel shrinkage layer to perform channel shrinkage processing on the target enhancement feature map to obtain an output feature map, and the number of channels of the output feature map is the same as the number of channels of the frame image; using the denormalization layer to perform denormalization processing on the output feature map to obtain an enhanced image corresponding to the frame image.
[0148] The channel shrinking layer is used to shrink the number of channels of the input feature map to the number of channels of the frame image. Exemplarily, the channel shrinking layer can be a convolution layer with a convolution kernel of 3×3; the denormalization layer is used to perform denormalization processing on the input feature map, and the denormalization processing is the reverse processing of the normalization processing mentioned above.
[0149] Exemplarily, the computer device determines the target enhancement feature map After that, the following formula (3) is used to perform channel shrinkage processing to obtain the corresponding output feature map :
[0150] (3)
[0151] In formula (3) It is the convolution layer 3 with a convolution kernel of 3×3, which is the channel expansion layer.
[0152] Then use the following formula (4) to determine the sub-enhanced image corresponding to the c channel: :
[0153] (4)
[0154] As mentioned above, c∈{R,G,B}, so in formula (4) Output feature map The computer device merges the sub-enhanced images corresponding to the R channel, the G channel, and the B channel to obtain the corresponding enhanced image O.
[0155] In this embodiment, a channel shrinkage layer is used to perform channel shrinkage processing on the target enhanced feature map to shrink the number of channels of the target enhanced feature map to ensure that the number of channels of the output feature map is the same as the number of channels of the frame image. Then, an inverse normalization layer is used to perform inverse normalization processing on the output feature map to obtain an enhanced image corresponding to the frame image, so that the pixel distribution of the enhanced image is the same as the pixel distribution of the frame image, ensuring the effectiveness of the enhancement process.
[0156] As mentioned above, if the channels of the enhanced feature map corresponding to the last basic network unit and the initial feature map are not aligned, then before calculating the target enhanced feature map, it is necessary to perform channel transformation on the enhanced feature map corresponding to the last basic network unit to obtain the changed enhanced feature map, so that the channels of the changed enhanced feature map and the channels of the initial feature map are aligned.
[0157] To this end, in some embodiments, after determining the enhanced feature map corresponding to the final basic network, the computer device uses a convolution layer with a convolution kernel of 1×1 to perform channel transformation on the enhanced feature map, and superimposes the transformed enhanced feature map with the initial feature map to obtain a target enhanced feature map.
[0158] In this way, through the convolution layer with a convolution kernel of 1×1, the enhanced feature map corresponding to the final basic network unit is integrated or transformed in the channel dimension to ensure the effectiveness of the subsequent superposition process.
[0159] For example, after determining the initial feature map , the target enhancement feature map is determined using the following formula (5) :
[0160] (5)
[0161] In formula (5) is the calculation function of the kth basic network unit, k∈[1,n]. It is the convolution layer 2 with a convolution kernel of 1×1.
[0162] The following is an introduction to the model structure of the video enhancement model of the embodiment of the present application with a specific example. Figure 7 , which is a schematic diagram of the model structure of a video enhancement model in an embodiment. Figure 7 In the video enhancement model, the normalization layer, convolution layer 1, basic network unit 1, ..., basic network unit n, convolution layer 2, convolution layer 3, and denormalization layer are connected in sequence. Among them, convolution layer 1 is the one mentioned in formula (2) above. , is the channel expansion layer. Convolutional layer 2 is the convolutional layer with a convolution kernel of 1×1 mentioned above. Convolutional layer 3 is the convolutional layer mentioned in formula (3) above. , which is the channel contraction layer.
[0163] In this embodiment, a deeper target enhancement feature map is obtained by superimposing the initial feature map of the frame image and the enhancement feature map corresponding to the final basic network unit. In this way, based on the target enhancement feature map, an enhanced image with the same number of channels and pixel distribution as the frame image can be accurately determined to ensure the video enhancement effect.
[0164] In the above-mentioned video enhancement method, an input video is obtained to determine multiple frame images of the input video. For each frame image, the frame image is input into a trained video enhancement model. The video enhancement model includes at least two basic network units, each of which is connected in sequence. Each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation. In the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined. The distillation feature map obtained by the first-level distillation is channel-separated to obtain an effective channel feature map that can reflect deep-level details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation as the remaining channel feature map obtained by the previous level of distillation, the deep-level details are continued to be distilled out, and the effective channel feature map corresponding to each level of distillation is accurately extracted. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature maps obtained by each remaining level of distillation are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. In this way, the effective extraction of useful details in the input of the current basic network unit is achieved, and the acquisition of irrelevant details is avoided, ensuring the enhancement effect. Among them, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. Finally, according to the enhanced feature map corresponding to the last basic network unit, the frame image can be effectively enhanced, and the enhanced image corresponding to each frame image can be obtained. Then, based on the enhanced image corresponding to each frame image, the enhanced video corresponding to the input video with good enhancement effect can be obtained, thereby improving the video enhancement effect.
[0165] In some embodiments, each basic network unit also includes a channel activation layer based on a self-attention mechanism, and the method also includes: inputting the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit into the channel activation layer in the current basic network unit, performing channel activation processing on the multi-level distillation feature map based on the self-attention mechanism, and obtaining a channel-activated multi-level distillation feature map.
[0166] Each basic network unit includes a multi-level feature distillation layer and a channel activation layer based on the self-attention mechanism. The channel activation layer based on the self-attention mechanism is used to activate the effective channels of the multi-level distillation feature map. Channel activation can be understood as focusing on more important channels (effective channels).
[0167] Exemplarily, for any basic network unit, after determining the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit, the computer device inputs the multi-level distillation feature map to the channel activation layer of the current basic network unit. The computer device determines the importance of each channel in the multi-level distillation feature map based on the self-attention mechanism of the channel activation layer. Channel activation processing is performed on the multi-level distillation feature map based on the importance of each channel to obtain a channel-activated multi-level distillation feature map.
[0168] The importance of any channel reflects the effectiveness of the features of the channel. The higher the importance, the more effective the features of the corresponding channel.
[0169] In this embodiment, in the current basic network unit, channel activation processing is performed on the multi-level distillation feature map output by the multi-level distillation layer using the self-attention mechanism to activate the features of the effective channels in the multi-level distillation feature map, so as to focus on the features of more important channels, thereby obtaining a channel-activated multi-level distillation feature map. In this way, the subsequent multi-level distillation feature map based on channel activation can obtain an enhanced video with better clarity and improve the video enhancement effect.
[0170] In some embodiments, the multi-level distillation feature map corresponding to the current basic network unit includes channel distillation feature maps of each channel, and channel activation processing is performed on the multi-level distillation feature map based on the self-attention mechanism to obtain a channel-activated multi-level distillation feature map, including: performing self-attention mechanism processing on the multi-level distillation feature map to determine the importance corresponding to each channel in the multi-level distillation feature map; and dot-multiplying the importance corresponding to each channel with the channel distillation feature map to obtain a channel-activated multi-level distillation feature map.
[0171] Exemplarily, the channel activation layer based on the self-attention mechanism includes a convolution layer for extracting query features, a convolution layer for extracting key features, and a convolution layer for extracting value features.
[0172] Exemplarily, the computer device performs global average pooling and batch normalization on the multi-stage distillation feature map to obtain a feature map to be processed. The number of channels of the feature map to be processed is the same as the number of channels of the multi-stage distillation feature map.
[0173] The feature graph to be processed is then processed by a self-attention mechanism. Specifically, the feature graph to be processed is respectively input into the convolution layer for extracting query features, the convolution layer for extracting key features, and the convolution layer for extracting value features, and the query features, key features, and value features corresponding to each channel are obtained respectively. Based on the query features, key features, and value features corresponding to each channel, the computer device processes the query features, key features, and value features corresponding to each channel through a self-attention mechanism to obtain the importance corresponding to each channel in the multi-level distillation feature graph.
[0174] The computer device determines the channel distillation feature map corresponding to each channel in the multi-level distillation feature map, and respectively multiplies the importance corresponding to each channel with the channel distillation feature map to obtain the dot product result corresponding to each channel, and combines the dot product results to obtain the multi-level distillation feature map activated by the channel.
[0175] The calculation of importance is explained below. For the kth basic network unit, the corresponding multi-level distillation feature map is , the feature map to be processed is , the self-attention mechanism is processed based on the following formula (6) to determine the initial importance of each channel:
[0176] (6)
[0177] In formula (6) The number of channels is , channel attention with a height and width of 1×1, Contains the initial importance of each channel. , and They are respectively a convolution layer for extracting query features, a convolution layer for extracting key features, and a convolution layer for extracting value features, and the convolution kernel is 1×1.
[0178] Next, After inputting into the convolution layer 2 with a convolution kernel of 1×1 and processing with the Sigmoid function, the new channel attention is obtained. , as shown in the following formula (7):
[0179] (7)
[0180] Among them, the new channel attention Contains the importance of each channel.
[0181] After obtaining the importance of each channel, the importance of each channel and the channel distillation feature map are multiplied to obtain the multi-level distillation feature map of channel activation. .
[0182] In this embodiment, by processing the multi-level distillation feature map with a self-attention mechanism, the importance of each channel in the multi-level distillation feature map can be accurately determined. In this way, the importance of each channel and the channel distillation feature map are multiplied to further activate the effective channels, focus on the features of more important channels, and obtain a multi-level distillation feature map of channel activation to ensure the video enhancement effect.
[0183] In some embodiments, the step of generating an enhanced feature map corresponding to the current basic network unit includes: in the current basic network unit, according to the multi-level distillation feature map corresponding to the current basic network unit, the multi-level distillation feature map activated by the channel, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit, obtaining the enhanced feature map corresponding to the current basic network unit.
[0184] Exemplarily, in the current basic network unit, the computer device superimposes the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel to obtain a superimposed feature map. The computer device fuses the superimposed feature map with the enhanced feature map corresponding to the previous basic network unit to obtain an enhanced feature map corresponding to the current basic network unit.
[0185] For example, when the channels of the superimposed feature map are aligned with the channels of the enhanced feature map corresponding to the previous basic network unit, the computer device directly superimposes the superimposed feature map with the enhanced feature map corresponding to the previous basic network unit to obtain the enhanced feature map corresponding to the current basic network unit.
[0186] Exemplarily, if the current basic network unit is the first basic network unit, the computer device superimposes the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel to obtain a superimposed feature map. The computer device fuses the superimposed feature map with the initial feature map corresponding to the frame image to obtain an enhanced feature map corresponding to the current basic network unit.
[0187] In the case of non-alignment, the enhanced feature map corresponding to the current basic network unit may be determined based on the following embodiments.
[0188] In some embodiments, an enhanced feature map corresponding to the current basic network unit is obtained based on the multi-level distillation feature map corresponding to the current basic network unit, the channel-activated multi-level distillation feature map, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit, including: superimposing the multi-level distillation feature map corresponding to the current basic network unit and the channel-activated multi-level distillation feature map to obtain a superimposed feature map; performing channel transformation on the superimposed feature map to obtain a transformed feature map, and superimposing the transformed feature map and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit to obtain an enhanced feature map corresponding to the current basic network unit.
[0189] Exemplarily, the computer device uses a convolution layer with a convolution kernel of 1×1 to perform convolution calculation on the superimposed feature map to obtain a transformed feature map.
[0190] In this way, by superimposing the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel, the features distilled on each channel are retained, and the feature expression of the more effective channel is enhanced, thereby obtaining the superimposed feature map. By performing channel transformation on the superimposed feature map, the transformed feature map is obtained, and the alignment of the transformed feature map with the enhanced feature map corresponding to the previous basic network unit in the channel dimension is ensured. In this way, the enhanced feature map corresponding to the current basic network unit is obtained by superimposing the transformed feature map and the enhanced feature map corresponding to the previous basic network unit, thereby ensuring the effectiveness of the superposition process.
[0191] In this embodiment, in the current basic network unit, an enhanced feature map corresponding to the current basic network unit is obtained based on the multi-level distillation feature map corresponding to the current basic network unit, the channel-activated multi-level distillation feature map and the enhanced feature map corresponding to the previous basic network unit, thereby enabling the current basic network unit to effectively extract useful details in the enhanced feature map of the previous basic network unit, avoid obtaining irrelevant details, and ensure the enhancement effect.
[0192] The unit structure of each basic network unit is explained below. Figure 8 FIG. 1 is a schematic diagram of a unit structure of a basic network unit in an embodiment.
[0193] Figure 8 Take the unit structure of the kth basic network unit as an example, where the multi-level feature distillation layer includes the first distillation layer, the second distillation layer, the third distillation layer and the fourth distillation layer connected in sequence. After the channel merging is completed, the channel activation layer and the convolution layer 1 with a convolution kernel of 1×1 are connected in sequence.
[0194] First, when k is not 1, the enhanced feature map corresponding to the previous basic network unit is After inputting to the first-level distillation layer, refer to steps 6.1 to 6.5 above to obtain the multi-level distillation feature map corresponding to the k-th basic network unit When k is 1, the initial feature map of the frame image is After inputting to the first-level distillation layer, refer to steps 6.1 to 6.5 above to obtain the multi-level distillation feature map corresponding to the k-th basic network unit .
[0195] Next, Input to the channel activation layer, output channel activated multi-level distillation feature map Among them, the channel activation layer includes global average pooling, batch normalization, self-attention mechanism processing, convolution layer 2 with a convolution kernel of 1×1, and Sigmoid processing. The specific activation processing process is detailed in the previous text.
[0196] Then, and Superposition, get the superimposed feature map , using a convolution layer with a convolution kernel of 1×1 Perform channel transformation to obtain the transformed feature map .
[0197] Finally, and Superimpose to obtain the enhanced feature map corresponding to the kth basic network unit .
[0198] The first to fourth distillation layers are all followed by a LeakyReLU function (an activation function).
[0199] To facilitate understanding of the number of channels output by each process, different arrows and thicknesses are used to represent the corresponding number of channels. For details, see Figure 8 in the comment box.
[0200] The multi-level distillation based on the multi-level feature distillation layer can distill out more useful features, and then perform channel activation processing on the multi-level distillation feature map obtained by the multi-level distillation based on the channel activation layer to activate the features of the effective channels in the multi-level distillation feature map, so as to focus on the features of more important channels, thereby obtaining a channel-activated multi-level distillation feature map to ensure the video enhancement effect.
[0201] In some embodiments, Fig. 9 As shown, a video enhancement model processing method is provided, and the method is applied to a computer device (for example, the terminal 402 in FIG. 4 or the server 404) as an example for description, including the following steps S902 to S908. Among them:
[0202] Step S902: acquiring training samples, each training sample including a first sample frame image and a second sample frame image, wherein the image quality of the first sample frame image is higher than the image quality of the second sample frame image.
[0203] The first sample frame image is derived from the first sample video, and the second sample frame image is obtained by blurring and compressing the first sample frame image. The second sample frame image has low definition and has video compression artifacts.
[0204] Compared with the second sample frame image, the corresponding first sample frame image has higher definition and fewer video compression artifacts (or no video compression artifacts).
[0205] Exemplarily, the computer device obtains a first sample video and determines a plurality of first sample frame images in the first sample video. The computer device performs blurring processing on the first sample video and then performs video compression to obtain a second sample video, wherein the second sample video includes a plurality of second sample frame images.
[0206] Exemplarily, a computer device compresses a first sample video to obtain a compressed video, extracts a preset number of frame images from the compressed video, and blurs the extracted frame images to obtain multiple second sample frame images.
[0207] Exemplarily, the computer device obtains a first sample frame image and a second sample frame image at the same time stamp from a plurality of first sample frame images and a plurality of second sample frame images to construct a training sample.
[0208] In some embodiments, obtaining a training sample includes: obtaining a first sample video, the first sample video including a plurality of first sample frame images; blurring the first sample video to obtain a blurred video; performing video compression on the blurred video to obtain a second sample video; and constructing a training sample based on obtaining the first sample frame image and the second sample frame image at the same timestamp from the first sample video and the second sample video.
[0209] like Fig.10 As shown, it is a schematic diagram of training sample construction in an embodiment. The first sample video set includes the first sample video A1, ..., the first sample video Am, a total of m videos. Take the first sample video A1 as an example for explanation:
[0210] Step 10.1: The computer device decodes the first sample video A1 to obtain a plurality of first sample frame images, and blurs the plurality of first sample frame images frame by frame to obtain a blurred video.
[0211] Exemplarily, for any first sample frame image, the computer device downsamples the first sample frame image to half the resolution using a preset downsampling method to obtain a downsampled image. Then, the downsampled image is sampled back to the original resolution (i.e., the resolution of the first sample frame image) using a preset upsampling method to obtain a corresponding blurred image, and the blurred images are combined to obtain a blurred video.
[0212] The downsampling method includes but is not limited to bilinear downsampling and bicubic downsampling. The upsampling method includes but is not limited to bilinear upsampling and bicubic upsampling.
[0213] Step 10.2: The computer device compresses the blurred video to obtain a second sample video B1 corresponding to the first sample video A1.
[0214] Exemplarily, the computer device determines the compression degree based on the scenario in which the video enhancement model is applied, which can be specifically controlled by using the crf parameter (constant rate factor). The computer device uses the FFmpeg tool (a set of open source computer programs that can be used to record, convert digital audio and video, and convert them into streams) to compress the blurred video according to the compression degree to obtain the second sample video B1.
[0215] Wherein, referring to the above steps 10.1 and 10.2, similar processing is performed on other first sample videos A2, A3, A4, ..., Am in the first sample video set to obtain corresponding second sample videos B2, B3, B4, ..., Bm.
[0216] Step 10.3: The computer device extracts frames from the first sample video A1 to obtain first sample frame images A1.1 to first sample frame images A1.x. Similarly, the computer device extracts frames from the second sample video B1 to obtain second sample frame images B1.1 to second sample frame images B1.x.
[0217] Among them, referring to the above-mentioned process of extracting frames from the first sample video A1, similar processing is performed on the first sample videos A2, A3, A4, ..., Am, respectively, to obtain the first sample frame images A2.1, ..., and first sample frame images A2.x corresponding to the first sample video A2; the first sample frame images A3.1, ..., and first sample frame images A3.x corresponding to the first sample video A3; the first sample frame images A4.1, ..., and first sample frame images A4.x corresponding to the first sample video A4; and the first sample frame images Am.1, ..., and first sample frame images Am.x corresponding to the first sample video Am.
[0218] With reference to the above-mentioned process of extracting frames from the second sample video B1, similar processing is performed on the second sample videos B2, B3, B4, ..., Bm, respectively, to obtain the second sample frame images B2.1, ..., and second sample frame images B2.x corresponding to the second sample video B2; the second sample frame images B3.1, ..., and second sample frame images B3.x corresponding to the second sample video B3; the second sample frame images B4.1, ..., and second sample frame images B4.x corresponding to the second sample video B4; and the second sample frame images Bm.1, ..., and second sample frame images Bm.x corresponding to the second sample video Bm.
[0219] Step 10.4: Based on the first sample frame image A1.1 and the second sample frame image B1.1 at the same timestamp, construct a training sample A.1 (the training sample A.1 includes the first sample frame image A1.1 and the second sample frame image B1.1).
[0220] In this embodiment, the first sample video is blurred to reduce its definition, and the blurred video is compressed to introduce video compression artifacts, so that each second sample frame image in the generated second sample video is an image with low definition and containing video compression artifacts. In the subsequent training process, the definition of the second sample frame image is enhanced and the video compression artifacts are removed to obtain a sample enhanced image, which drives the model to enhance the image quality of the obtained sample enhanced image, close to the image quality of the first sample frame image at the same timestamp, to ensure the model training effect.
[0221] Step S904: input the second sample frame image into the video enhancement model to be trained, where the video enhancement model includes at least two basic network units, each of which is connected in sequence, each of which includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation.
[0222] Step S906, in the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and the effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein, the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0223] Step S908, according to the enhanced feature map corresponding to the final basic network unit, obtain the sample enhanced image corresponding to the second sample frame image, construct the target loss based on the difference between the sample enhanced image and the first sample frame image, and update the video enhancement model with minimizing the target loss as the training goal.
[0224] The above-mentioned embodiment of step S904 to step S908 is similar to the embodiment of the above-mentioned video enhancement method, and reference may be made to the embodiment of the above-mentioned video enhancement method.
[0225] The following is an example to explain the above model training process:
[0226] First, multiple training samples (such as 300) are obtained from the training set for the current round of training. Each round is divided into multiple batches, and each batch samples the first number of training samples (such as 32 training samples) from the multiple training samples without replacement for training until all training samples (such as 300) are trained, and then the round of training is completed.
[0227] Then all training samples are put back into the training set for the next round of training. After completing the preset round of training, a trained video enhancement model is obtained.
[0228] Among them, Fig.11 As shown in FIG. 1 , a schematic diagram of model training in one embodiment is shown. For the training process of each annotation, please refer to Fig.11 :
[0229] Step 11.1: Sample image from the second frame To the second sample frame image Select the second sample frame image , and input it into the network Net of the video enhancement model to be trained. After model inference, the corresponding sample enhanced image is obtained. , refer to the following formula (8):
[0230] (8)
[0231] Step 11.2: Image from the first sample frame And the first sample frame image In the example, select the second sample frame image The first sample frame image at the same timestamp , based on sample enhancement image And the corresponding first sample frame image , use the L1 loss function to calculate the corresponding loss , and use the perceptual loss function to calculate the corresponding loss , joint loss and loss , construct the target loss , is used to constrain the learning process of enhancing the second sample frame image to the first sample frame image, specifically referring to the following formula (9):
[0232] (9)
[0233] in, is a feature extraction function for extracting feature maps. The feature extraction function may be a function of the fourth convolutional layer before the fifth maximum pooling layer in the pre-trained VGG-19 model. and are the weights of the L1 loss function and the perceptual loss function, for example, 0.9 and 0.1 respectively.
[0234] In other examples, the L1 loss function may be replaced by an L2 loss function, etc., without specific limitation.
[0235] Step 11.3: Update the model parameters based on the target loss through error backpropagation and the adam optimizer (adaptive moment estimation).
[0236] The video enhancement model processing method obtains training samples, determines that each training sample includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image. The second sample frame image is input into the video enhancement model to be trained, and the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; in the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined, and the distillation feature map obtained by the first-level distillation is channel-separated to obtain an effective channel feature map that can reflect deep-level details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation as the remaining channel feature map obtained by the previous level of distillation, the deep-level details are continued to be distilled out, thereby obtaining an effective channel feature map corresponding to each level of distillation. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature map obtained by each remaining level of distillation are channel-merged, and all the details extracted by the multi-level distillation are integrated to determine the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. Wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. According to the enhanced feature map corresponding to the basic network unit at the end, a sample enhanced image corresponding to the second sample frame image is obtained. Based on the difference between the sample enhanced image and the first sample frame image, a target loss is constructed. Taking minimizing the target loss as the training goal, the video enhancement model is updated to obtain a trained video enhancement model. When performing video enhancement processing, the trained video enhancement model can not only remove video compression artifacts, but also improve video picture clarity, thereby improving the video enhancement effect.
[0237] The present application also provides an application scenario, which applies the above-mentioned video enhancement method. Specifically, the application of the video enhancement method in this application scenario is, for example: in a long video enhancement scenario, the input video is a video on demand in a video client, or a live video. Specifically, the computer device decodes the input video to obtain multiple frame images, and for each frame image, the frame image is input into a trained video enhancement model, the video enhancement model includes at least two basic network units, each basic network unit is connected in sequence, each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; in the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is subjected to multi-level distillation, and the effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first-level distillation is for the current The input of the basic network unit, each remaining level of distillation is aimed at the remaining channel feature maps except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; according to the enhanced feature map corresponding to the last basic network unit, the enhanced image corresponding to the frame image is obtained, and according to the enhanced image corresponding to each frame image, the enhanced video corresponding to the input video is obtained. In this way, the video enhancement effect can be improved.
[0238] Of course, it is not limited to this. The video enhancement method provided by the present application can also be applied in other scenarios. For example, in a short video or medium video enhancement scenario, the input video is a short video or medium video. For another example, in an image enhancement scenario, an image to be enhanced is obtained, the image to be enhanced is input into a trained video enhancement model, and the video enhancement method provided by the embodiment of the present application is used to determine an enhanced image corresponding to the image to be enhanced.
[0239] The above application scenarios are merely illustrative descriptions. It should be understood that the application of the video enhancement methods provided in the embodiments of the present application is not limited to the above scenarios.
[0240] In a specific embodiment, a video enhancement method is provided, which is executed by a computer device. Fig.12 FIG. 1 is a flow chart of a video enhancement process in an embodiment.
[0241] Step 12.1: The computer device obtains the input video and decodes the input video to obtain frame images 1 to frame images P.
[0242] Step 12.2: Obtain the current frame image j to be processed from frame images 1 to frame images P, and input the frame image j into the trained video enhancement model for model inference, wherein the video enhancement model includes a normalization layer, a channel expansion layer, at least two basic network units, a channel contraction layer and an inverse normalization layer connected in sequence, each basic network unit includes a multi-level feature distillation layer and a channel activation layer based on a self-attention mechanism, and the multi-level feature distillation layer includes at least two levels of distillation.
[0243] Step 12.3: Use the standardization layer to standardize the frame image j to obtain a standard image; use the channel expansion layer to perform channel expansion on the standard image to obtain the initial feature map of the frame image j.
[0244] Step 12.4: In the first-level distillation layer of the multi-level feature distillation layer, a first-level distillation operation is performed on the input of the current basic network unit to obtain a first-level distillation feature map.
[0245] Exemplarily, when the current basic network unit is the first basic network unit among at least two basic network units, in the first-level distillation layer of the multi-level feature distillation layer, a first-level distillation operation is performed on the initial feature map of the frame image j to obtain the first-level distillation feature map corresponding to the current basic network unit.
[0246] Exemplarily, when the current basic network unit is not the first basic network unit among at least two basic network units, in the first-level distillation layer of the multi-level feature distillation layer, a first-level distillation operation is performed on the enhanced feature map corresponding to the previous basic network unit of the current basic network unit to obtain the first-level distillation feature map corresponding to the current basic network unit.
[0247] After obtaining the first-level distillation feature map corresponding to the current basic network unit, perform the following steps:
[0248] In the middle distillation layer of the multi-stage characteristic distillation layer, a residual channel characteristic graph obtained by performing channel separation on the distillation characteristic graph obtained by the distillation operation of the previous stage is obtained.
[0249] Exemplarily, the step of determining the residual channel characteristic graph and the effective channel characteristic graph of the previous distillation operation includes:
[0250] The distillation characteristic graph obtained by the previous distillation operation is subjected to channel separation to obtain channel characteristic graphs of each channel; according to the channel order of each channel, starting from the first channel, the channel characteristic graphs of a preset number of channels with later channel numbers are used as valid channel characteristic graphs in the distillation characteristic graph obtained by the previous distillation, and the channel characteristic graphs of the remaining channels are used as the remaining channel characteristic graphs in the distillation characteristic graph obtained by the previous distillation.
[0251] Step 12.5: Perform a distillation operation on the remaining channel feature graph to obtain an intermediate distillation feature graph; in the last distillation layer of the multi-level feature distillation layer, obtain the remaining channel feature graph obtained by channel separation of the distillation feature graph obtained by the previous distillation operation, perform a last-level distillation operation on the remaining channel feature graph, and obtain an effective channel feature graph obtained by the last-level distillation operation; perform channel merging on the effective channel feature graphs in the distillation feature graphs obtained by each level of distillation to obtain a multi-level distillation feature graph corresponding to the current basic network unit. The multi-level distillation feature graph includes the channel distillation feature graphs of each channel.
[0252] Step 12.6: Input the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit to the channel activation layer in the current basic network unit. Perform self-attention on the multi-level distillation feature map to determine the importance of each channel in the multi-level distillation feature map; multiply the importance of each channel with the channel distillation feature map to obtain the channel-activated multi-level distillation feature map.
[0253] Step 12.7: In the current basic network unit, the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel are superimposed to obtain the superimposed feature map; the superimposed feature map is subjected to channel transformation to obtain the transformed feature map. After that, the enhanced feature map corresponding to the current basic network unit is determined by the case, as follows:
[0254] When the current basic network unit is the first basic network unit, the transformed feature map and the initial feature map of the frame image j are superimposed to obtain an enhanced feature map corresponding to the current basic network unit.
[0255] When the current basic network unit is not the first basic network unit, the transformed feature map and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit are superimposed to obtain the enhanced feature map corresponding to the current basic network unit.
[0256] Step 12.8: After obtaining the enhanced feature map corresponding to the last basic network unit, superimpose the initial feature map of frame image j and the enhanced feature map corresponding to the last basic network unit to obtain the target enhanced feature map, and determine the enhanced image j corresponding to frame image j based on the target enhanced feature map.
[0257] Exemplarily, a channel shrinkage layer is used to perform channel shrinkage processing on the target enhanced feature map to obtain an output feature map, and the number of channels of the output feature map is the same as the number of channels of the frame image j; an inverse normalization layer is used to perform inverse normalization processing on the output feature map to obtain an enhanced image j corresponding to the frame image j.
[0258] Step 12.9: Based on the above steps 12.2 to 12.8, the computer device determines the enhanced images corresponding to the frame images 1 to P, namely, enhanced images 1 to enhanced images P, respectively, encodes each enhanced image to obtain an enhanced video.
[0259] The training steps of the video enhancement model are detailed in steps 12.10 to 12.14 below:
[0260] Step 12.10, obtain a first sample video, the first sample video includes multiple first sample frame images; blur the first sample video to obtain a blurred video; perform video compression on the blurred video to obtain a second sample video; construct a training sample based on obtaining the first sample frame image and the second sample frame image at the same timestamp from the first sample video and the second sample video.
[0261] Step 12.11: For the constructed training samples, a second sample frame image is obtained, wherein each training sample includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than that of the second sample frame image.
[0262] In step 12.12, the second sample frame image is input into the video enhancement model to be trained, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, each of which includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation.
[0263] In step 12.13, in the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and the effective channel feature maps in the distillation feature map obtained by each level of distillation are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit; wherein, the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0264] In step 12.14, according to the enhanced feature map corresponding to the basic network unit at the end, the sample enhanced image corresponding to the second sample frame image is obtained, and based on the difference between the sample enhanced image and the first sample frame image, the target loss is constructed, and the video enhancement model is updated with minimizing the target loss as the training goal.
[0265] The specific process of the above steps 12.12 to 12.14 may refer to steps 12.2 to 12.8. For example, the frame image j is replaced with the second sample frame image and similar processing is performed to obtain a sample enhanced image corresponding to the second sample frame image.
[0266] It should be noted that the video enhancement method provided by this application is specially designed for video compression artifact scenarios, not JPEG image compression artifact scenarios. The video enhancement model provided by this application is highly robust and can achieve adaptive compression artifact removal and clarity enhancement for different local contents, with obvious and natural effects. Moreover, during the entire video enhancement process, the video resolution will not be changed, and no additional display device capable of supporting higher resolution is required. It relies on less bitrate than the video super-resolution method, saving storage and bandwidth costs of online video platforms.
[0267] The video enhancement method of the present application can be used to enhance animation videos, videos containing subtitles, and drama videos. It can not only improve the video clarity, but also remove various video compression artifacts, and the video enhancement effect is obvious.
[0268] In this embodiment, an input video is obtained to determine multiple frame images of the input video. For each frame image, the frame image is input into a trained video enhancement model. The video enhancement model includes at least two basic network units, each of which is connected in sequence. Each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation. In the multi-level feature distillation layer of the current basic network unit, the input of the current basic network unit is used as the input of the first-level distillation to start the multi-level distillation, and the distillation feature map obtained by the first-level distillation is determined. The distillation feature map obtained by the first-level distillation is channel-separated to obtain an effective channel feature map that can reflect deep-level details, and a remaining channel feature map. Subsequently, by setting the input of each remaining level of distillation to the remaining channel feature map obtained by the previous level of distillation, the deep-level details are continued to be distilled out, and the effective channel feature map corresponding to each level of distillation is accurately extracted. That is to say, by performing multi-level distillation on the input of the current basic network unit, more useful details are gradually distilled out, and then the effective channel feature maps in the distillation feature maps obtained by each remaining level of distillation are channel-merged to obtain the multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate the enhanced feature map corresponding to the current basic network unit. In this way, the effective extraction of useful details in the input of the current basic network unit is achieved, and the acquisition of irrelevant details is avoided, ensuring the enhancement effect. Among them, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit. Finally, according to the enhanced feature map corresponding to the last basic network unit, the frame image can be effectively enhanced, and the enhanced image corresponding to each frame image can be obtained. Then, based on the enhanced image corresponding to each frame image, the enhanced video corresponding to the input video with good enhancement effect can be obtained, thereby improving the video enhancement effect.
[0269] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0270] Based on the same inventive concept, the embodiment of the present application also provides a video enhancement device for implementing the above-mentioned video enhancement method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more video enhancement device embodiments provided below can refer to the limitations of the video enhancement method above, and will not be repeated here.
[0271] In an exemplary embodiment, Fig.13 As shown, a video enhancement device 1300 is provided, comprising: an image acquisition module 1302, a first channel merging module 1304 and a video enhancement module 1306, wherein:
[0272] An image acquisition module 1302 is used to acquire multiple frame images of an input video. For each frame image, the frame image is input into a trained video enhancement model. The video enhancement model includes at least two basic network units, each of which is connected in sequence. Each basic network unit includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation.
[0273] The first channel merging module 1304 is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and merge the effective channel feature map in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0274] The video enhancement module 1306 is used to obtain an enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the final basic network unit, and to obtain an enhanced video corresponding to the input video according to the enhanced image corresponding to each frame image.
[0275] In some embodiments, the video enhancement model also includes a normalization layer and a channel expansion layer, and the device also includes an initial feature map determination module, which is used to use the normalization layer to normalize the frame image to obtain a standard image; and use the channel expansion layer to perform channel expansion on the standard image to obtain an initial feature map of the frame image.
[0276] In some embodiments, when the current basic network unit is not the first basic network unit among the at least two basic network units, the first channel merging module 1304 is further used to perform a first-level distillation operation on the enhanced feature map corresponding to the previous basic network unit of the current basic network unit in the first-level distillation layer of the multi-level feature distillation layer to obtain a first-level distillation feature map; in the middle distillation layer of the multi-level feature distillation layer, obtain the remaining channel feature map obtained by channel separation of the distillation feature map obtained by the previous-level distillation operation, perform a distillation operation on the remaining channel feature map, and obtain an intermediate-level distillation feature map; in the last distillation layer of the multi-level feature distillation layer, obtain the remaining channel feature map obtained by channel separation of the distillation feature map obtained by the previous-level distillation operation, perform a last-level distillation operation on the remaining channel feature map, and obtain an effective channel feature map obtained by the last-level distillation operation; and perform channel merging on the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit.
[0277] In some embodiments, the device also includes a channel characteristic map determination module, which is used to perform channel separation on the distillation characteristic map obtained by the previous level distillation operation to obtain channel characteristic maps of each channel; starting from the first channel, according to the channel order of each channel, the channel characteristic maps of a preset number of channels with later channel numbers are used as valid channel characteristic maps in the distillation characteristic map obtained by the previous level distillation, and the channel characteristic maps of the remaining channels are used as the remaining channel characteristic maps in the distillation characteristic map obtained by the previous level distillation.
[0278] In some embodiments, each basic network unit also includes a channel activation layer based on a self-attention mechanism, and the device also includes a distillation feature map determination module, which is used to input the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit into the channel activation layer in the current basic network unit, and perform channel activation processing on the multi-level distillation feature map based on the self-attention mechanism to obtain a channel-activated multi-level distillation feature map.
[0279] In some embodiments, the device also includes an enhanced feature map determination module, which is used to obtain an enhanced feature map corresponding to the current basic network unit in the current basic network unit based on the multi-level distillation feature map corresponding to the current basic network unit, the multi-level distillation feature map activated by the channel, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
[0280] In some embodiments, the multi-level distillation feature map corresponding to the current basic network unit includes channel distillation feature maps of each channel. The distillation feature map determination module is also used to perform a self-attention mechanism on the multi-level distillation feature map to determine the importance of each channel in the multi-level distillation feature map; and perform dot multiplication of the importance of each channel and the channel distillation feature map to obtain a channel-activated multi-level distillation feature map.
[0281] In some embodiments, an enhanced feature map determination module is used to superimpose a multi-level distillation feature map corresponding to a current basic network unit and a channel-activated multi-level distillation feature map to obtain a superimposed feature map; perform channel transformation on the superimposed feature map to obtain a transformed feature map, and superimpose the transformed feature map and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit to obtain an enhanced feature map corresponding to the current basic network unit.
[0282] In some embodiments, the video enhancement module 1306 is used to superimpose the initial feature map of the frame image and the enhanced feature map corresponding to the final basic network unit to obtain a target enhanced feature map, and determine the enhanced image corresponding to the frame image based on the target enhanced feature map.
[0283] In some embodiments, the video enhancement model also includes a denormalization layer and a channel shrinkage layer. The video enhancement module 1306 is also used to use the channel shrinkage layer to perform channel shrinkage processing on the target enhancement feature map to obtain an output feature map, and the number of channels of the output feature map is the same as the number of channels of the frame image; and use the denormalization layer to perform denormalization processing on the output feature map to obtain an enhanced image corresponding to the frame image.
[0284] Based on the same inventive concept, an embodiment of the present application also provides a video enhancement model processing device for implementing the above-mentioned video enhancement model processing method. The implementation solution for solving the problem provided by the device is similar to the implementation solution recorded in the above-mentioned method. Therefore, the specific limitations in one or more video enhancement model processing device embodiments provided below can be referred to the limitations on the video enhancement model processing method above, and will not be repeated here.
[0285] In an exemplary embodiment, Fig.14 As shown, a video enhancement model processing device 1400 is provided, comprising: a sample acquisition module 1402, an image input module 1404, a second channel merging module 1406 and a model updating module 1408, wherein:
[0286] A sample acquisition module 1402 is used to acquire training samples, each training sample includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image;
[0287] An image input module 1404 is used to input the second sample frame image into the video enhancement model to be trained, where the video enhancement model includes at least two basic network units, each of which is connected in sequence, each of which includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation;
[0288] The second channel merging module 1406 is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and merge the effective channel feature map in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map except the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit;
[0289] The model updating module 1408 is used to obtain a sample enhanced image corresponding to the second sample frame image according to the enhanced feature map corresponding to the final basic network unit, construct a target loss based on the difference between the sample enhanced image and the first sample frame image, and update the video enhancement model with minimizing the target loss as the training goal.
[0290] In some embodiments, the sample acquisition module 1402 is used to acquire a first sample video, the first sample video including multiple first sample frame images; blur the first sample video to obtain a blurred video; perform video compression on the blurred video to obtain a second sample video; and construct a training sample based on acquiring the first sample frame image and the second sample frame image at the same timestamp from the first sample video and the second sample video.
[0291] Each module in the above-mentioned video enhancement device and video enhancement model processing device can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0292] In an exemplary embodiment, a computer device is provided, which can be a server or a terminal, and its internal structure diagram can be shown in Figure 15. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, each method is implemented.
[0293] Those skilled in the art will understand that the structure shown in FIG. 15 is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.
[0294] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0295] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0296] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0297] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.
[0298] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0299] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0300] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A video enhancement method, characterized in that: The method comprises: Acquire multiple frame images of an input video, and for each frame image, input the frame image into a trained video enhancement model, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each of the basic network units includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; In the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and the effective channel feature map in the distillation feature map obtained by each level of distillation is channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature map other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; According to the enhanced feature map corresponding to the final basic network unit, an enhanced image corresponding to the frame image is obtained, and according to the enhanced image corresponding to each frame image, an enhanced video corresponding to the input video is obtained.
2. The method according to claim 1, characterized in that The video enhancement model further includes a normalization layer and a channel expansion layer, and the initial feature map determination step of the frame image includes: Using the standardization layer to perform standardization processing on the frame image to obtain a standard image; The channel expansion layer is used to perform channel expansion processing on the standard image to obtain an initial feature map of the frame image.
3. The method according to claim 1, characterized in that In the case where the current basic network unit is not the first basic network unit among the at least two basic network units, performing multi-level distillation on the input of the current basic network unit, merging channels of valid channel feature maps in the distillation feature map obtained by each level of distillation, and obtaining a multi-level distillation feature map corresponding to the current basic network unit, includes: In a first-level distillation layer of the multi-level feature distillation layer, a first-level distillation operation is performed on an enhanced feature map corresponding to a previous basic network unit of the current basic network unit to obtain a first-level distillation feature map; In the middle distillation layer of the multi-stage characteristic distillation layer, a residual channel characteristic graph obtained by performing channel separation on the distillation characteristic graph obtained by the previous stage distillation operation is obtained, and a distillation operation is performed on the residual channel characteristic graph to obtain an intermediate stage distillation characteristic graph; In the last distillation layer of the multi-stage characteristic distillation layer, a residual channel characteristic graph obtained by performing channel separation on the distillation characteristic graph obtained by the previous stage distillation operation is obtained, and a last stage distillation operation is performed on the residual channel characteristic graph to obtain an effective channel characteristic graph obtained by the last stage distillation operation; The effective channel feature maps in the distillation feature map obtained by each level of distillation are merged to obtain the multi-level distillation feature map corresponding to the current basic network unit.
4. The method according to claim 3, characterized in that The method further comprises: Performing channel separation on the distillation characteristic graph obtained by the previous distillation operation to obtain a channel characteristic graph of each channel; According to the channel order of each channel, starting from the first channel, the channel feature maps of a preset number of channels with the latter channel numbers are used as the effective channel feature maps in the distillation feature map obtained by the previous distillation, and the channel feature maps of the remaining channels are used as the remaining channel feature maps in the distillation feature map obtained by the previous distillation.
5. The method according to claim 1, characterized in that Each basic network unit also includes a channel activation layer based on a self-attention mechanism, and the method further includes: Inputting the multi-level distillation feature map output by the multi-level feature distillation layer in the current basic network unit into the channel activation layer in the current basic network unit, performing channel activation processing on the multi-level distillation feature map based on the self-attention mechanism, and obtaining a channel-activated multi-level distillation feature map; The step of generating an enhanced feature map corresponding to the current basic network unit includes: In the current basic network unit, an enhanced feature map corresponding to the current basic network unit is obtained according to the multi-level distillation feature map corresponding to the current basic network unit, the multi-level distillation feature map activated by the channel, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit.
6. The method according to claim 5, characterized in that The multi-level distillation feature map corresponding to the current basic network unit includes channel distillation feature maps of each channel, and the channel activation processing is performed on the multi-level distillation feature map based on the self-attention mechanism to obtain the channel-activated multi-level distillation feature map, including: Processing the multi-level distillation feature map with a self-attention mechanism to determine the importance corresponding to each channel in the multi-level distillation feature map; The importance of each channel and the channel distillation feature map are respectively multiplied to obtain the multi-level distillation feature map of channel activation.
7. The method according to claim 5, characterized in that The obtaining, according to the multi-level distillation feature map corresponding to the current basic network unit, the multi-level distillation feature map activated by the channel, and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit, the enhanced feature map corresponding to the current basic network unit includes: Superimposing the multi-level distillation feature map corresponding to the current basic network unit and the multi-level distillation feature map activated by the channel to obtain a superimposed feature map; Channel transformation is performed on the superimposed feature map to obtain a transformed feature map, and the transformed feature map and the enhanced feature map corresponding to the previous basic network unit of the current basic network unit are superimposed to obtain the enhanced feature map corresponding to the current basic network unit.
8. The method according to claim 1, characterized in that: The step of obtaining an enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the final basic network unit includes: The initial feature map of the frame image and the enhanced feature map corresponding to the final basic network unit are superimposed to obtain a target enhanced feature map, and based on the target enhanced feature map, an enhanced image corresponding to the frame image is determined.
9. The method according to claim 8, characterized in that The video enhancement model further includes an inverse normalization layer and a channel shrinkage layer, and the step of determining an enhanced image corresponding to the frame image based on the target enhancement feature map includes: Using the channel shrinkage layer to perform channel shrinkage processing on the target enhancement feature map to obtain an output feature map, wherein the number of channels of the output feature map is the same as the number of channels of the frame image; The output feature map is denormalized by using the denormalization layer to obtain an enhanced image corresponding to the frame image.
10. A video enhancement model processing method, characterized in that: The method comprises: Acquire training samples, each of the training samples includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image; Inputting the second sample frame image into a video enhancement model to be trained, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, each of which includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; In the multi-level feature distillation layer of the current basic network unit, multi-level distillation is performed on the input of the current basic network unit, and effective channel feature maps in the distillation feature map obtained by each level of distillation are channel-merged to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; According to the enhanced feature map corresponding to the final basic network unit, a sample enhanced image corresponding to the second sample frame image is obtained. Based on the difference between the sample enhanced image and the first sample frame image, a target loss is constructed. The video enhancement model is updated with minimizing the target loss as the training goal.
11. The method according to claim 10, characterized in that The obtaining of training samples comprises: Acquire a first sample video, where the first sample video includes a plurality of first sample frame images; Performing blur processing on the first sample video to obtain a blurred video; Performing video compression processing on the blurred video to obtain a second sample video; A training sample is constructed according to the first sample frame image and the second sample frame image at the same time stamp obtained from the first sample video and the second sample video.
12. A video enhancement device, characterized in that: The device comprises: An image acquisition module is used to acquire multiple frame images of an input video, and for each frame image, the frame image is input into a trained video enhancement model, wherein the video enhancement model includes at least two basic network units, each of which is connected in sequence, and each of the basic network units includes a multi-level feature distillation layer, and the multi-level feature distillation layer includes at least two levels of distillation; A first channel merging module is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and to merge the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; The video enhancement module is used to obtain an enhanced image corresponding to the frame image according to the enhanced feature map corresponding to the final basic network unit, and to obtain an enhanced video corresponding to the input video according to the enhanced image corresponding to each frame image.
13. A video enhancement model processing device, characterized in that: The device comprises: A sample acquisition module, used for acquiring training samples, each of the training samples includes a first sample frame image and a second sample frame image, and the image quality of the first sample frame image is higher than the image quality of the second sample frame image; An image input module, used for inputting the second sample frame image into a video enhancement model to be trained, wherein the video enhancement model comprises at least two basic network units, each of which is connected in sequence, each of which comprises a multi-level feature distillation layer, and the multi-level feature distillation layer comprises at least two levels of distillation; A second channel merging module is used to perform multi-level distillation on the input of the current basic network unit in the multi-level feature distillation layer of the current basic network unit, and to merge the effective channel feature maps in the distillation feature map obtained by each level of distillation to obtain a multi-level distillation feature map corresponding to the current basic network unit, and the multi-level distillation feature map is used to generate an enhanced feature map corresponding to the current basic network unit; wherein the first level of distillation is for the input of the current basic network unit, and each remaining level of distillation is for the remaining channel feature maps other than the effective channel feature map obtained by channel separation of the distillation feature map obtained by the previous level of distillation; wherein, when the current basic network unit is the first basic network unit among the at least two basic network units, the input of the current basic network unit is the initial feature map of the second sample frame image; when the current basic network unit is not the first basic network unit among the at least two basic network units, the input of the current basic network unit is the enhanced feature map corresponding to the previous basic network unit of the current basic network unit; The model updating module is used to obtain a sample enhanced image corresponding to the second sample frame image according to the enhanced feature map corresponding to the final basic network unit, construct a target loss based on the difference between the sample enhanced image and the first sample frame image, and update the video enhancement model with minimizing the target loss as the training goal.
14. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 11 are implemented.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
16. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
