An integrated image inpainting method and system based on image mask modeling

By employing image mask modeling pre-training and importance evaluation techniques, key network layers are selected for fine-tuning, solving the problem of image degradation restoration for various types of images. This achieves efficient and balanced image restoration results, improving the model's scalability and performance.

CN118628408BActive Publication Date: 2026-11-24NANKAI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410610768.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-16
Publication Date
2026-11-24
Estimated Expiration
2044-05-16

AI Technical Summary

Technical Problem

Existing technologies struggle to effectively handle multiple types of image degradation simultaneously, leading to unbalanced processing results and reduced scalability. The application of image masking modeling in image restoration has not yet been widely explored.

Method used

A pre-training strategy based on image masking modeling is adopted. The image inpainting network is trained with random masks, the importance of network layers is calculated and key layers are fine-tuned, and an integrated image inpainting method is established. The importance of each layer is evaluated by mask attribute propagation, and only some key layers are optimized to bridge the gap in data incompleteness.

Benefits of technology

It achieves balanced and powerful restoration results in various image restoration tasks, maintains model structure and computational efficiency, does not increase additional computational overhead, and improves the model's scalability and image restoration capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628408B_ABST
    Figure CN118628408B_ABST
Patent Text Reader

Abstract

This invention discloses an integrated image inpainting method and system based on image mask modeling. The method includes: inputting a first training set into an image inpainting network to train the image inpainting network and obtain a pre-trained image inpainting network; calculating the importance of each network layer in the pre-trained image inpainting network and selecting the top k network layers based on their importance; inputting a second training set into the pre-trained image inpainting network and training the pre-trained image inpainting network; wherein, during the training of the pre-trained image inpainting network, the network parameters of the non-top k network layers remain unchanged, and only the network parameters of the top k network layers are optimized to obtain the final trained image inpainting network; obtaining the image to be repaired and inputting the image to be repaired into the final trained image inpainting network to obtain the repaired image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image restoration technology, and in particular to an integrated image restoration method and system based on image mask modeling. Background Technology

[0002] Image inpainting involves restoring low-quality images affected by various degradations, typically stemming from adverse environmental conditions (e.g., rain, fog, low light), hardware-related issues (e.g., noise and blur), and post-processing flaws (e.g., JPEG compression). The value of image inpainting lies not only in enhancing the visual appeal of images but also in its practical applications, such as autonomous driving and surveillance. These applications require high-quality images to ensure operational accuracy and safety, and image inpainting techniques play a crucial role in these fields.

[0003] Modern techniques in this field primarily focus on learning fixed patterns formed during the degradation process, i.e., degradation priors. Some studies utilize task-specific priors to solve a particular degradation problem, while another research approach involves designing a general network architecture (such as SwinIR, MPRNet, Restormer, etc.) that can effectively learn each degradation pattern through independent training. However, these methods only allow the network to learn a single degradation type during a single training session, and cannot handle multiple types of degradation simultaneously. When training with data of multiple degradation types at the same time, it can lead to an imbalance in the processing results.

[0004] To address these issues, several integrated approaches have emerged, aiming to use a single model for multiple image inpainting tasks. Most of these methods tend to leverage explicit classification priors (e.g., AirNet) or introduce additional modules (e.g., PromptIR) to identify image degradation patterns, thereby assisting the model in performing restoration. However, these methods focus on distinguishing degradation types within an image rather than the image content itself, which leads to reduced scalability and blurred decision boundaries when dealing with more degradation types.

[0005] Inspired by masked language modeling (such as BERT and GPT), Mask Image Modeling (MIM) was first introduced as a pre-training method for learning general representations in high-level vision. MAE (Model-Based Image Modeling) pioneered the use of image masking as a pre-training method in high-level vision, predicting masked image patches and demonstrating significant power, effectively generalizing to various downstream tasks. However, image masking has not yet seen widespread application in image inpainting. This is because while image masking is more effective for knowledge extraction from semantic understanding, it struggles to learn image details. Nevertheless, the optimization objectives of image masking are similar to those in image inpainting and can help improve model scalability. Therefore, in-depth exploration of image masking methods suitable for low-level vision is necessary and worthwhile. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides an integrated image restoration method and system based on image mask modeling; it focuses on solving the problem of how to extract intrinsic image information from various damaged images.

[0007] On the one hand, an integrated image inpainting method based on image mask modeling is provided, including:

[0008] The first training set is input into the image restoration network. The low-quality image with a random mask is used as the input value of the image restoration network, and the corresponding high-quality image is used as the output value of the image restoration network. The image restoration network is trained to obtain the pre-trained image restoration network.

[0009] For the pre-trained image inpainting network, calculate the importance of each network layer and select the k network layers with the highest importance ranking;

[0010] The second training set is input into the pre-trained image inpainting network. Low-quality images without random masks are used as input values ​​to the pre-trained image inpainting network, and corresponding high-quality images are used as output values ​​to train the pre-trained image inpainting network. During the training process, the network parameters of non-top k layers remain unchanged, and only the network parameters of the top k layers are optimized to obtain the final trained image inpainting network.

[0011] The image to be repaired is obtained and then input into the finally trained image inpainting network to obtain the repaired image.

[0012] On the other hand, an integrated image inpainting system based on image mask modeling is provided, including:

[0013] The pre-training module is configured to: input the first training set into the image restoration network, use a low-quality image with a random mask as the input value of the image restoration network, use the corresponding high-quality image as the output value of the image restoration network, train the image restoration network, and obtain the pre-trained image restoration network.

[0014] The importance calculation module is configured to: calculate the importance of each network layer of the pre-trained image inpainting network, and select the top k network layers in terms of importance.

[0015] The fine-tuning module is configured to: input the second training set into the pre-trained image inpainting network, use the low-quality image without random mask as the input value of the pre-trained image inpainting network, and use the corresponding high-quality image as the output value of the pre-trained image inpainting network to train the pre-trained image inpainting network; wherein, during the training process of the pre-trained image inpainting network, the network parameters of the non-top k network layers remain unchanged, and only the network parameters of the top k network layers are optimized to obtain the final trained image inpainting network;

[0016] The repair module is configured to: acquire the image to be repaired, input the image to be repaired into the finally trained image repair network, and obtain the repaired image.

[0017] Furthermore, an electronic device is also provided, including:

[0018] Memory, used for non-transitory storage of computer-readable instructions; and

[0019] Processor, for executing the computer-readable instructions,

[0020] When the computer-readable instructions are executed by the processor, they perform the method described in the first aspect above.

[0021] In another aspect, a storage medium is also provided for non-transitory storage of computer-readable instructions, wherein when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method described in the first aspect are executed.

[0022] In another aspect, a computer program product is also provided, including a computer program that, when run on one or more processors, is used to implement the method described in the first aspect above.

[0023] The above technical solution has the following advantages or beneficial effects:

[0024] This invention discusses the challenges of using MIM in low-level vision and proposes an image mask modeling pre-training strategy suitable for integrated comprehensive image inpainting, which enables the restoration network to effectively learn the essential information of the image while ensuring the reconstruction result.

[0025] This invention proposes mask attribute propagation to evaluate the importance of each layer in addressing the input integrity gap, so as to fine-tune a small subset (e.g., 5%) of key layers to bridge this gap while preserving the image priors learned by MIM.

[0026] The image inpainting (RAM) method proposed in this invention provides a new perspective for achieving more balanced and robust fully blind image restoration, focusing on extracting inherent image information from damaged images. This invention can be applied to any image restoration network without introducing additional computational overhead.

[0027] This invention can handle multiple image restoration effects simultaneously using a single model, while ensuring balanced restoration results for different image restoration tasks. Compared with state-of-the-art methods, this invention has stronger scalability. Attached Figure Description

[0028] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.

[0029] Figure 1 This is a schematic diagram of the basic process of implementing the present invention.

[0030] Figure 2 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the defogging task.

[0031] Figure 3 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the rain removal task.

[0032] Figure 4 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the denoising task.

[0033] Figure 5 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the low-light enhancement task.

[0034] Figure 6 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods on the kernel removal fuzzing task.

[0035] Figure 7 This is a schematic diagram comparing the output results of the implementation method of this invention and other existing methods in the task of removing JPEG compression artifacts.

[0036] Figure 8 This is a schematic diagram of the statistical results of the implementation method of the present invention. Detailed Implementation

[0037] It should be noted that the following detailed descriptions are exemplary and intended to provide further illustration of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.

[0038] Example 1

[0039] This embodiment provides an integrated image inpainting method based on image mask modeling;

[0040] like Figure 1 As shown, an integrated image inpainting method based on image mask modeling includes:

[0041] S101: Input the first training set into the image restoration network, use the low-quality image with random mask as the input value of the image restoration network (such as the SwinIR network, PromptIR network, etc.), and use the corresponding high-quality image as the output value of the image restoration network to train the image restoration network and obtain the pre-trained image restoration network.

[0042] S102: For the pre-trained image inpainting network, calculate the importance of each network layer and select the k network layers with the highest importance ranking;

[0043] S103: Input the second training set into the pre-trained image restoration network. Use the low-quality image without random mask as the input value of the pre-trained image restoration network and the corresponding high-quality image as the output value of the pre-trained image restoration network to train the pre-trained image restoration network. During the training process of the pre-trained image restoration network, the network parameters of the non-top k network layers remain unchanged, and only the network parameters of the top k network layers are optimized to obtain the final trained image restoration network.

[0044] S104: Obtain the image to be repaired, input the image to be repaired into the finally trained image repair network, and obtain the repaired image.

[0045] Further, in S101: construct a first training set, which includes: a number of high-quality images, each of which has a corresponding low-quality image with a random mask.

[0046] Furthermore, the low-quality image refers to an image taken in rainy, foggy, or nighttime conditions, or an image with noise, kernel blur, motion blur, or JPEG compression artifacts.

[0047] Furthermore, the low-quality image with random masking refers to the low-quality image being randomly masked using pixel blocks of 1*1 at the pixel level, with a masking rate of 50%.

[0048] Furthermore, the high-quality image refers to an image that was not taken in rainy, foggy, or nighttime conditions, and that is free from noise, kernel blur, motion blur, and JPEG compression artifacts, with illumination, contrast, and image clarity all exceeding a set threshold.

[0049] It should be understood that, given an image inpainting network, this neural network is pre-trained using customized image masking modeling. The pre-training details are as follows: Given low-quality images with varying degrees of degradation, a pixel-level equalized random mask is applied to the degraded image to generate a partially masked degraded image. The neural network is then trained by inputting the partially masked degraded image to predict the high-quality image portions corresponding to the masked pixels.

[0050] Binary masks are applied to input images with varying degrees of degradation using pixel-level (1x1 image patches) and equalized (50% masking rate) random masks. These masks are used to augment the data and are subsequently used for image reconstruction. A neural network is trained using these degraded images with different masks to predict the sharp image portions corresponding to the masked pixels, with high-quality images used as supervision.

[0051] Further, in S102: for the pre-trained image inpainting network, the importance of each network layer is calculated, and the top k network layers in terms of importance are selected, including:

[0052] S102-1: For a low-quality image with a random mask, define a discrete mask attribution path from the low-quality image with a random mask to a low-quality image without a mask; in the discrete mask attribution path, the mask rate continuously decreases.

[0053] S102-2: Convert discrete mask attribution paths into differentiable and continuous mask attribution paths;

[0054] S102-3: Based on the differentiable and continuous mask attribution path, calculate the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network; use the local normalized cumulative gradient of each network layer as the mask attribution flux.

[0055] S102-4: Take the mean of the absolute values ​​of the mask attribution flux as the importance of each network layer;

[0056] S102-5: Sort the importance in descending order and select the top k network layers.

[0057] Further, S102-1: For a low-quality image with a random mask, a discrete mask attribution path is defined from the low-quality image with the random mask to the low-quality image without the mask, specifically including:

[0058] Define a discrete mask attribution path as a non-random path that progressively adds pixels to the mask image to the complete image.

[0059]

[0060] Where i represents the pixel index, r is the initial mask ratio of the input mask image, and α∈(r,1] represents the mask ratio variable. i ∈(1-,1] is a set of constants. i This represents the complete input, x′ i This represents a masked image.

[0061] Throughout the entire path, the mask ratio of the masked image continuously decreases until it becomes a complete image.

[0062]

[0063]

[0064] in, This represents the image corresponding to the masking rate 1-r along the masking attribution path. represents the image corresponding to a mask rate of 0 on the mask attribution path; x′ represents the initial mask image, i.e., the mask image with a mask rate of r used for pre-training; x represents the complete image, used for model fine-tuning and inference.

[0065] Further, S102-2: converting the discrete mask attribution path into a differentiable and continuous mask attribution path specifically includes:

[0066] The discrete mask attribution path is transformed into a differentiable and continuous mask path using a function approximation method.

[0067]

[0068] Here, δ represents the approximation degree of the approximation function. The larger δ is, the closer the differentiable mask attribution path is to the discrete mask attribution path.

[0069] Further, S102-3: Based on the differentiable and continuous mask attribution path, calculate the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network, specifically including:

[0070] The cumulative gradient vector output by each network layer is used. As a mask attribution flux;

[0071]

[0072] in, This indicates that the image restoration network F, when given an input image, Output at time; This indicates that the image restoration network F, when given an input image, The partial derivative of the output variable at a certain intermediate node; This indicates that the image restoration network F, when given an input image, Intermediate variables for input image Partial derivative of mask rate α.

[0073] Understandably, after pre-training, the proposed importance assessment technique based on mask attribute conductance is used to evaluate the importance of each network layer in the neural network for the fine-tuning stage. The specific details of the importance assessment process are as follows: For a masked image, a differentiable continuous integral path with a continuously decreasing mask rate is defined from the masked image to the complete image. The local normalized cumulative gradient of each network layer is calculated, which represents the sensitivity of each network layer to changes in the mask rate and is considered the network's importance in the fine-tuning stage. This differentiable continuous integral path is called the Mask Attribute Path (MAP), and the local normalized cumulative gradient is called the Mask Attribute Conductance (MAC).

[0074] After the training and importance assessment processes described above are completed, the importance of each network layer is evaluated, and the top k% of network layers are selected for fine-tuning. The fine-tuning phase uses complete degraded images as input to address the input discrepancies caused by incomplete data in the pre-training phase and the inference phase, while preserving as much pre-training prior knowledge as possible. Because neither the training nor the fine-tuning process introduces any additional parameters, the final model maintains the same structure and computational methods as the original neural network model, without adding any inference overhead.

[0075] A discrete mask attribution path is defined as a non-random path that progressively adds pixels to a mask image until a complete image is formed. Throughout this path, the mask ratio of the mask image continuously decreases until a complete image is achieved. A function approximation method is used to transform the discrete mask attribution path into a differentiable and continuous mask path, allowing the computation of the cumulative gradient of any network layer. The average of the absolute values ​​of the cumulative gradient vectors output by each network layer is used as the mask attribution flux, representing the importance of each network layer relative to the fine-tuning stage.

[0076] Further, in S103: construct a second training set, which includes: several high-quality images, each of which has a corresponding low-quality image without a random mask.

[0077] During the fine-tuning phase, the importance of each network layer is ranked, and the most important network layers can be selected for fine-tuning.

[0078] The aim of this method is to mine the intrinsic information of image content and establish a unified model to handle various image restoration problems. This method designs a novel paradigm based on image mask modeling, utilizing image reconstruction to allow the model to learn the intrinsic information of the image rather than specific degradation patterns. This paradigm enables the model to handle multiple image restoration tasks simultaneously while maintaining balanced and superior performance. Furthermore, this paradigm can be effectively applied to various neural network models, achieving better performance without additional computational cost or parameters.

[0079] This invention mainly consists of three stages: image masking pre-training, importance assessment based on mask attribute propagation, and model fine-tuning. In the pre-training stage, the invention randomly masks damaged images at the pixel level, forcing the network to predict the clear image corresponding to the masked pixels and extract inherent image information from the damaged images. After pre-training, the proposed importance assessment technique based on mask attribution flux is used to evaluate the importance of each network layer in the neural network for the fine-tuning stage. The specific details of the importance assessment process are as follows: For a masked image, a mask attribution path is defined, and the mask attribution flux of each network layer is calculated, which is the sensitivity of each network layer to changes in the mask rate, and is considered as the network importance for the fine-tuning stage. After the above training and importance assessment processes are completed, the importance of each network layer is evaluated, and the top k% of network layers are selected for fine-tuning. The fine-tuning stage uses complete degraded images as input to address the input differences caused by incomplete data in the pre-training stage and the inference stage, while preserving pre-training priors as much as possible. Because neither the training nor the fine-tuning process introduces any additional parameters, the final model maintains the same structure and operation as the original neural network model, without increasing any inference overhead.

[0080] Figure 2 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the defogging task. Figure 3 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the rain removal task. Figure 4 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the denoising task. Figure 5 This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods in the low-light enhancement task. Figure 6This is a schematic diagram comparing the output results of the implementation method of this invention with other existing methods on the kernel removal fuzzing task. Figure 7 This is a schematic diagram comparing the output results of the implementation method of this invention and other existing methods in the task of removing JPEG compression artifacts. Figure 8 This is a schematic diagram of the statistical results of the implementation method of the present invention.

[0081] This implementation is evaluated on image inpainting tasks (dehazing, deraining, denoising, lowlight enhancement, kernel blur removal, and JPEG compression artifact removal) and over 10 datasets, applied to neural network models of SwinIR and PromptIR. The effectiveness of the RAM method in this implementation is demonstrated.

[0082] The method proposed in this implementation is compared with eight other methods, including Restormer, MPRNet, NAFNet, SwinIR, DL, TAPE, AirNet, and PromptIR.

[0083] Example 2

[0084] This embodiment provides an integrated image inpainting system based on image mask modeling, including:

[0085] The pre-training module is configured to: input the first training set into the image restoration network, use a low-quality image with a random mask as the input value of the image restoration network, use the corresponding high-quality image as the output value of the image restoration network, train the image restoration network, and obtain the pre-trained image restoration network.

[0086] The importance calculation module is configured to: calculate the importance of each network layer of the pre-trained image inpainting network, and select the top k network layers in terms of importance.

[0087] The fine-tuning module is configured to: input the second training set into the pre-trained image inpainting network, use the low-quality image without random mask as the input value of the pre-trained image inpainting network, and use the corresponding high-quality image as the output value of the pre-trained image inpainting network to train the pre-trained image inpainting network; wherein, during the training process of the pre-trained image inpainting network, the network parameters of the non-top k network layers remain unchanged, and only the network parameters of the top k network layers are optimized to obtain the final trained image inpainting network;

[0088] The repair module is configured to: acquire the image to be repaired, input the image to be repaired into the finally trained image repair network, and obtain the repaired image.

[0089] It should be noted that the pre-training module, importance calculation module, fine-tuning module, and repair module mentioned above correspond to steps S101 to S104 in Embodiment 1. The examples and application scenarios implemented by these modules and their corresponding steps are the same, but they are not limited to the content disclosed in Embodiment 1. It should be noted that these modules, as part of the system, can be executed in a computer system such as a set of computer-executable instructions.

[0090] The descriptions of each embodiment in the above embodiments have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.

[0091] The proposed system can be implemented in other ways. For example, the system embodiments described above are merely illustrative, and the division of modules described above is only a logical functional division. In actual implementation, there may be other division methods. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not executed.

[0092] Example 3

[0093] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Embodiment 1.

[0094] It should be understood that in this embodiment, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0095] Memory may include read-only memory and random access memory, and provides instructions and data to the processor. A portion of memory may also include non-volatile random access memory. For example, memory may also store information about the device type.

[0096] In the implementation process, each step of the above method can be completed by the integrated logic circuits in the processor hardware or by software instructions.

[0097] The method in Embodiment 1 can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor. The software modules can reside in readily available storage media in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not provided here.

[0098] Those skilled in the art will recognize that the units and algorithm steps described in connection with the various examples of this embodiment can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this invention.

[0099] Example 4

[0100] This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.

[0101] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. An integrated image inpainting method based on image mask modeling, characterized in that, include: The first training set is input into the image restoration network. The low-quality image with a random mask is used as the input value of the image restoration network, and the corresponding high-quality image is used as the output value of the image restoration network. The image restoration network is trained to obtain the pre-trained image restoration network. For the pre-trained image inpainting network, the importance of each network layer is calculated, and the top k network layers by importance are selected, including: For a low-quality image with a random mask, a discrete mask attribution path is defined from the low-quality image with a random mask to a low-quality image without a mask; in the discrete mask attribution path, the mask rate continuously decreases. The discrete mask attribution path is transformed into a differentiable and continuous mask attribution path. Based on the differentiable and continuous mask attribution path, the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network is calculated; the local normalized cumulative gradient of each network layer is used as the mask attribution flux. The mean of the absolute values ​​of the mask attribution flux is taken as the importance of each network layer. Sort the network layers by importance from largest to smallest, and select the top k layers. The process of converting discrete mask attribution paths into differentiable and continuous mask attribution paths specifically includes: The discrete mask attribution path is transformed into a differentiable and continuous mask path using a function approximation method. : ; in, It indicates the degree of approximation of the approximate function. The larger the value, the closer the differentiable mask attribution path is to the discrete mask attribution path; The method based on the differentiable and continuous mask attribution path calculates the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network, specifically including: The cumulative gradient vector output by each network layer is used. As a mask attribution flux; ; in, Image restoration network When accepting input image Output at time; Image restoration network When accepting input image The partial derivative of the output variable at a certain intermediate node; Image restoration network When accepting input image Intermediate variables for input image mask rate The partial derivatives; The second training set is input into the pre-trained image inpainting network. Low-quality images without random masks are used as input values ​​to the pre-trained image inpainting network, and corresponding high-quality images are used as output values ​​to train the pre-trained image inpainting network. During the training process, the network parameters of non-top k layers remain unchanged, and only the network parameters of the top k layers are optimized to obtain the final trained image inpainting network. The image to be repaired is obtained and then input into the finally trained image inpainting network to obtain the repaired image.

2. The integrated image inpainting method based on image mask modeling as described in claim 1, characterized in that, For a low-quality image with a random mask, a discrete mask attribution path is defined from the low-quality image with the random mask to the low-quality image without the mask, specifically including: Define a discrete mask attribution path as a non-random path that progressively adds pixels to the mask image to the complete image. : ; in, Index representing a pixel, The initial mask ratio is the input mask image. Represents the mask rate variable. It is a set of constants; This indicates complete input. Represents a mask image; Throughout the entire path, the mask ratio of the masked image continuously decreases until it becomes a complete image. ; ; in, This represents the image corresponding to the masking rate 1-r along the masking attribution path. This represents the image corresponding to a mask rate of 0 on the mask attribution path. This represents the initial mask image, i.e., the mask image with a mask rate of r used for pre-training; This represents the complete image, used for model fine-tuning and inference.

3. The integrated image inpainting method based on image mask modeling as described in claim 1, characterized in that, The second training set includes several high-quality images, each of which is accompanied by a corresponding low-quality image without a random mask.

4. An integrated image inpainting system based on image mask modeling, characterized in that, include: The pre-training module is configured to: input the first training set into the image restoration network, use a low-quality image with a random mask as the input value of the image restoration network, use the corresponding high-quality image as the output value of the image restoration network, train the image restoration network, and obtain the pre-trained image restoration network. The importance calculation module is configured to: calculate the importance of each network layer in a pre-trained image inpainting network, and select the top k network layers based on their importance ranking, including: For a low-quality image with a random mask, a discrete mask attribution path is defined from the low-quality image with a random mask to a low-quality image without a mask; in the discrete mask attribution path, the mask rate continuously decreases. The discrete mask attribution path is transformed into a differentiable and continuous mask attribution path. Based on the differentiable and continuous mask attribution path, the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network is calculated; the local normalized cumulative gradient of each network layer is used as the mask attribution flux. The mean of the absolute values ​​of the mask attribution flux is taken as the importance of each network layer. Sort the network layers by importance from largest to smallest, and select the top k layers. The process of converting discrete mask attribution paths into differentiable and continuous mask attribution paths specifically includes: The discrete mask attribution path is transformed into a differentiable and continuous mask path using a function approximation method. : ; in, It indicates the degree of approximation of the approximate function. The larger the value, the closer the differentiable mask attribution path is to the discrete mask attribution path; The method based on the differentiable and continuous mask attribution path calculates the local normalized cumulative gradient of each network layer in the pre-trained image inpainting network, specifically including: The cumulative gradient vector output by each network layer is used. As a mask attribution flux; ; in, Image restoration network When accepting input image Output at time; Image restoration network When accepting input image The partial derivative of the output variable at a certain intermediate node; Image restoration network When accepting input image Intermediate variables for input image mask rate The partial derivatives; The fine-tuning module is configured to: input the second training set into the pre-trained image inpainting network, use the low-quality image without random mask as the input value of the pre-trained image inpainting network, and use the corresponding high-quality image as the output value of the pre-trained image inpainting network to train the pre-trained image inpainting network; wherein, during the training process of the pre-trained image inpainting network, the network parameters of the non-top k network layers remain unchanged, and only the network parameters of the top k network layers are optimized to obtain the final trained image inpainting network; The repair module is configured to: acquire the image to be repaired, input the image to be repaired into the finally trained image repair network, and obtain the repaired image.

5. An electronic device, characterized in that it comprises: Memory is used to store computer-readable instructions in a non-transitory manner. as well as Processor, for executing the computer-readable instructions, When the computer-readable instructions are executed by the processor, they perform the method described in any one of claims 1-3.

6. A storage medium characterized by being non-transitory. The system stores computer-readable instructions, wherein, when the non-transitory computer-readable instructions are executed by a computer, the instructions of the method according to any one of claims 1-3 are executed.

7. A computer program product, characterized in that, Includes a computer program, which, when run on one or more processors, is used to implement the method described in any one of claims 1-3.

Citation Information

Patent Citations

  • Self-supervised facial expression recognition method combining comparative learning with mask image modeling

    CN116386104A

  • High-resolution image restoration method and device

    CN116433520A