Model training method and device, image processing method and device and electronic equipment

By obtaining training samples that do not contain target elements and other training samples to train complementary image repair models, the problem of reduced accuracy and stability of the image repair model during the image repair process is solved, and the accuracy and stability of image repair are achieved. promote.

CN118628868APending Publication Date: 2024-09-10BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1

Patent Information

Application Number
CN202410799751.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the existing technology, the images used to train the image repair model are randomly obtained, resulting in reduced accuracy and stability of the model during the image repair process.

Method used

By obtaining training samples in which the mask area of ​​the target image and the mask image does not include the target element, and using other training samples to train the image repair model, complementary first and second image repair models are formed to improve the accuracy of image repair. and stability.

Benefits of technology

It achieves a comprehensive improvement in the accuracy and stability of the image repair model, and enhances the controllability and accuracy of the image repair process through the complementary approach of dual models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118628868A
    Figure CN118628868A
Patent Text Reader

Abstract

The invention relates to a model training method and device, an image processing method and device, electronic equipment and a computer readable storage medium. The model training method comprises the steps that a training sample is acquired, the training sample comprises a target image and a mask image corresponding to the target image, and in the target image, a mask area indicated by the mask image corresponding to the target image does not comprise a target element; training the image restoration model by using the training sample, including training a first image restoration model in the image restoration model by using other training samples except the training sample, the first image restoration model being used for restoring the to-be-processed image to obtain a first image; the training sample is utilized to train a second image restoration model in the image restoration models, the second image restoration model is used for restoring the first image to obtain a second image, and the first image restoration model and the second image restoration model are complementary in image processing capability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image processing, and in particular to a model training method and device, an image processing method and device, an electronic device, and a computer storable medium. Background Art

[0002] Image Inpainting refers to repairing and reconstructing damaged images or removing redundant objects in images.

[0003] In the related art, an image and a mask image corresponding to the image are randomly obtained, and an image restoration model is trained using the random image and its mask image. Summary of the invention

[0004] In the related art, since the images used to train the image restoration model are acquired randomly, the image restoration model is prone to generate uncertain content during the image redrawing process, which reduces the accuracy and stability of the image restoration model during the image restoration process.

[0005] In view of the above technical problems, the present disclosure proposes a solution that can improve the accuracy and stability of image restoration of the image restoration model.

[0006] According to a first aspect of the present disclosure, a model training method is provided, comprising: obtaining training samples, the training samples comprising a target image and a mask image corresponding to the target image, wherein in the target image, a mask area indicated by the mask image corresponding to the target image does not include a target element; using the training samples, training an image restoration model, comprising: using other training samples except the training samples, training a first image restoration model in the image restoration model, wherein the first image restoration model is used to perform restoration processing on the image to be processed to obtain a first image; using the training samples, training a second image restoration model in the image restoration model, wherein the second image restoration model is used to perform restoration processing on the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing.

[0007] In some embodiments, obtaining a training sample includes: obtaining an initial image and a mask image corresponding to the initial image; in the initial image, using other elements in the initial image except the target element to replace the target element in the mask area indicated by the mask image corresponding to the initial image, to obtain a target image, wherein the mask image corresponding to the target image is the mask image corresponding to the initial image; determining the target image and the mask image corresponding to the target image as the training samples.

[0008] In some embodiments, in the initial image, using other elements in the initial image except the target element to replace the target element in the mask area indicated by the mask image corresponding to the initial image includes: in the initial image, using other elements in the mask area in the initial image except the target element to replace the target element in the mask area indicated by the mask image corresponding to the initial image.

[0009] In some embodiments, acquiring an initial image includes: acquiring a reference image, the reference image not including the target element; randomly adding the target element to the reference image to obtain the initial image; in the initial image, using other elements except the target element in the mask area in the initial image to replace the target element in the mask area indicated by the mask image corresponding to the initial image, including: replacing the pixel values ​​in the initial image located in the mask area with the pixel values ​​in the reference image located in the mask area.

[0010] In some embodiments, randomly adding the target element to the reference image to obtain the initial image includes: randomly generating an image including the target element as a random image; and superimposing the random image on the basis of the reference image to obtain the initial image.

[0011] In some embodiments, the target element includes characters, the characters in the random image are characters of random language, random font, and random size, and the characters in the random image are located at random positions in the random image.

[0012] In some embodiments, the complementary capabilities of the first image restoration model and the second image restoration model in image processing include: the capability of the first image restoration model in the first image processing is stronger than the capability of the second image restoration model in the first image processing, and the capability of the second image restoration model in the second image processing is stronger than the capability of the first image restoration model in the second image processing.

[0013] In some embodiments, the second image restoration model includes an image generation model and a fine-tuning training model, and the fine-tuning training model is used to fine-tune the image generation model during the process of training the second image restoration model.

[0014] In some embodiments, the fine-tuning training model is used to fine-tune the parameters of the image generation model during the process of training the second image restoration model; and / or the fine-tuning training model is embedded in the image generation model.

[0015] In some embodiments, the first image restoration model is used to restore the image to be processed based on the image to be processed and the mask image corresponding to the object to be processed, so as to obtain a first image; the second image restoration model is used to restore the first image based on the first image and the mask image corresponding to the image to be processed, so as to obtain a second image.

[0016] According to a second aspect of the present disclosure, an image processing method is provided, comprising: obtaining an image to be processed and a mask image corresponding to the image to be processed; and performing repair processing on the image to be processed using an image repair model according to the image to be processed and the mask image, wherein the image repair model is obtained in advance according to the model training method described in any of the above embodiments.

[0017] According to a third aspect of the present disclosure, a model training device is provided, comprising: an acquisition module, configured to acquire training samples, the training samples comprising a target image and a mask image corresponding to the target image, wherein in the target image, a mask area indicated by the mask image corresponding to the target object does not include a target element; a training module, configured to train an image restoration model using the training samples, comprising: training a first image restoration model in the image restoration model using other training samples except the training samples, wherein the first image restoration model is used to perform restoration processing on the image to be processed to obtain a first image; training a second image restoration model in the image restoration model using the training samples, wherein the second image restoration model is used to perform restoration processing on the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing.

[0018] According to the fourth aspect of the present disclosure, an image processing device is provided, comprising: an acquisition module, configured to acquire an image to be processed and a mask image corresponding to the image to be processed; a repair processing module, configured to perform repair processing on the image to be processed using an image repair model based on the image to be processed and the mask image, wherein the image repair model is obtained in advance according to the model training method of any of the above-mentioned embodiments.

[0019] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising: a memory; and a processor coupled to the memory, the processor being configured to execute the model training method or image processing method described in any of the above embodiments based on instructions stored in the memory.

[0020] According to a sixth aspect of the present disclosure, a computer-storable medium is provided, on which computer program instructions are stored. When the instructions are executed by a processor, the model training method or image processing method described in any of the above embodiments is implemented.

[0021] In the above embodiments, the accuracy and stability of image restoration of the image restoration model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] The accompanying drawings, which constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0023] The present disclosure may be more clearly understood from the following detailed description with reference to the accompanying drawings, in which:

[0024] Figure 1 is a block diagram illustrating a model training method according to some embodiments of the present disclosure;

[0025] Figure 2A is a schematic diagram showing an input picture according to some embodiments of the present disclosure;

[0026] Figure 2B is a schematic diagram showing a combined copy according to some embodiments of the present disclosure;

[0027] Figure 2C is a schematic diagram showing a process of fusing an input image and a combined text to obtain a combined image according to some embodiments of the present disclosure;

[0028] Figure 2D is a mask diagram illustrating a rectangular mask region according to some embodiments of the present disclosure;

[0029] Figure 2E is a mask diagram illustrating an elliptical mask region according to some embodiments of the present disclosure;

[0030] Figure 2F is a mask diagram showing an irregular pattern mask region according to some embodiments of the present disclosure;

[0031] Figure 2G is a schematic diagram showing a process of performing pixel replacement on a combined picture according to some embodiments of the present disclosure;

[0032] Figure 3 is a flowchart illustrating an image processing method according to some embodiments of the present disclosure;

[0033] Figure 4A is a schematic diagram showing an image to be processed according to some embodiments of the present disclosure;

[0034] Figure 4Bis a schematic diagram showing a mask image of an image to be processed according to some embodiments of the present disclosure;

[0035] Figure 4C is a schematic diagram showing a first image according to some embodiments of the present disclosure;

[0036] Figure 4D is a schematic diagram showing a second image according to some embodiments of the present disclosure;

[0037] Figure 5 is a block diagram illustrating a model training apparatus according to some embodiments of the present disclosure;

[0038] Figure 6 is a block diagram showing an image processing apparatus according to some embodiments of the present disclosure;

[0039] Figure 7 is a block diagram illustrating an electronic device according to some embodiments of the present disclosure;

[0040] Figure 8 is a block diagram illustrating a computer system for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION

[0041] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0042] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.

[0043] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0044] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0045] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0046] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0047] The following will combine 1, Figure 2A to Figure 2GThe model training method in some embodiments of the present disclosure is described in detail.

[0048] Figure 1 is a block diagram illustrating a model training method according to some embodiments of the present disclosure.

[0049] Figure 2A is a schematic diagram showing an input picture according to some embodiments of the present disclosure.

[0050] Figure 2B It is a schematic diagram showing a combined copy according to some embodiments of the present disclosure.

[0051] Figure 2C It is a schematic diagram showing the process of fusing an input image and a combined text to obtain a combined image according to some embodiments of the present disclosure.

[0052] Figure 2D is a mask diagram illustrating a rectangular mask area according to some embodiments of the present disclosure.

[0053] Figure 2E is a mask diagram illustrating an elliptical mask region according to some embodiments of the present disclosure.

[0054] Figure 2F is a mask diagram illustrating an irregular pattern mask area according to some embodiments of the present disclosure.

[0055] Figure 2G It is a schematic diagram showing a process of performing pixel replacement on a combined picture according to some embodiments of the present disclosure.

[0056] like Figure 1 As shown, the model training method includes: step S110, obtaining training samples, the training samples include a target image and a mask image corresponding to the target image, in the target image, the mask area indicated by the mask image corresponding to the target image does not include the target element; and step S120, using the training samples to train the image restoration model, including: using other training samples except the training samples to train the first image restoration model in the image restoration model, wherein the first image restoration model is used to restore the image to be processed to obtain the first image; using the training samples to train the second image restoration model in the image restoration model, wherein the second image restoration model is used to restore the first image to obtain the second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing. In some embodiments, the model training method is performed by a model training device.

[0057] In the above embodiment, in the training samples used to train the image restoration model, the mask area indicated by the mask image corresponding to the target object in the target object does not include the target element, so that the image restoration model is less likely to generate the target element in the mask area during the image restoration process, thereby making the image restoration process of the image restoration model more controllable and improving the accuracy and stability of image restoration. The image restoration model integrates the first image restoration model and the second image restoration model with complementary image processing capabilities, realizes the complementarity of the two models, and can further improve the accuracy of the image restoration model in image restoration. The first image restoration model completes the preliminary processing, and the second image restoration model controls the generation of uncertain elements in the image restoration. The fusion of this situation can further improve the accuracy and stability of the image restoration model in image restoration. Therefore, through the model training method in the embodiment of the present disclosure, the accuracy and stability of the image restoration model in image restoration can be improved from many aspects, and the comprehensive improvement of the accuracy and stability of the image restoration model in image restoration can be achieved.

[0058] In step S110, a training sample is obtained, the training sample includes a target image and a mask image corresponding to the target image, in which the mask area indicated by the mask image corresponding to the target object in the target image does not include the target element. In some embodiments, the target element is an element that the user does not expect to appear in the picture. For example, the training sample is image data related to the actual use scenario of the image restoration model.

[0059] In some embodiments, the attribute information of the target element in the target image is random. For example, the attribute information includes but is not limited to the shape, size, position, color, etc. of the target element. The attribute information can be set according to the target element itself.

[0060] In some embodiments, the pixel value of the mask area indicated by the mask image is a first value, and the pixel value of other areas in the mask image except the mask area is a second value. For example, the mask image is a black and white image.

[0061] In some embodiments, obtaining training samples may be achieved in the following manner.

[0062] First, an initial image and a mask image corresponding to the initial image are obtained.

[0063] Then, in the initial image, other elements except the target element in the initial image are used to replace the target element in the mask area indicated by the mask image corresponding to the initial image to obtain the target image. The mask image corresponding to the target image is the mask image corresponding to the initial image.

[0064] Finally, the target image and the mask image corresponding to the target image are determined as training samples.

[0065] In the above embodiment, using elements other than the target element in the initial image to replace the target element in the mask area indicated by the mask image corresponding to the initial image can assist the image restoration model in strengthening the semantic learning of elements other than the target element in the initial image during the image restoration process, thereby enabling the image restoration model to achieve an image restoration process that is more consistent with the scene or semantics of the initial image, further improving the accuracy and stability of image restoration.

[0066] In some embodiments, in the initial image, other elements other than the target element in the mask area of ​​the initial image may be used to replace the target element in the mask area indicated by the mask image corresponding to the initial image. Using other elements in the mask area of ​​the initial image for replacement can enable the image restoration model to further improve its understanding of semantic information such as the scene of the mask area of ​​the initial image during the image restoration process, thereby further improving the accuracy and stability of the image restoration model in performing image restoration on the mask area.

[0067] In some embodiments, acquiring the initial image includes: acquiring a reference image, the reference image not including the target element; and randomly adding the target element to the reference image to obtain the initial image. In this case, in the initial image, using other elements other than the target element in the mask area in the initial image to replace the target element in the mask area indicated by the mask image corresponding to the initial image includes replacing the pixel value in the mask area in the initial image with the pixel value in the mask area in the initial image.

[0068] The operation of replacing the pixel values ​​of the mask area of ​​the initial image refers to replacing the pixel value of any pixel position in the mask area in the initial image with the pixel value of the any pixel position in the mask area in the initial image. The pixel value in the mask area in the initial image mentioned here refers to the pixel value in the image area corresponding to the mask area in the initial image, that is, there is a one-to-one correspondence between the position coordinates of the pixel points in the image area corresponding to the mask area in the initial image and the position coordinates of the pixel points in the mask area.

[0069] In the above embodiment, by replacing the pixel value of any pixel position in the mask area in the initial image with the pixel value of any pixel position in the mask area in the reference image, that is, the sub-image in the mask area in the initial image is completely replaced by the sub-image in the mask area in the reference image. This enables the image restoration model to more accurately learn semantic information such as the scene in the mask area in the reference image during the image restoration process, thereby further improving the accuracy and stability of the image restoration model in performing image restoration on the mask area.

[0070] In some embodiments, when the initial image is obtained from a reference image, a mask image corresponding to the reference image may also be obtained as the mask image corresponding to the initial image.

[0071] In some embodiments, randomly adding a target element to a reference image to obtain an initial image may include: randomly generating an image including the target element as a random image; and superimposing the random image on the basis of the reference image to obtain the initial image.

[0072] In some embodiments, the target element includes characters, and the characters in the random image are characters of random languages, random fonts, and random sizes, and the characters in the random image are located at random positions in the random image. For example, the characters include but are not limited to text, numbers, and special symbols. The text includes but is not limited to text in various languages. For another example, the characters are characters that meet preset conditions, such as irregular text.

[0073] When the target element is a mixed text, for example, the training sample can be generated in the following manner: Mixed here means that multiple texts have different attribute values ​​for the same attribute.

[0074] First, randomly select an image from the image set that does not contain mixed text as the input image. Input image reference Figure 2A For example, the input image is the aforementioned reference image.

[0075] Secondly, construct a combination copy that includes mixed text. Taking the target element as mixed text as an example, use random languages ​​(Chinese, English, etc.), random fonts, random text sizes, and random placements to construct a random combination copy. Figure 2B .

[0076] Next, the randomly selected input image is merged with the constructed combined copy, so that the input image is accompanied by the random combined copy to form a combined image. This process can be referred to Figure 2C . Figure 2C The plus sign "+" in represents a fusion operation. For example, the combined image is the aforementioned initial image.

[0077] Then, a random mask image is generated. For example, a random erasing operation is performed on an image with a single pixel value to obtain a random mask image. The mask image can be of any shape, including but not limited to a rectangle, an ellipse, and an irregular shape. For example, the mask image is identified by a grayscale image, the pixel value of the mask area (e.g., the area to be erased) is 255, and the pixel value of other areas except the mask area (e.g., the non-erased area) is 0. Mask image reference Figure 2D , Figure 2E and Figure 2F . Figure 2DThe mask map includes a rectangular mask region. Figure 2E The mask image includes an elliptical mask region. Figure 2F A mask region including irregular shapes. For example, the mask image is the aforementioned mask image.

[0078] Finally, the pixel values ​​of the erased area of ​​the mask image are all replaced with the pixel values ​​of the area corresponding to the erased area in the input image to obtain the target image. Under the condition that text exists in the non-erased area, it is easier to derive text. In the case of erasing text, the present disclosure can strengthen the possible lines of text removal and reduce the probability of text generation. Figure 2G ,based on Figure 2D The mask map of Figure 2C The combined image obtained in the above is processed by pixel replacement to obtain the target image. Figure 2G The plus sign “+” in represents the pixel replacement process.

[0079] In some other embodiments, the target element may further include a watermark. The watermark in the random image is of a random size and is located at a random position in the random image.

[0080] Those skilled in the art should understand that the target element can be any element that can be displayed in an image, and the target element is set by the user according to the actual usage scenario. The target element can also be some user-defined elements.

[0081] In step S120, the image restoration model is trained using the training samples. The image restoration model is used to restore the image to be processed, including: using other training samples except the training samples to train a first image restoration model in the image restoration model, wherein the first image restoration model is used to restore the image to be processed to obtain a first image; using the training samples to train a second image restoration model in the image restoration model, wherein the second image restoration model is used to restore the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing.

[0082] In some embodiments, other training samples include other images other than the aforementioned target image and mask images corresponding to other images. For example, in other images, the mask area indicated by the mask image corresponding to other images may include the target element or may not include the target element.

[0083] In some embodiments, the image restoration model is used to perform image erasure processing on the masked area in the target image. For example, the trained image restoration model can be used by users in the e-commerce field to process and fine-tune the image materials used in the store operation process according to the traffic rules and compliance requirements of the e-commerce platform so that the specified elements do not appear in the image materials.

[0084] In some embodiments, the target image and its corresponding mask image may be converted into tensors of size [W, H, 3] and [W, H], respectively. W and H represent the width and height of the image, respectively, and 3 represents the number of channels. The image restoration model is trained using the tensor corresponding to the target image and the tensor corresponding to the mask image. For example, when the image restoration model converges or reaches a certain number of training times, the training ends.

[0085] In some embodiments, the first image restoration model has a stronger capability in a first image processing aspect than the second image restoration model has a stronger capability in a second image processing aspect than the first image restoration model has a stronger capability in a second image processing aspect.

[0086] In some embodiments, the first image restoration model can be implemented by a MAT (Mask-Aware Transformer for Large Hole Image Inpainting) model, a Lama (Resolution-robust Large Mask Inpainting with Fourier Convolutions) model, a CM-GAN (Cascaded modulation Generative Adversarial Networks) model or similar software.

[0087] In some embodiments, the second image restoration model can be implemented by an SD Inpainting (stable diffusion Inpainting, image restoration based on a stable diffusion model) model, an SD XL (Stable Diffusion XL, two-stage cascade diffusion) model, a combination of an SD Inpainting model or an SD XL model and a LORA (Low-Rank Adaptation of Large Language Models, low-rank adaptation of large language models) model, a combination of SD Inpainting or SD XL and a LyCORIS (Lora by Yond Conventional methods, Other Rank adaptation Implementations for Stable diffusion, beyond conventional rank adaptation methods to achieve SD) model, a combination of SD Inpainting or SDXL and a textual inversion model, a Hypernetwork model, a Dreambooth model or similar software.

[0088] The LyCORIS model has more layer parameters than the LORA model. The Hypernetwork model is a neural network architecture that allows the parameters (i.e. weights) of the neural network to be dynamically generated. The Dreambooth model is a model that uses a technique for fine-tuning diffusion models (such as stable diffusion) by injecting custom topics into the model.

[0089] Taking the software in which the first image restoration model is a MAT model and the second image restoration model is a combination of the SD Inpainting model and the LORA model as an example, the first image restoration model is stronger than the second image restoration model in terms of long-distance information interaction in image processing, and the second image restoration model is stronger than the first image restoration model in terms of semantic understanding in image processing. The first image restoration model and the second image restoration model complement each other, making the image restoration result more in line with the actual situation, thereby improving the accuracy of image restoration. Software such as the LORA model is compact and does not affect the original model weight.

[0090] Efficient long-distance information interaction plays an important role in image restoration. In order to achieve long-distance information interaction (also known as long-distance information interaction), either an independent attention mechanism or software such as Transformer is used, but considering the computational cost, these models usually act on low-resolution images or features. Software such as the MAT model can be used to deal with the problem of large-area pixel loss. The software such as the MAT model combines the advantages of software such as transformers and convolution to effectively process high-resolution images.

[0091] At the same time, the software such as the MAT model carefully designs each component of the model to ensure the high fidelity and diversity of the restored images. Specifically, the software such as the MAT model customizes a transformer-like software structure for image restoration, in which the attention module aggregates information only from some valid pixels. A large number of experiments have proved that the software such as the MAT model has achieved good results on multiple benchmark datasets. However, the software such as the MAT model is trained without semantic annotations and encounters difficulties when dealing with objects with various shapes, such as running animals. Due to the lack of semantic context, the software such as the MAT model failed in the task of restoring cats and cars. At the same time, due to the lack of semantic understanding, the software such as the MAT model cannot fully understand and repair the specific details of the objects. Based on this, the software such as the MAT model can be integrated with models that are good at semantic understanding to form complementary advantages.

[0092] For example, the Stable Diffusion (SD) model is a diffusion generative model based on latent space, which can generate diverse and rich image results based on prompt word descriptions and image references. Because the generative space is huge, software such as the SD model has been applied to a large number of generation or restoration tasks, including erasure scenes.

[0093] For example, software based on the SD inpainting model of SD realizes erasure optimization by inputting the original image and the erased image into UNet (UNetwork, U-shaped network) for feature extraction and learning, and redrawing the image according to context information and features.

[0094] Since software such as the SD model is trained with massive amounts of data, it can understand image semantic information and is naturally suitable for large-scale erasure and reconstruction scenes. It can generate a harmonious and unified background image, but this also leads to uncontrollable factors in the generated data. When it comes to restoration issues, the generated images often need to be both clean and concise. Because software such as the SD model is good at association and imagination, in the absence of constraints, even with targeted prompts, software such as the SD inpainting model is prone to generate uncertain content, such as irregular text, watermarks, additional elements, etc. In particular, when there is already text in the image, it is easier to generate text content in the erased area.

[0095] In this case, specific training can be performed using software such as the LORA model to alleviate the derivative problems of uncertain content. Software such as the LORA model can be understood as a plug-in for software such as the SD model.

[0096] For another example, software such as the LaMa model can increase the receptive field, stimulate the potential of the model network, and can also complement the advantages of other models to improve the accuracy of image restoration. Software such as the LaMa model uses fast Fourier convolutions (FFCs) to increase the receptive field, and finally forms a large mask in painting (LaMa). At the same time, software such as the LaMa model uses perceptual loss to maintain the consistency of global structure and shape, and improves the mask generation strategy during training. The resulting large-area mask in painting stimulates the potential of the network. Software such as the LaMa model is only trained on limited data, and its performance on complex images on the Internet is not ideal. In addition, although the software such as the LaMa model uses a large receptive field, it uses software such as CNN (Convolutional Neural Networks) to learn local features and global features, and has limited learning ability for long-distance information, and performs poorly for problems where the repair area is too large. Regarding the erasure and repair issues of materials in the e-commerce field, software such as the LaMa model is not good at erasing complex content areas or erasing large areas, and is prone to generating problems such as lack of semantics, blur and black spots. Based on this, software such as the LaMa model can be integrated with models that are good at long-distance information learning to form complementary advantages.

[0097] In the above embodiment, the image restoration model integrates the first image restoration model and the second image restoration model with complementary image processing capabilities, thereby realizing dual-model complementarity, which can further improve the accuracy of image restoration performed by the image restoration model.

[0098] In some embodiments, the second image restoration model includes an image generation model and a fine-tuning training model. The fine-tuning training model is used to fine-tune the image generation model during the training of the second image restoration model. Using the fine-tuning training model to fine-tune the image generation model can simplify the training process and improve the efficiency of training the image restoration model.

[0099] In some embodiments, the fine-tuning training model is used to fine-tune the parameters of the image generation model during the training of the second image restoration model. Only fine-tuning the parameters can further simplify the training process and further improve the efficiency of training the image restoration model.

[0100] In some embodiments, the fine-tuning training model is embedded in the image generation model. By embedding the fine-tuning training model into the image generation model, there is no need to change the structure of the image generation model itself, making the training process more efficient and simple.

[0101] The following will be combined Figure 3 , Figure 4A , Figure 4B , Figure 4C , Figure 4D The image processing methods of some embodiments of the present disclosure are described in detail.

[0102] Figure 3 is a flowchart illustrating an image processing method according to some embodiments of the present disclosure.

[0103] Figure 4A is a schematic diagram showing an image to be processed according to some embodiments of the present disclosure.

[0104] Figure 4B is a schematic diagram showing a mask image of an image to be processed according to some embodiments of the present disclosure.

[0105] Figure 4C is a schematic diagram illustrating a first image according to some embodiments of the present disclosure.

[0106] Figure 4D is a schematic diagram showing a second image according to some embodiments of the present disclosure.

[0107] like Figure 3 As shown, the image processing method includes steps S310 to S320. In some embodiments, the image processing method is performed by an image processing device.

[0108] In step S310, an image to be processed and a mask image corresponding to the image to be processed are obtained.

[0109] In step S320, the image to be processed is repaired using an image repair model according to the image to be processed and the mask image. The image repair model is obtained in advance according to the model training method in any embodiment of the present disclosure.

[0110] In some embodiments, the image restoration model includes a first image restoration model and a second image restoration model. In this case, the image to be processed may be restored in the following manner.

[0111] First, according to the image to be processed and the mask image, the first image is repaired using the first image repair model to obtain a first image. Then, according to the first image and the mask image, the second image is repaired using the second image repair model to obtain a second image. In some embodiments, there may be one or more second images.

[0112] In some embodiments, a tensor of an image to be processed and a tensor of a mask image may be generated, and the generated tensor may be input into a first image restoration model to obtain a tensor representing the first image, and then the tensor representing the first image and the tensor of the mask image may be input into a second image restoration model to obtain at least one tensor representing the second image, and finally the at least one tensor representing the second image may be converted into at least one second image. For example, the sizes of the tensors of the image to be processed, the first image, and the second image are all [W, H, 3], and the size of the tensor of the mask image is [W, H].

[0113] By using the reference above Figure 2A to Figure 2G Take the training sample training image restoration model obtained as an example. In the case where the first image restoration model is software such as the MAT model and the second image restoration model is software such as a combination model of the SD model and the LORA model, Figure 4A The image to be processed and Figure 4B The mask image of the image to be processed is input into the first image restoration model to obtain Figure 4C The first image is shown. Figure 4C The first image shown and Figure 4B The mask image shown is input into the second image restoration model to obtain Figure 4D The second image is shown.

[0114] The first image is an image initially redrawn by software such as the MAT model, such as Figure 4C As shown in , the first image is often a relatively clean and concise image, but there are image areas with distorted curves and no semantics (indicated by Figure 4C (marked with a white rectangle). Figure 4D Relative to Figure 4C, which is more concise, complete, smooth, and natural, with semantics consistent with the actual scene, and no target elements such as derived text. The image restoration model obtained by the model training method disclosed in the present invention can alleviate the problem of target element derivation.

[0115] Figure 5 is a block diagram illustrating a model training apparatus according to some embodiments of the present disclosure.

[0116] like Figure 5 As shown, the model training device 5 includes an acquisition module 51 and a training module 52.

[0117] The acquisition module 51 is configured to acquire a training sample, wherein the training sample includes a target image and a mask image corresponding to the target image, wherein in the target image, a mask area indicated by the mask image corresponding to the target object does not include a target element, for example, by performing Figure 1 Step S110 is shown.

[0118] The training module 52 is configured to use the training samples to train the image restoration model, including: using other training samples except the training samples to train a first image restoration model in the image restoration model, wherein the first image restoration model is used to restore the image to be processed to obtain a first image; using the training samples to train a second image restoration model in the image restoration model, wherein the second image restoration model is used to restore the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing, for example, performing the following steps: Figure 1 Step S120 is shown.

[0119] In some embodiments, the acquisition module 51 includes an acquisition unit and a replacement unit. The acquisition unit is configured to acquire an initial image and a mask image corresponding to the initial image. The replacement unit is configured to replace the target element in the mask area indicated by the mask image corresponding to the initial image with other elements in the initial image except the target element.

[0120] In some embodiments, the replacement unit is further configured to replace, in the initial image, the target element in the mask area indicated by the mask image corresponding to the initial image with other elements in the mask area in the initial image except the target element.

[0121] In some embodiments, the initial image does not include the target element. The replacement unit is further configured to randomly add the target element to the initial image to obtain an intermediate image; replace the pixel values ​​in the intermediate image located in the mask area with the pixel values ​​in the initial image located in the mask area to obtain a target image, wherein the mask image corresponding to the target object is the mask image corresponding to the initial image; and determine the target image and the mask image corresponding to the target image as the training samples.

[0122] In some embodiments, the replacement unit is further configured to randomly generate an image including the target element as a random image; and superimpose the random image on the basis of the initial image to obtain the intermediate image.

[0123] In some embodiments, the target element includes characters, the characters in the random image are characters of random language, random font, and random size, and the characters in the random image are located at random positions in the random image.

[0124] In some embodiments, the image restoration model includes a first image restoration model and a second image restoration model, wherein the capability of the first image restoration model in the first image processing aspect is stronger than the capability of the second image restoration model in the first image processing aspect, and the capability of the second image restoration model in the second image processing aspect is stronger than the capability of the first image restoration model in the second image processing aspect.

[0125] In some embodiments, the training module 52 includes a first training module and a second training module. The first training module is configured to train the first image restoration model using other training samples other than the training samples, wherein the first image restoration model is used to perform restoration processing on the image to be processed to obtain the first image. The second training module is configured to train the second image restoration model using the training samples, wherein the second image restoration model is used to perform restoration processing on the first image to obtain the second image.

[0126] In some embodiments, the second image restoration model includes an image generation model and a fine-tuning training model, and the fine-tuning training model is used to fine-tune the image generation model during the process of training the second image restoration model.

[0127] In some embodiments, the fine-tuning training model is used to fine-tune the parameters of the image generation model during the process of training the second image restoration model.

[0128] In some embodiments, the first image restoration model is used to restore the image to be processed based on the image to be processed and the mask image corresponding to the object to be processed, so as to obtain a first image; the second image restoration model is used to restore the first image based on the first image and the mask image corresponding to the image to be processed, so as to obtain a second image.

[0129] Figure 6 is a block diagram illustrating an image processing apparatus according to some embodiments of the present disclosure.

[0130] like Figure 6 As shown, the image processing device 6 includes an acquisition module 61 and a repair processing module 62 .

[0131] The acquisition module 61 is configured to acquire the image to be processed and the mask image corresponding to the image to be processed, for example, by performing the following steps: Figure 3 Step S310 is shown.

[0132] The repair processing module 62 is configured to perform repair processing on the image to be processed using an image repair model according to the image to be processed and the mask image, wherein the image repair model is obtained in advance according to the model training method in any embodiment of the present disclosure, for example, by executing Figure 3 Step S320 is shown.

[0133] Figure 7 is a block diagram illustrating an electronic device according to some embodiments of the present disclosure.

[0134] like Figure 7 As shown, the electronic device 7 includes a memory 71; and a processor 72 coupled to the memory 71. The memory 71 is used to store instructions for executing the model training method or the image processing method corresponding to the embodiment. The processor 72 is configured to execute the model training method or the image processing method in any of the embodiments of the present disclosure based on the instructions stored in the memory 71.

[0135] Figure 8 is a block diagram illustrating a computer system for implementing some embodiments of the present disclosure.

[0136] like Figure 8 As shown, the computer system 80 may be embodied in the form of a general-purpose computing device. The computer system 80 includes a memory 810, a processor 820, and a bus 800 that connects the various system components.

[0137] The memory 810 may include, for example, a system memory, a non-volatile storage medium, and the like. The system memory may store, for example, an operating system, an application, a boot loader, and other programs. The system memory may include a volatile storage medium, such as a random access memory (RAM) and / or a cache memory. The non-volatile storage medium may store, for example, instructions for executing at least one of the corresponding embodiments of the model training method or the image processing method. The non-volatile storage medium includes, but is not limited to, a disk storage, an optical storage, a flash memory, and the like.

[0138] The processor 820 can be implemented by a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistors, etc. Discrete hardware components. Accordingly, each module such as the judgment module and the determination module can be implemented by a central processing unit (CPU) running instructions in a memory that execute corresponding steps, or can be implemented by a dedicated circuit that executes corresponding steps.

[0139] The bus 800 may use any of a variety of bus architectures, including, but not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, and a Peripheral Component Interconnect (PCI) bus.

[0140] The computer system 80 may also include an input / output interface 830, a network interface 840, a storage interface 850, etc. These interfaces 830, 840, 850, the memory 810, and the processor 820 may be connected via a bus 800. The input / output interface 830 may provide a connection interface for input / output devices such as a display, a mouse, and a keyboard. The network interface 840 may provide a connection interface for various networked devices. The storage interface 850 may provide a connection interface for external storage devices such as a floppy disk, a USB flash drive, and an SD card.

[0141] Here, various aspects of the present disclosure are described with reference to flowcharts and / or block diagrams of methods, devices, and computer program products according to embodiments of the present disclosure. It should be understood that each frame of the flowchart and / or block diagram and the combination of frames can be implemented by computer-readable program instructions.

[0142] These computer-readable program instructions may be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable device to produce a machine, so that the processor executes the instructions to produce means for implementing the functions specified in one or more blocks in the flowchart and / or block diagram.

[0143] These computer-readable program instructions may also be stored in a computer-readable memory, which cause the computer to work in a specific manner to produce an article of manufacture, including instructions for implementing the functions specified in one or more blocks in the flowchart and / or block diagram.

[0144] The present disclosure can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects.

[0145] Through the model training method and device, image processing method and device, electronic device, and computer storable medium in the above-mentioned embodiments, the accuracy and stability of image restoration of the image restoration model can be improved.

[0146] So far, the model training method and device, image processing method and device, electronic device, and computer storable medium according to the present disclosure have been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed herein.

Claims

1. A model training method, comprising: Acquire a training sample, the training sample including a target image and a mask image corresponding to the target image, wherein in the target image, a mask area indicated by the mask image corresponding to the target image does not include a target element; Using the training samples, training an image restoration model includes: Using other training samples except the training samples, training a first image restoration model in the image restoration model, wherein the first image restoration model is used to perform restoration processing on the image to be processed to obtain a first image; The training samples are used to train the second image restoration model in the image restoration model, wherein the second image restoration model is used to restore the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing.

2. The model training method according to claim 1, wherein: Obtaining training samples includes: Acquire an initial image and a mask image corresponding to the initial image; In the initial image, using other elements in the initial image except the target element to replace the target element in the mask area indicated by the mask image corresponding to the initial image, to obtain a target image, wherein the mask image corresponding to the target image is the mask image corresponding to the initial image; The target image and a mask image corresponding to the target image are determined as the training samples.

3. The model training method according to claim 2, wherein: In the initial image, using other elements in the initial image except the target element to replace the target element in the mask area indicated by the mask image corresponding to the initial image includes: In the initial image, other elements except the target element in the mask area in the initial image are used to replace the target element in the mask area indicated by the mask image corresponding to the initial image.

4. The model training method according to claim 3, wherein: Acquiring the initial image includes: acquiring a reference image, the reference image not including the target element; randomly adding the target element to the reference image to obtain the initial image; In the initial image, using other elements except the target element in the mask area in the initial image to replace the target element in the mask area indicated by the mask image corresponding to the initial image includes: replacing the pixel value located in the mask area in the initial image with the pixel value located in the mask area in the reference image.

5. The model training method according to claim 4, wherein: Randomly adding the target element to the reference image to obtain the initial image includes: randomly generating an image including the target element as a random image; On the basis of the reference image, the random image is superimposed to obtain the initial image.

6. The model training method according to claim 5, wherein: The target elements include characters, the characters in the random image are in random languages, random fonts, and random sizes, and the characters in the random image are located at random positions in the random image.

7. The model training method according to any one of claims 1 to 4, wherein: The complementary capabilities of the first image restoration model and the second image restoration model in image processing include: the capability of the first image restoration model in the first image processing is stronger than the capability of the second image restoration model in the first image processing, and the capability of the second image restoration model in the second image processing is stronger than the capability of the first image restoration model in the second image processing.

8. The model training method according to claim 1, wherein: The second image restoration model includes an image generation model and a fine-tuning training model, and the fine-tuning training model is used to fine-tune the image generation model during the training of the second image restoration model.

9. The model training method according to claim 8, wherein: The fine-tuning training model is used to fine-tune the parameters of the image generation model during the training of the second image restoration model; And / or the fine-tuned training model is embedded into the image generation model.

10. The model training method according to claim 1, wherein: The first image restoration model is used to perform restoration processing on the image to be processed based on the image to be processed and the mask image corresponding to the object to be processed to obtain a first image; The second image restoration model is used to perform restoration processing on the first image according to the first image and a mask image corresponding to the image to be processed, so as to obtain a second image.

11. An image processing method, comprising: Acquire an image to be processed and a mask image corresponding to the image to be processed; According to the image to be processed and the mask image, the image to be processed is repaired using an image repair model, wherein the image repair model is obtained in advance according to the model training method according to any one of claims 1 to 10.

12. A model training device comprising: an acquisition module configured to acquire a training sample, the training sample including a target image and a mask image corresponding to the target image, wherein in the target image, a mask area indicated by the mask image corresponding to the target object does not include a target element; The training module is configured to train the image restoration model using the training samples, including: Using other training samples except the training samples, training a first image restoration model in the image restoration model, wherein the first image restoration model is used to perform restoration processing on the image to be processed to obtain a first image; The training samples are used to train the second image restoration model in the image restoration model, wherein the second image restoration model is used to restore the first image to obtain a second image, and the first image restoration model and the second image restoration model have complementary capabilities in image processing.

13. An image processing device, comprising: an acquisition module, configured to acquire an image to be processed and a mask image corresponding to the image to be processed; The repair processing module is configured to perform repair processing on the image to be processed using an image repair model based on the image to be processed and the mask image, wherein the image repair model is obtained in advance according to the model training method according to any one of claims 1 to 10.

14. An electronic device comprising: Memory; as well as A processor coupled to the memory, the processor being configured to execute the model training method according to any one of claims 1 to 10 or the image processing method according to claim 11 based on instructions stored in the memory.

15. A computer-storable medium having computer program instructions stored thereon, which, when executed by a processor, implement the model training method according to any one of claims 1 to 10 or the image processing method according to claim 11.

Citation Information

Patent Citations

  • Image processing method and device, electronic equipment and storage medium

    CN112258404A

  • Image restoration method based on mask training

    CN115115537A

Cited By

  • Image processing method and related device

    CN121073837A

  • Microorganism shielding identification method, system, equipment and medium

    CN121437898A

  • A method, system, device and medium for identifying microbial occlusion

    CN121437898B