Image processing method, device, equipment and medium
By introducing random vector units and image adjustment units in the image processing model to generate random vector adjustment of image adjustment area, solve the problem of difficulty obtaining diversified optimization results in the existing technology, and realize the diversity and user satisfaction of the image processing method and user satisfaction. Improvement.
Patent Information
- Application Number
- CN202110518091.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-12
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2041-05-12
AI Technical Summary
Existing image optimization techniques are difficult to obtain diverse optimization results, making it difficult for users to choose satisfactory optimized images based on their personal preferences.
A pre-trained image processing model is used, which includes a random vector unit and an image adjustment unit. By generating random vectors that meet the preset probability distribution conditions, the image adjustment area is adjusted to obtain different styles of optimization results.
Achieve the optimization results based on the same optimization image to obtain the image to meet the diverse aesthetic needs of users.
Smart Images

Figure CN113191940B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and more specifically, to an image processing method, apparatus, device and medium. Background Art
[0002] With the development of electronic technology, images have become a part of life. For example, users can record their lives by taking photos. However, as the number of images increases, some incomplete images or images whose local areas do not meet the user's expectations will appear.
[0003] Under this circumstance, image optimization technology was developed. The inventor found that it is difficult to obtain diverse optimization results with related image optimization technology. Summary of the invention
[0004] In order to overcome at least one shortcoming in the prior art, in a first aspect, an embodiment of the present application provides an image processing method, which is applied to an electronic device, wherein the electronic device is configured with a pre-trained image processing model, wherein the image processing model includes a random vector unit and an image adjustment unit, wherein the random vector unit is used to generate a random vector that satisfies a preset probability distribution condition, and the method includes:
[0005] Acquire a first image having an image adjustment region;
[0006] inputting the random vector generated by the random vector unit and the first image into the image adjustment unit;
[0007] The image adjustment unit uses the random vector to adjust the image adjustment area to obtain a second image.
[0008] In a second aspect, an embodiment of the present application provides an image processing device, which is applied to an electronic device, wherein the electronic device is configured with a pre-trained image processing model, wherein the image processing model includes a random vector unit and an image adjustment unit, wherein the random vector unit is used to generate a random vector that satisfies a preset probability distribution condition, and the image processing device includes:
[0009] An image acquisition module, used for acquiring a first image having an image adjustment area, wherein the first image is obtained by repairing the image to be repaired;
[0010] An image processing module, used for inputting the random vector generated by the random vector unit and the first image into the image adjustment unit;
[0011] The image processing module is further configured to adjust the image adjustment area using the random vector through the image adjustment unit to obtain a second image.
[0012] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the image processing method is implemented.
[0013] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method is implemented.
[0014] Compared with the prior art, this application has the following beneficial effects:
[0015] In the image processing method, device, equipment and medium provided by the implementation of the present application, the electronic device obtains a first image with an image adjustment area; inputs the random vector generated by the random vector unit and the first image into the image adjustment unit; and the image adjustment unit uses the random vector to adjust the image adjustment area to obtain a second image. Since the random vector unit generates a different random vector each time, and inputs it into the image adjustment unit together with the first image, the data input by the image adjustment unit each time will change, and then a second image of a different style can be obtained based on the same first image. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0018] Figure 2 A flowchart of the steps of the image processing method provided in the embodiment of the present application;
[0019] Figure 3 One of the image adjustment area schematic diagrams provided in the embodiment of the present application;
[0020] Figure 4 The second schematic diagram of the image adjustment area provided in the embodiment of the present application;
[0021] Figure 5 A schematic diagram of the structure of the image processing model provided in the embodiment of the present application;
[0022] Figure 6 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application.
[0023] Icons: 120 - memory; 130 - processor; 140 - communication device; 200 - first image; 201 - identification line; 202 - binary mask; 300 - vector space; 400 - random vector unit; 500 - image adjustment unit; 601 - image acquisition module; 602 - image processing module. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0025] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0026] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0027] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0028] It should be understood that the operations of the flow chart may not be implemented in order, and steps without logical contextual relationships may be reversed in order or implemented simultaneously. In addition, those skilled in the art may add one or more other operations to the flow chart, or may remove one or more operations from the flow chart under the guidance of the content of this application.
[0029] Image optimization technology has been developed to optimize some incomplete images or images whose local areas do not meet user expectations. However, related image optimization technology is difficult to obtain diverse optimization results. As a result, it is difficult for users to choose their favorite optimized images based on personal preferences.
[0030] There are currently many image optimization technologies, such as pixel-by-pixel filling, block-by-block filling, and deep learning-based filling.
[0031] The principle of pixel-by-pixel filling is that, for the image adjustment area in the image to be optimized, all pixels in the image adjustment area are gradually filled from the boundary of the area to the center, and the image adjustment area is obtained by the weighted sum of all known pixels in its neighborhood.
[0032] The principle of block-by-block filling is to fill the image adjustment area in the image to be optimized with the image content outside the image adjustment area in the image to be optimized.
[0033] The principle of deep learning-based filling is to use a large number of sample images to train a neural network model to patch the adjustment area using the image content outside the adjustment area.
[0034] However, after the optimization algorithm or model parameters are fixed, the above-mentioned image optimization technology can only obtain the optimization result of one image for the same image to be optimized. But the reality is that there should be multiple optimization results in the image adjustment area, as long as the optimized result looks beautiful and natural.
[0035] In view of this, an embodiment of the present application provides an image processing method applied to an electronic device, which is used to obtain multiple optimization results of different styles based on the same image to be optimized.
[0036] The electronic device may be, but is not limited to, a server and a user terminal. The server may be a Web server, an FTP server, a data server, etc. The user terminal may be a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), etc.
[0037] like Figure 1 As shown, the embodiment of the present application also provides a structural schematic diagram of the electronic device. The electronic device may include a memory 120, a processor 130, and a communication device. Among them, the components are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0038] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 120 is used to store a computer program, and the processor 130 executes the computer program after receiving an execution instruction, thereby implementing the image processing method. The communication device 140 is used to send and receive data through a network or a communication bus.
[0039] The processor 130 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be 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 transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0040] Based on the hardware structure of the electronic device, a pre-trained image processing model is configured in the memory of the electronic device, wherein the image processing model includes a random vector unit and an image adjustment unit, and the random vector unit is used to generate a random vector that meets a preset probability distribution condition.
[0041] The present application also provides a flowchart of the steps of the image processing method. The following is a detailed description of each step in conjunction with the flowchart. Figure 2 As shown, the image processing method includes:
[0042] Step S101, acquiring a first image having an image adjustment area.
[0043] In order to facilitate the description of the technical solution provided by the embodiment of the present application, the image to be optimized is referred to as the first image, and the optimized image is referred to as the second image. The first image may require optimization processing due to different reasons, which is determined by the specific usage scenario.
[0044] For example, the first image may be an image whose local image area does not meet the user's expectations, wherein the local area is the above-mentioned image adjustment area. For example, in images taken when traveling, the expressions and postures of people in some images do not meet the user's aesthetic taste. For example, the smile is unnatural, the posture is stiff, the eyes are too small, etc.
[0045] At this time, the user can use the image to be optimized as the first image, and the area in the image that needs to be optimized is the image adjustment area. For example, the area that needs to be optimized may be the lip area, the eye area, etc.
[0046] Exemplarily, the first image may also be obtained by repairing the image to be repaired, wherein the image to be repaired corresponds to the original image, and the area to be repaired in the image to be repaired is the area where the original image is missing.
[0047] In the implementation of the present application, the electronic device can input the image to be repaired into a pre-trained image repair model, and repair the area to be repaired by the image repair model to obtain a first image. The image repair unit can be a preset machine learning model, for example, a GAN (Generative Adversarial Networks) model.
[0048] However, even if the image restoration model restores the image to be restored naturally, the actual image content of the missing area in the original image is unknown. Therefore, the restored first image cannot represent the actual original image. Then, in the embodiment of the present application, it is necessary to optimize the image adjustment area corresponding to the area to be restored in the first image to obtain optimization results of different styles for the user to choose.
[0049] Of course, not limited to the above examples, the first image may also be derived from other reasons that require optimization processing, and the embodiments of the present application do not make specific limitations. For example, when the first image is used as a training sample to train a machine learning model, it can be used to expand the training sample.
[0050] Step S102: inputting the random vector generated by the random vector unit and the first image into the image adjustment unit.
[0051] Step S103: The image adjustment unit uses a random vector to adjust the image adjustment area to obtain a second image.
[0052] It should be understood that after the machine learning model is trained to meet the requirements, the model parameters will remain unchanged during the use of the model. Therefore, if the data input to the machine learning model remains unchanged, the data output by the machine learning model will also remain unchanged.
[0053] In the embodiment of the present application, in order to obtain optimization results of different styles of the first image, a random vector unit is introduced into the image processing model to generate a random vector that meets a preset probability distribution condition, wherein the probability distribution condition may be a standard normal distribution.
[0054] It can be understood that the random vector unit generates a different random vector each time and inputs it together with the first image into the image adjustment unit, which will cause the data input to the image adjustment unit to change each time, thereby affecting the second image output by the image adjustment unit.
[0055] Exemplarily, it is assumed that the first image is obtained by repairing the image to be repaired, and the first image is a selfie image, and the image content displayed in the image adjustment area of the first image is a facial image.
[0056] Furthermore, it is assumed that 10 second images of different styles need to be provided for the user to choose. The electronic device inputs the first image into the image processing model 10 times, and obtains 10 second images under the action of the random vector unit. Among them, these 10 second images display facial images of different styles in the image adjustment area, so that the user can select the most satisfactory target image from the 10 second images based on personal aesthetic standards for the face.
[0057] In an embodiment of the present application, during the process of optimizing the above-mentioned 10 first images, the pre-trained image processing model optimizes and adjusts the image content of the image adjustment area according to the following strategy.
[0058] Specifically, since the first image is obtained by repairing the image to be repaired, the closer it is to the edge of the image adjustment area, the better the corresponding repair effect. Therefore, there is no need to make overly obvious diversity adjustments to the image content near the edge of the image adjustment area to avoid incoherent visual effects at the edge of the image adjustment area.
[0059] Correspondingly, the area closer to the center of the image adjustment area has a worse repair effect, and then the image content can be adjusted in a variety of ways. In general, the closer to the edge of the image adjustment area, the lower the probability of adjusting the image content, and the closer to the center of the image adjustment area, the higher the probability of adjusting the image content.
[0060] Thus, the electronic device obtains a first image having an image adjustment area; inputs the random vector generated by the random vector unit and the first image into the image adjustment unit; and uses the random vector to adjust the image adjustment area through the image adjustment unit to obtain a second image. Since the random vector unit generates a different random vector each time and inputs it into the image adjustment unit together with the first image, the data input into the image adjustment unit each time will change, and then a second image of a different style can be obtained based on the same first image.
[0061] In addition, in the embodiments of the present application, multiple methods are provided to identify the position of the image adjustment area in the first image, so that the image processing model only adjusts the image content within the image adjustment area.
[0062] In one embodiment, Figure 3 As shown, the electronic device can add a marking line 201 of a specified color as region marking information to the first image 200. The region surrounded by the marking line 201 in the first image 200 is the image adjustment region.
[0063] In another embodiment, Figure 4 As shown, the electronic device can also use the binary mask 202 as the region identification information. The binary mask 202 has the same size as the first image 200, and the pixel value of each pixel in the binary mask 202 is 1 or 0. The electronic device inputs the binary mask 202 and the first image 200 into the image processing model, wherein the region with a pixel value of 1 is the image adjustment region.
[0064] It is worth noting that the embodiment of the present application does not specifically limit the number of image adjustment regions in the first image 200. It can be understood that the number of image adjustment regions in the first image 200 can be one or more.
[0065] like Figure 5 As shown, the embodiment of the present application also provides a schematic diagram of the structure of a random vector unit 400. The random vector unit 400 includes a sampling layer and a vector conversion layer. The electronic device performs random sampling through the sampling layer to generate a sampling vector; and processes the sampling vector through the vector conversion layer to obtain a random vector.
[0066] It should be understood that, considering the lack of stability of the sampling vectors collected by the sampling layer, a vector conversion layer is introduced to further map the sampling vectors so that the random vectors finally obtained are more robust. The vector conversion layer may be a fully connected layer (Fully CeLayers, FC).
[0067] Exemplarily, assuming that the random vector generated by the random vector unit 400 satisfies the standard normal distribution, the electronic device performs random sampling from the vector space 300 through the sampling layer, wherein the distribution of the vectors in the vector space 300 satisfies the standard normal distribution; then, the sampling vector obtained by sampling is processed through the vector conversion layer to obtain the above-mentioned random vector.
[0068] Please see again Figure 5 The present application embodiment also provides a structural diagram of an image adjustment unit 500. The image adjustment unit 500 includes an image input layer and at least one image adjustment layer connected in sequence. Figure 5 As shown, the input data of the image input layer are the random vector generated by the random vector unit 400 and the first image; the input data of each image adjustment layer are the output data of the previous layer and the first image, and the last image adjustment layer outputs the second image.
[0069] Since the input data of each image adjustment layer includes the first image, each image adjustment layer can optimize and adjust the image adjustment region in the first image, thereby obtaining a better adjustment effect.
[0070] Exemplarily, the above-mentioned image adjustment layer and image input layer can be batch normalization residual network layers.
[0071] The present application also provides a corresponding training method for training the image processing model to be trained, and finally obtains the above-mentioned pre-trained image processing model. The specific training process is as follows:
[0072] The electronic device acquires a sample image; inputs the sample image into an image processing model to be trained; and then iteratively adjusts the model parameters of the image processing model to be trained to obtain a pre-trained image processing model.
[0073] The image processing model to be trained includes a random vector unit to be trained and an image adjustment unit to be trained, and adjusting the model parameters of the image processing model to be trained includes:
[0074] The electronic device inputs the first vector generated by the random vector unit to be trained and the sample image to the image adjustment unit to be trained.
[0075] Specifically, in order to facilitate the description of the technical solution provided by the embodiment of the present application, the random vector generated by the random vector unit during training is referred to as the first vector, and the random vector generated last time is referred to as the second vector. Thus, the random vectors generated by the random vector unit during model application are distinguished.
[0076] It can be understood that, assuming that the model parameters of the random vector unit to be trained and the image adjustment unit to be trained are adjusted for the nth time, the random vector generated by the random vector unit for the nth time is called the first vector, and the random vector generated for the n-1th time is the second vector.
[0077] Furthermore, the image generated by the image adjustment unit during training is referred to as an adjustment image, which is used to distinguish the second image generated by the image adjustment unit in the model application interval.
[0078] Then, the electronic device obtains a model loss value according to the vector difference and the adjusted image generated by the image adjustment unit to be trained, wherein the vector difference is the difference between the first vector and the second vector.
[0079] Specifically, in order to ensure that the image content of the second image generated by the pre-trained image processing model each time has a large difference in the image adjustment area, a vector difference is introduced into the model loss value.
[0080] Exemplarily, the vector difference may be the average value of the difference between the elements in the same sequence position between the first vector and the second vector. Assuming that the first vector is [0.1, 0.2, 0.3]; the second vector is [0.2, 0.4, 0.9]; then the vector difference is ((0.2-0.1)+(0.4-0.2)+(0.9-0.3)) / 3=0.3.
[0081] Exemplarily, the vector difference may also be the spatial distance between the first vector and the second vector. Assume that the first vector is [0.1, 0.2, 0.3]; the second vector is [0.2, 0.4, 0.9]; then the vector difference is
[0082] In addition, the electronic device also calculates the image difference between the adjusted image and the corresponding reference image through the L1 loss function, wherein the image difference is used to measure the difference between the adjusted image and the reference image.
[0083] Then, the electronic device combines the vector difference and the image difference to obtain a model loss value. Exemplarily, the electronic device may perform a weighted summation of the vector difference and the image difference based on a preset weight, and use the summation result as the model loss value. The weight of the vector difference may be 0.3, and the weight of the image difference may be 0.7.
[0084] Finally, the electronic device adjusts the model parameters of the random vector unit to be trained and the image adjustment unit to be trained according to the model loss value.
[0085] The electronic device goes through multiple rounds of iterations through the above steps until a preset convergence condition is met. The convergence condition may be, but is not limited to, stopping iteration when the model loss value no longer decreases; stopping iteration when the number of iterations reaches a set number of times, or stopping iteration when the model loss value is lower than a set threshold.
[0086] In this way, the pre-trained image processing model can generate different random vectors through the vector unit for the same first image to obtain a second image of different styles.
[0087] Based on the same inventive concept as the image processing method, the embodiment of the present application also provides an image processing device applied to an electronic device. The electronic device is configured with a pre-trained image processing model, wherein the image processing model includes a random vector unit and an image adjustment unit, and the random vector unit is used to generate a random vector that meets a preset probability distribution condition. Figure 6 As shown, from the functional point of view, the image processing device may include:
[0088] The image acquisition module 601 is used to acquire a first image having an image adjustment area, wherein the first image is obtained by repairing the image to be repaired.
[0089] In the embodiment of the present application, the image acquisition module 601 is used to implement Figure 2 For a detailed description of the image acquisition module 601, please refer to the detailed description of step S101.
[0090] The image processing module 602 is used to input the random vector generated by the random vector unit and the first image into the image adjustment unit.
[0091] The image processing module 602 is further configured to adjust the image adjustment area using a random vector through an image adjustment unit to obtain a second image.
[0092] In the embodiment of the present application, the image processing module 602 is used to implement Figure 2 For the detailed description of the image processing module 602, please refer to the detailed description of steps S102-S103.
[0093] Optionally, the random vector unit includes a sampling layer and a vector conversion layer. Before the random vector generated by the random vector unit and the first image are input to the image adjustment unit, the image processing module 602 is used to:
[0094] Perform random sampling through the sampling layer to generate a sampling vector;
[0095] The sampled vector is processed through the vector conversion layer to obtain a random vector.
[0096] Optionally, the image acquisition module 601 is used to:
[0097] Acquire an image to be repaired, wherein the image to be repaired has a region to be repaired corresponding to the image adjustment region;
[0098] Input the image to be repaired into the pre-trained image repair unit;
[0099] The image restoration unit is used to restore the area to be restored, so as to obtain a first image.
[0100] It is worth noting that the image processing device may also include other functional modules for implementing other steps or sub-steps of the above-mentioned image processing method. In addition, the image acquisition module 601 and the graphic processing module may also be used to implement other steps or sub-steps of the image processing method. The embodiments of the present application do not specifically limit this.
[0101] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, an image processing method is implemented.
[0102] In summary, in the image processing method, apparatus, device and medium provided by the present application, the electronic device obtains a first image having an image adjustment area; inputs the random vector generated by the random vector unit and the first image into the image adjustment unit; and the image adjustment unit uses the random vector to adjust the image adjustment area to obtain a second image. Since the random vector unit generates a different random vector each time and inputs it into the image adjustment unit together with the first image, the data input into the image adjustment unit each time will change, and then a second image of a different style can be obtained based on the same first image.
[0103] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0104] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0105] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0106] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0107] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An image processing method, characterized in that: Applied to an electronic device, the electronic device is configured with a pre-trained image processing model, the image processing model includes a random vector unit and an image adjustment unit, the random vector unit is used to generate a random vector that meets a preset probability distribution condition, the method includes: Acquire an image to be repaired, wherein the image to be repaired has a region to be repaired; Inputting the image to be repaired into a pre-trained image repair model; Repairing the area to be repaired by using the image repair model to obtain a first image, wherein the first image has an image adjustment area corresponding to the area to be repaired; inputting the random vector generated by the random vector unit and the first image into the image adjustment unit; The image adjustment unit uses the random vector to adjust the image adjustment area to obtain a second image.
2. The image processing method according to claim 1, characterized in that: The random vector unit includes a sampling layer and a vector conversion layer. Before the random vector generated by the random vector unit and the first image are input into the image adjustment unit, the method further includes: Perform random sampling through the sampling layer to generate a sampling vector; The sampling vector is processed by the vector conversion layer to obtain the random vector.
3. The image processing method according to claim 1, characterized in that: The image adjustment unit comprises an image input layer and at least one image adjustment layer connected in sequence; The input data of the image input layer are the random vector generated by the random vector unit and the first image; The input data of each image adjustment layer is the output data of the previous layer and the first image, and the last image adjustment layer outputs the second image.
4. The image processing method according to claim 1, characterized in that: The method further comprises: Get a sample image; Inputting the sample image into the image processing model to be trained; Iteratively adjusting the model parameters of the image processing model to be trained to obtain the pre-trained image processing model, wherein the image processing model to be trained includes a random vector unit to be trained and an image adjustment unit to be trained, and adjusting the model parameters of the image processing model to be trained includes: Inputting the first vector generated by the random vector unit to be trained and the sample image into the image adjustment unit to be trained; Obtaining a model loss value according to a vector difference and an adjusted image generated by the image adjustment unit to be trained, wherein the vector difference is a difference between the first vector and the second vector, and the second vector is a random vector generated last time by the random vector unit to be trained; The model parameters of the random vector unit to be trained and the image adjustment unit to be trained are adjusted according to the model loss value.
5. An image processing device, characterized in that: Applied to an electronic device, the electronic device is configured with a pre-trained image processing model, the image processing model includes a random vector unit and an image adjustment unit, the random vector unit is used to generate a random vector that meets a preset probability distribution condition, and the image processing device includes: An image acquisition module, used for acquiring an image to be repaired, wherein the image to be repaired has an area to be repaired; Inputting the image to be repaired into a pre-trained image repair model; Repairing the area to be repaired by using the image repair model to obtain a first image, wherein the first image has an image adjustment area corresponding to the area to be repaired; An image processing module, used for inputting the random vector generated by the random vector unit and the first image into the image adjustment unit; The image processing module is further configured to adjust the image adjustment area using the random vector through the image adjustment unit to obtain a second image.
6. The image processing device according to claim 5, characterized in that: The random vector unit includes a sampling layer and a vector conversion layer. Before the random vector generated by the random vector unit and the first image are input into the image adjustment unit, the image processing module is used to: Perform random sampling through the sampling layer to generate a sampling vector; The sampling vector is processed by the vector conversion layer to obtain the random vector.
7. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the image processing method according to any one of claims 1 to 4 is implemented.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the image processing method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Face conversion model training method and device, equipment and medium
CN111860041A