Image processing method, device, equipment and medium
By performing thin plate spline transformation and appearance flow deformation on the image of the clothes to be tried on, the pixel extrusion problem caused by occlusion in 2D virtual fitting technology is solved, and the generated fitting image is better.
Patent Information
- Application Number
- CN202210236228.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-11
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-03-11
AI Technical Summary
When the existing 2D virtual fitting technology handles human body occlusion, the pixels of the clothes image are squeezed, and the generated fitting image has poor effect.
By extracting key point images, background area images and occlusion images in the image to be processed, thin plate spline transformation and appearance flow deformation are performed to generate anti-occlusion deformed clothes images to avoid pixel extrusion.
The quality of fitting images has been improved to ensure that pixels will not be squeezed in occluded areas, improving the fitting effect.
Smart Images

Figure CN114638665B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and more particularly to an image processing method, device, equipment and medium. Background Art
[0002] With the development of online e-commerce platforms, virtual fitting technology that simulates putting the clothes selected by users on people can enhance the user's shopping experience. Since 3D virtual fitting solutions require a lot of computing resources, 2D virtual fitting solutions are the mainstream research direction in this field.
[0003] At present, various 2D virtual fitting solutions include a deformation (warp) module and a try-on (Try-on) module. Among them, the warp module is mainly used to deform the clothing image in the image to a shape consistent with the posture and shape of the human body in the image, and the try-on module is mainly used to wear the clothing image deformed by the warp module on the person in the image to generate a fitting image. The warp module can learn the point-to-point mapping relationship between the pixel points in the image of the clothing to be tried on and the area of the human body to be tried on through the appearance-flow-based warp method, and output a pixel coordinate map composed of two-dimensional coordinate vectors to represent the above mapping relationship. According to the pixel coordinate map, the clothing can be accurately deformed into a state consistent with the posture and shape of the human body.
[0004] However, in actual application, there may be occlusions in the area of the human body to be tried on in the image before virtual trying on. For example, the person in the image will cross his arms across his chest. When the Try-on module puts the deformed clothes on the person in the image, there will be pixel squeezing in the arm area of the generated trying-on image, that is, the pixels on the arm are squeezed with the pixels on the deformed clothes, resulting in poor trying-on effect. In other words, when there are occluders in the fitting area in the image, the generated fitting image will have the problem of pixel squeezing in the occluded area, resulting in poor trying-on effect. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide an image processing method, device, equipment and medium to achieve that the deformed clothes in the generated fitting image are consistent with the posture and shape of the human body, and there will be no pixel squeezing in the human body clothing area where there is occlusion. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides an image processing method, the method comprising:
[0007] Obtaining images to be processed and images of clothes to be tried on;
[0008] Extracting a first key point image, a second key point image and a background area image from the image to be processed; the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and an image of an obstruction on the area to be tried on;
[0009] Based on the first key point image, the second key point image and the background area image, the image of the clothes to be tried on is deformed by a thin plate spline transformation (TPS) to obtain a deformed clothes image and a spatial transformation parameter, wherein the spatial transformation parameter is used to represent a spatial transformation relationship between the image of the clothes to be tried on and the deformed clothes image;
[0010] Based on the deformed clothing image and the spatial transformation parameters, an area on the clothing image to be tried on that has a spatial transformation relationship with an occlusion on the clothing area to be tried on is erased to obtain an anti-occlusion clothing image to be tried on;
[0011] Based on the first key point image, the second key point image and the background area image, the anti-occlusion image of the clothes to be tried on is deformed by an appearance flow deformation module AFWM model to obtain an anti-occlusion deformed clothes image.
[0012] In a possible implementation, based on the deformed clothing image and the spatial transformation parameter, erasing a region on the image of the clothing to be tried on that has a spatial mapping relationship with an occlusion on the area of the clothing to be tried on, to obtain an anti-occlusion image of the clothing to be tried on, includes:
[0013] Extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed;
[0014] The first image block is reversely transformed into an image of clothes to be tried on based on the spatial transformation parameters, and the area that blocks the clothes to be tried on after the reverse transformation is erased to obtain an anti-occlusion image of clothes to be tried on.
[0015] In a possible implementation, extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed includes:
[0016] Performing human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed;
[0017] The deformed clothing image is simulated and covered on the to-be-trimmed clothing area of the human body semantic segmentation result image, and the first image block that coincides with the position and shape of the occlusion image in the human body semantic segmentation result image is extracted from the deformed clothing image.
[0018] In a possible implementation, deforming the anti-occlusion image of clothing to be tried on by using an AFWM model based on the first key point image, the second key point image, and the background area image to obtain an anti-occlusion deformed clothing image includes:
[0019] Inputting the first key point image, the second key point image, the background area image and the anti-occlusion image of clothes to be tried on into the AFWM model to obtain a pixel mapping relationship set, wherein the pixel mapping relationship set includes a mapping relationship between each pixel on the anti-occlusion image of clothes to be tried on and each pixel in the area to be tried on in the image to be processed;
[0020] According to the pixel mapping relationship set, each pixel point of the anti-occlusion to-be-tried clothes image is filled into the to-be-tried clothes area in the corresponding to-be-processed image to generate an anti-occlusion deformed clothes image.
[0021] In a possible implementation, the AFWM model is trained by the following steps:
[0022] Obtain sample fitting images and anti-occlusion sample clothing images;
[0023] Inputting the first key point image, the second key point image, the background area image and the anti-occlusion sample clothing image of the sample fitting image into the AFWM model to obtain an anti-occlusion deformed sample clothing image;
[0024] A loss function is calculated based on the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, and the AFWM model parameters are adjusted based on the loss function value until the AFWM model converges, and it is determined that the AFWM model training is completed.
[0025] In a second aspect, an embodiment of the present application provides an image processing device, the device comprising:
[0026] An acquisition module, used for acquiring images to be processed and images of clothes to be tried on;
[0027] An extraction module, used to extract a first key point image, a second key point image and a background area image from the image to be processed; the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and an image of an obstruction on the area to be tried on;
[0028] a first deformation module, configured to perform a thin plate spline transformation (TPS) deformation on the image of the clothing to be tried on based on the first key point image, the second key point image and the background area image, to obtain a deformed clothing image and a spatial transformation parameter, wherein the spatial transformation parameter is used to represent a spatial transformation relationship between the image of the clothing to be tried on and the deformed clothing image;
[0029] an erasing module, configured to erase the region on the image of the clothes to be tried on that has a spatial transformation relationship with the occluder on the area to be tried on, based on the deformed clothes image and the spatial transformation parameter, so as to obtain an anti-occlusion image of the clothes to be tried on;
[0030] The second deformation module is used to deform the anti-occlusion image of the clothes to be tried on through an appearance flow deformation module AFWM model based on the first key point image, the second key point image and the background area image to obtain an anti-occlusion deformed clothes image.
[0031] In a possible implementation, the erasing module is specifically used to:
[0032] Extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed;
[0033] The first image block is reversely transformed into an image of clothes to be tried on based on the spatial transformation parameters, and the area that blocks the clothes to be tried on after the reverse transformation is erased to obtain an anti-occlusion image of clothes to be tried on.
[0034] In a possible implementation, the erasing module is specifically used to:
[0035] Performing human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed;
[0036] The deformed clothing image is simulated and covered on the to-be-trimmed clothing area of the human body semantic segmentation result image, and the first image block that coincides with the position and shape of the occlusion image in the human body semantic segmentation result image is extracted from the deformed clothing image.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0038] Memory, used to store computer programs;
[0039] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.
[0040] 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 computer program implements any of the above-mentioned image processing methods.
[0041] In a fifth aspect, an embodiment of the present application further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described image processing methods.
[0042] Through the above technical scheme, the TPS deformation is first performed on the image of clothes to be tried on to obtain the deformed clothes image and the spatial transformation parameters, and then the area on the deformed clothes image that has the spatial transformation relationship with the occlusion in the image to be processed is erased according to the obtained spatial transformation parameters to obtain the anti-occlusion image of clothes to be tried on, and then the AFWM model is used to deform the anti-occlusion image of clothes to be tried on to obtain the anti-occlusion deformed clothes image. Since the anti-occlusion image of clothes to be tried on does not include the area overlapping with the occlusion area, the obtained anti-occlusion deformed clothes image does not include the area overlapping with the occlusion area. Furthermore, when the try-on module uses the anti-occlusion deformed clothes image to synthesize the try-on image, there will be no pixel squeezing in the occlusion area, thereby improving the trying-on effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0044] Figure 1 A flowchart of an image processing method provided in an embodiment of the present application;
[0045] Figure 2 An exemplary schematic diagram of an image of clothing to be tried on provided in an embodiment of the present application;
[0046] Figure 3a An exemplary schematic diagram of a first key point image provided in an embodiment of the present application;
[0047] Figure 3b An exemplary schematic diagram of a second key point image provided in an embodiment of the present application;
[0048] Figure 4 An exemplary schematic diagram of a background area image provided in an embodiment of the present application;
[0049] Figure 5 An exemplary schematic diagram of a deformed clothing image provided by an embodiment of the present application;
[0050] Figure 6 A flowchart of another image processing method provided in an embodiment of the present application;
[0051] Figure 7 An exemplary schematic diagram of a human body segmentation result map provided in an embodiment of the present application;
[0052] Figure 8 An exemplary schematic diagram of a first image block provided in an embodiment of the present application;
[0053] Fig. 9 An exemplary schematic diagram of an anti-occlusion image of clothing to be tried on provided in an embodiment of the present application;
[0054] Fig.10 A flowchart of another image processing method provided in an embodiment of the present application;
[0055] Fig.11 A flowchart of a model training method provided in an embodiment of the present application;
[0056] Fig.12 An exemplary schematic diagram of an image processing method flow provided in an embodiment of the present application;
[0057] Fig.13 A schematic diagram of the structure of an image processing device provided in an embodiment of the present application;
[0058] Fig.14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0060] The present application embodiment provides an image processing method, which can be applied to electronic devices, such as smart phones, tablet computers, desktop computers, servers, etc. Figure 1 As shown, the method includes:
[0061] S101, obtaining an image to be processed and an image of clothes to be tried on.
[0062] S102: extracting a first key point image, a second key point image and a background area image from the image to be processed.
[0063] Among them, the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and the occlusion image on the area to be tried on.
[0064] S103, performing Thin Plate Spline (TPS) deformation on the image of the clothing to be tried on based on the first key point image, the second key point image and the background area image to obtain a deformed clothing image and space transformation parameters.
[0065] The spatial transformation parameter is used to represent the spatial transformation relationship between the image of the clothes to be tried on and the deformed clothes image.
[0066] S104: based on the deformed clothing image and the spatial transformation parameters, the region on the clothing image to be tried on that has a spatial transformation relationship with the occluding object on the clothing area to be tried on is erased to obtain an anti-occlusion clothing image to be tried on.
[0067] S105 , deforming the occlusion-resistant image of the clothes to be tried on through an appearance flow warping module (AFWM) model based on the first key point image, the second key point image and the background area image to obtain an occlusion-resistant deformed clothes image.
[0068] According to the embodiment of the present application, the image of the clothes to be tried on is first subjected to TPS deformation to obtain a deformed clothes image and a spatial transformation parameter, and then, according to the obtained spatial transformation parameter, the area on the deformed clothes image that has a spatial transformation relationship with the occlusion in the image to be processed is erased to obtain an anti-occlusion image of the clothes to be tried on, and then the AFWM model is used to deform the anti-occlusion image of the clothes to be tried on to obtain an anti-occlusion deformed clothes image. Since the anti-occlusion image of the clothes to be tried on does not include an area overlapping with the occlusion area, the obtained anti-occlusion deformed clothes image also does not include an area overlapping with the occlusion area. Furthermore, when the try-on module uses the anti-occlusion deformed clothes image to synthesize the try-on image, there will be no pixel squeezing in the occlusion area, thereby improving the trying-on effect.
[0069] With respect to the above S101, the image to be processed is an image of a person who needs to try on clothes uploaded by a user, or may be a video frame in a video of a person who needs to try on clothes uploaded by a user.
[0070] The image of clothes to be tried on is an image of clothes selected by the user to be tried on in a flat state, such as Figure 2 As shown, Figure 2 exemplarily shows an image of clothing to be tried on.
[0071] With respect to the above S102, in one implementation, a human pose recognition algorithm can be used to perform human pose recognition on a human figure in the processed image to obtain a first key point image and a second key point image. The first key point image is a pose image containing human key points, and the second key point image is a densepose image containing shapes of various parts of the human body. The first key point image can be obtained by an Openpose algorithm, such as Figure 3a As shown, Figure 3a is an exemplary schematic diagram of the first key point image, and the second key point image can be obtained by the Densepose algorithm, such as Figure 3b As shown, Figure 3b is an exemplary schematic diagram of the second key point image; wherein the Openpose algorithm is a human posture recognition algorithm used to identify the key points of each joint of the human body in the image, and the Densepose algorithm is a human posture recognition algorithm that converts a 2D human body image into a 3D human body image.
[0072] The background area image is obtained by processing the to-be-fitted area of the portrait in the to-be-processed image to have the same pixel value, such as Figure 4 As shown, Figure 4 The upper garment area of the portrait included in the background image is processed as the same pixel value, that is, the background area image includes the background excluding the portrait area, the part of the portrait area excluding the upper garment area, and the occluder in the upper garment area. Figure 4 The covering in the middle and upper area is the backpack strap.
[0073] For the above S103, the TPS transformation can be performed on the clothes to be tried on through a Thin Plate Spline (TPS) model. The network structure of the model is a Geometric Matching Module (GMM) neural network structure. The model includes two feature extraction layers, a feature matching layer and a spatial transformation parameter estimation layer. The feature extraction layer is an encoder, and the spatial transformation parameter estimation layer is a regression network.
[0074] The first key point image, the second key point image and the background area image are input into a feature extraction layer, the image of the clothes to be tried on is input into another feature extraction layer, the output features of the two feature extraction layers are input into the feature matching layer, the matching features output by the feature matching layer are obtained, the matching features are input into the spatial transformation parameter estimation layer, the spatial transformation parameters are obtained, and the image of the clothes to be tried on is deformed (warped) according to the spatial transformation parameters to obtain a deformed clothes image. Figure 5 As shown, Figure 5 This is an exemplary deformed clothing image obtained by TPS model transformation.
[0075] With respect to the above S104, the deformed clothing image is obtained by deforming the clothing image to be tried on according to the area to be tried on. Therefore, there is an area on the clothing image to be tried on that has a spatial transformation relationship with the occlusion on the area to be tried on. By erasing the pixels in this area, an anti-occlusion clothing image to be tried on can be obtained.
[0076] With respect to the above S105, the AFWM model is a neural network model implemented by AFWM, and the AFWM model is used to predict the dense flow mapping between the anti-occluded image of the clothes to be tried on and the portrait image in the image to be processed, so as to deform the clothes, and the module outputs a set of two-dimensional coordinate vectors. Each vector represents the position of a pixel point in the anti-occluded image of the clothes to be tried on, and the pixel points on the anti-occluded image of the clothes to be tried on are mapped to the points of the area to be tried on according to the two-dimensional coordinate vector set, so that the anti-occluded deformed clothes image can be obtained.
[0077] The anti-occlusion deformed clothing image is input into the fitting module to obtain the fitting image.
[0078] The try-on module can be a try-on module in a try-on solution such as CP-VTON, Parser Free Appearance Flow Network (PF-AFN), Adaptive Content Generation and Preserving Network (ACGPN), VITON-HD, etc., wherein CP-VTON is a feature-preserving virtual try-on network (CP-VTON) proposed at the European International Conference on Computer Vision, and VITON-HD is an image-based virtual try-on network. The embodiment of the present application does not make specific limitations on this; the try-on image is an image of a person in the image to be processed generated by the try-on module wearing clothes in the image of clothes to be tried on.
[0079] In another embodiment of the present application, the image of the clothes to be tried on can be reversely mapped according to the spatial transformation parameters, so as to obtain an anti-occlusion image of the clothes to be tried on. Figure 6 As shown, the above S104 can be specifically implemented as follows:
[0080] S1041. Extract a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed.
[0081] S1041 can be specifically implemented as follows:
[0082] Perform human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed, simulate and cover the deformed clothing image on the to-be-trimmed clothing area of the human body semantic segmentation result image, and extract the first image block that coincides with the position and shape of the occlusion image in the human body semantic segmentation result image from the deformed clothing image.
[0083] In one implementation, a human parsing algorithm can be used to perform human semantic segmentation on the person in the image to be processed, and a human semantic segmentation result image can be obtained, such as Figure 7 As shown, Figure 7 is a human body semantic segmentation result image including the image block where the occluder is located. The area where the deformed clothing image overlaps with the occluder area in the human body segmentation image can be extracted from the deformed clothing image to obtain the first image block, such as Figure 8 As shown, Figure 8 is a schematic diagram of a first image block.
[0084] S1042: Inversely transform the first image block into the image of the clothes to be tried on based on the spatial transformation parameters, and erase the area that occludes the clothes to be tried on after the inverse transformation to obtain an anti-occlusion image of the clothes to be tried on.
[0085] like Fig. 9 As shown, Fig. 9 is an exemplary anti-occlusion image of clothing to be tried on, Fig. 9 The black part of the clothing area is the area reversely mapped by the first image block and the spatial transformation parameter. By erasing the pixels in this area, an anti-occlusion image of the clothing to be tried on can be obtained.
[0086] By adopting the embodiment of the present application, human body semantic segmentation is performed on the processed image to obtain a human body semantic segmentation result map, and then, according to the area where the deformed clothing image and the occluder area in the human body semantic segmentation result map overlap, a first image block map consistent with the shape and position of the occluder can be determined on the deformed clothing image, and the image of the clothes to be tried on is reversely mapped according to the spatial transformation parameters and the first image block, which is equivalent to erasing the area on the image of the clothes to be tried on according to the shape and position of the occluder, so as to obtain an anti-occlusion image of the clothes to be tried on, so that the anti-occlusion deformed clothing image obtained by deforming the anti-occlusion clothing image with the tried-on clothes will not overlap in the area where the occluder is located. When the fitting image is synthesized using the anti-occlusion deformed clothing image, there will be no problem of pixel squeezing in the occluder area, thereby improving the fitting effect.
[0087] In another embodiment of the present application, Fig.10 As shown, the above S105 can be implemented as follows:
[0088] S1051. Input the first key point image, the second key point image, the background area image and the anti-occlusion image of the clothes to be tried on into the AFWM model to obtain a pixel mapping relationship set.
[0089] The pixel mapping relationship set includes a mapping relationship between each pixel on the anti-occlusion image of the clothes to be tried on and each pixel in the area to be tried on in the image to be processed.
[0090] The pixel point mapping set can also be called a two-dimensional graph of size H*W, that is, a two-dimensional graph with a height and width of H and W respectively. There are a total of H*W points in the two-dimensional graph, each point has a two-dimensional coordinate, and each two-dimensional coordinate represents the position of a pixel point on the anti-occlusion clothing to be tried on.
[0091] S1052: fill each pixel point on the anti-occlusion image of the clothes to be tried on into the clothes to be tried on region in the image to be processed according to the pixel mapping relationship set, so as to generate an anti-occlusion deformed clothes image.
[0092] For example, the height and width of the two-dimensional image are 6 and 3 respectively, then there are a total of 6*3=18 points on the two-dimensional image. Assuming that one of the points is point a, and the two-dimensional coordinates of point a are (m, n), then when generating anti-occlusion deformed clothes, it is necessary to fill the pixel point with the coordinate position (m, n) on the anti-occlusion image of the clothes to be tried on into point a in the two-dimensional image.
[0093] In an embodiment of the present application, since the pixel points of the area on the anti-occlusion image of the clothes to be tried on that has a spatial conversion relationship with the occlusion area in the image to be processed have been erased in advance, the pixel mapping relationship set does not include the pixel mapping relationship of the occlusion area. Therefore, based on the pixel mapping relationship set, an anti-occlusion deformed clothing image that does not include the area overlapping with the occlusion area can be generated.
[0094] By adopting the embodiment of the present application, the first key point image, the second key point image, and the background area image are input into the AFWM model to deform the image of clothes to be tried on that is resistant to occlusion. Since the area in the image of clothes to be tried on that corresponds to the occlusion in the image to be processed has been erased, the pixel mapping relationship set output by the AFWM model does not include the pixel mapping relationship of the occlusion area. Therefore, the deformed clothing image that is resistant to occlusion can be obtained according to the pixel mapping relationship set and pixel filling. Furthermore, when the try-on module uses the deformed clothing image that is resistant to occlusion to synthesize the fitting image, there will be no problem of pixel squeezing in the occlusion area, thereby improving the fitting effect.
[0095] In another embodiment of the present application, the AFWM model in the above embodiment is obtained by pre-training, such as Fig.11 As shown, the AFWM model is trained through the following steps:
[0096] S1101. Obtain sample fitting images and anti-occlusion sample clothing images.
[0097] Among them, the sample fitting image is an image obtained by using an electronic device to capture a person wearing sample clothes, and the anti-occlusion sample clothes image is a clothes image obtained by removing the areas corresponding to the occlusions in the sample fitting image from the sample clothes image. The method and steps for obtaining the anti-occlusion clothes image are the same as the method for obtaining the anti-occlusion clothes image to be tried on in the above S101-S104. Please refer to the relevant description in the above S101-S104, which will not be repeated here.
[0098] S1102, inputting the first key point image, the second key point image, the background area image and the anti-occlusion sample clothing image of the sample fitting image into the AFWM model to obtain an anti-occlusion deformed sample clothing image.
[0099] Among them, the first key point image and the second key point image of the sample fitting image are both used to represent the posture of the person in the sample fitting image, and the background area image includes the background area outside the area to be fitted in the sample fitting image, and the occlusion image on the area to be fitted.
[0100] The method of obtaining the first key point image, the second key point image, and the background area image of the sample fitting image is the same as that of the above S102, and the method of extracting the first key point image, the second key point image, and the background area image of the image to be processed is consistent. Please refer to the relevant description in the above S102, and no further details will be given here.
[0101] S1103, calculating a loss function based on the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, adjusting the AFWM model parameters based on the loss function value, and determining that the AFWM model training is completed when the AFWM model converges.
[0102] In an embodiment of the present application, the loss function can be calculated by calculating the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, and whether the AFWM model has converged is determined based on the calculated loss function value. If the AFWM model has not converged, the parameters of the AFWM model are adjusted according to the loss function value, and the process returns to execute S1101, and the next sample fitting image and anti-occlusion sample clothing image are obtained. S1102-S1103 are repeatedly executed until the AFWM model converges, and it is determined that the AFWM model training is completed.
[0103] By using the embodiment of the present application, the loss function value of the AFWM model is calculated by the difference between the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, and the parameters of the AFWM model are adjusted according to the loss function value, so that the trained AFWM model can perform more accurate deformation on the anti-occlusion clothing image to obtain the anti-occlusion deformed clothing image. Furthermore, when the fitting module uses the anti-occlusion deformed clothing image generated by the AFWM model to synthesize the fitting image, there will be no pixel squeezing in the occluded area of the synthesized fitting image, thereby improving the fitting effect.
[0104] like Fig.12 As shown, an exemplary schematic diagram of the image processing method provided in the embodiment of the present application is shown below in conjunction with Fig.12 Provide explanation.
[0105] The first key point image P, the second key point image D and the background area image A of the image to be processed are input into an encoder, and the image C of the clothes to be tried on is input into another encoder to obtain the features of the image to be processed and the features of the image of the clothes to be tried on, respectively.
[0106] The features of the image to be processed and the features of the image of the clothes to be tried on are fused to obtain fused features.
[0107] The fused features are input into the regression network to obtain the spatial transformation parameter θ.
[0108] The image C of the clothes to be tried on is deformed (warped) using the spatial transformation parameter θ to obtain the deformed clothes image W(C,θ).
[0109] Figure I: Human body segmentation result of the image to be processed extracted from the deformed clothing image W(C,θ) oc The part of the image that overlaps with the occluder area is obtained as the first image block M o .
[0110] According to the spatial transformation parameter θ and the first image block M o Reverse Mapping is performed on the image C of the clothes to be tried on to obtain an anti-occlusion image of the clothes to be tried on .
[0111] The anti-occlusion image of the clothes to be tried , the first key point image P, the second key point image D and the background area image A are input into the AFWM model to obtain a pixel mapping relationship set f.
[0112] According to the pixel mapping relationship set f, the anti-occlusion clothes to be tried on are The pixel points on the image are filled into the area to be tried on in the image to be processed to obtain an anti-occlusion deformed clothing image.
[0113] By adopting the embodiment of the present application, the image of the clothes to be tried on is first deformed based on the TPS model, and then the AWFM model is used to deform the clothes to be tried on that are resistant to occlusion. This is equivalent to designing a two-stage accurate deformation scheme against occlusion. The scheme combines the advantages of the two deformation models: the TPS model can deform the clothes to be tried on in the occluded area, and the AWFM model can deform the clothes to be tried on more accurately, thereby realizing accurate deformation of the image of the clothes to be tried on when there is an occluded area in the clothes area. Furthermore, in the finally generated trying-on image, there will be no pixel squeezing in the occluded area, thereby improving the trying-on effect.
[0114] Corresponding to the above method embodiment, the present application embodiment also provides an image processing device, such as Fig.13 As shown, the device comprises:
[0115] An acquisition module 1301 is used to acquire an image to be processed and an image of clothes to be tried on;
[0116] Extraction module 1302, used to extract a first key point image, a second key point image and a background area image from the image to be processed; the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and the occlusion image on the area to be tried on;
[0117] A first deformation module 1303 is used to perform a thin plate spline transformation TPS deformation on the image of the clothes to be tried on based on the first key point image, the second key point image and the background area image to obtain a deformed clothes image and a spatial transformation parameter, wherein the spatial transformation parameter is used to represent a spatial transformation relationship between the image of the clothes to be tried on and the deformed clothes image;
[0118] The erasing module 1304 is used to erase the area on the image of the clothes to be tried on that has a spatial transformation relationship with the occluder on the area to be tried on based on the deformed clothes image and the spatial transformation parameters, so as to obtain an anti-occlusion image of the clothes to be tried on;
[0119] The second deformation module 1305 is used to deform the anti-occlusion clothing image to be tried on through the appearance flow deformation module AFWM model based on the first key point image, the second key point image and the background area image to obtain the anti-occlusion deformed clothing image.
[0120] In another embodiment of the present application, the erasing module 1304 is specifically used for:
[0121] Extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed;
[0122] The first image block is reversely transformed into the image of the clothes to be tried on based on the spatial transformation parameters, and the area that blocks the clothes to be tried on after the reverse transformation is erased to obtain an anti-occlusion image of the clothes to be tried on.
[0123] In another embodiment of the present application, the erasing module 1304 is specifically used for:
[0124] Performing human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed;
[0125] The deformed clothing image is simulated and covered on the to-be-trimmed clothing area of the human body semantic segmentation result image, and the first image block whose position and shape coincide with the occlusion image in the human body semantic segmentation result image is extracted from the deformed clothing image.
[0126] In another embodiment of the present application, the second deformation module 1305 is specifically used for:
[0127] Inputting the first key point image, the second key point image, the background area image and the anti-occlusion image of the clothes to be tried on into the AFWM model, obtaining a pixel mapping relationship set, wherein the pixel mapping relationship set includes a mapping relationship between each pixel on the anti-occlusion image of the clothes to be tried on and each pixel in the area to be tried on in the image to be processed;
[0128] According to the pixel mapping relationship set, each pixel point of the anti-occlusion to-be-tried clothes image is filled into the to-be-tried clothes area in the corresponding to-be-processed image to generate an anti-occlusion deformed clothes image.
[0129] In another embodiment of the present application, the device further includes an AFWM model training module, and the AFWM model training module is used to:
[0130] Obtain sample fitting images and anti-occlusion sample clothing images;
[0131] The first key point image, the second key point image, the background area image and the anti-occlusion sample clothing image of the sample fitting image are input into the AFWM model to obtain the anti-occlusion deformed sample clothing image;
[0132] The loss function is calculated based on the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, and the AFWM model parameters are adjusted based on the loss function value until the AFWM model converges, and the AFWM model training is determined to be completed.
[0133] The present application also provides an electronic device, such as Fig.14 As shown, it includes a processor 1401, a communication interface 1402, a memory 1403 and a communication bus 1404, wherein the processor 1401, the communication interface 1402, and the memory 1403 communicate with each other through the communication bus 1404.
[0134] Memory 1403, used for storing computer programs;
[0135] The processor 1401 is used to implement the above-mentioned image processing method steps when executing the program stored in the memory 1403.
[0136] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0137] The communication interface is used for communication between the above electronic device and other devices.
[0138] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0139] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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 gate or transistor logic devices, discrete hardware components.
[0140] In another embodiment provided in the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the image processing method described in any one of the above embodiments is implemented.
[0141] In another embodiment provided in the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the image processing method described in any one of the above embodiments.
[0142] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0143] 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.
[0144] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0145] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. An image processing method, It is characterized in that The method comprises: Obtaining images to be processed and images of clothes to be tried on; Extracting a first key point image, a second key point image and a background area image from the image to be processed; the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and an image of an obstruction on the area to be tried on; Input the first key point image, the second key point image and the background area image into a feature extraction layer of a thin plate spline transform TPS model, input the image of the clothes to be tried on into another feature extraction layer of the TPS model, input the features output by the two feature extraction layers into the feature matching layer of the TPS model to obtain matching features output by the feature matching layer, input the matching features into the spatial transformation parameter estimation layer of the TPS model to obtain spatial transformation parameters, perform TPS deformation on the image of the clothes to be tried on according to the spatial parameters to obtain a deformed clothes image; the network structure of the TPS model is a geometric matching GMM neural network structure, and the spatial transformation parameters are used to represent the spatial transformation relationship between the image of the clothes to be tried on and the deformed clothes image; Extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed; Reversely transforming the first image block into an image of clothes to be tried on based on the spatial transformation parameters, erasing the area that blocks the clothes to be tried on after the reverse transformation, to obtain an anti-occlusion image of clothes to be tried on; Input the first key point image, the second key point image, the background area image and the anti-occluded image of clothes to be tried on into the appearance flow deformation module AFWM model to obtain a pixel mapping relationship set, wherein the pixel mapping relationship set includes a mapping relationship between each pixel on the anti-occluded image of clothes to be tried on and each pixel in the area to be tried on in the image to be processed; According to the pixel mapping relationship set, each pixel of the anti-occlusion image of the clothes to be tried on is filled into the clothes to be tried on area in the image to be processed, so as to generate an anti-occlusion deformed clothes image.
2. The method according to claim 1, It is characterized in that The step of extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed includes: Performing human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed; The deformed clothing image is simulated and covered on the to-be-trimmed clothing area of the human body semantic segmentation result image, and the first image block that coincides with the position and shape of the occlusion image in the human body semantic segmentation result image is extracted from the deformed clothing image.
3. The method according to claim 1, It is characterized in that The AFWM model is trained by the following steps: Obtain sample fitting images and anti-occlusion sample clothing images; Inputting the first key point image, the second key point image, the background area image and the anti-occlusion sample clothing image of the sample fitting image into the AFWM model to obtain an anti-occlusion deformed sample clothing image; A loss function is calculated based on the clothing area in the sample fitting image and the anti-occlusion deformed sample clothing image, and the AFWM model parameters are adjusted based on the loss function value until the AFWM model converges, and it is determined that the AFWM model training is completed.
4. An image processing device, It is characterized in that The device comprises: An acquisition module, used for acquiring images to be processed and images of clothes to be tried on; An extraction module, used to extract a first key point image, a second key point image and a background area image from the image to be processed; the first key point image and the second key point image are both used to represent the posture of the person in the image to be processed, and the background area image includes the background area outside the area to be tried on in the image to be processed, and an image of an obstruction on the area to be tried on; A first deformation module is used to input the first key point image, the second key point image and the background area image into a feature extraction layer of a thin plate spline transformation TPS model, input the image of the clothes to be tried on into another feature extraction layer of the TPS model, input the features output by the two feature extraction layers into a feature matching layer of the TPS model to obtain matching features output by the feature matching layer, input the matching features into a spatial transformation parameter estimation layer of the TPS model to obtain spatial transformation parameters, and perform thin plate spline transformation TPS deformation on the image of the clothes to be tried on according to the spatial parameters to obtain a deformed clothes image; the network structure of the TPS model is a geometric matching GMM neural network structure, and the spatial transformation parameters are used to represent the spatial transformation relationship between the image of the clothes to be tried on and the deformed clothes image; an erasing module, configured to erase the region on the image of the clothes to be tried on that has a spatial transformation relationship with the occluder on the area to be tried on, based on the deformed clothes image and the spatial transformation parameter, so as to obtain an anti-occlusion image of the clothes to be tried on; The erasing module is specifically used for: Extracting a first image block consistent with the position and shape of the occlusion image from the deformed clothing image according to the image to be processed; inversely transforming the first image block into the image of the clothing to be tried on based on the spatial transformation parameters, erasing the area that occludes the clothing to be tried on after the inverse transformation, and obtaining an anti-occlusion image of the clothing to be tried on; A second deformation module is used to deform the anti-occlusion image of the clothes to be tried on through an appearance flow deformation module AFWM model based on the first key point image, the second key point image and the background area image to obtain an anti-occlusion deformed clothes image; The second deformation module is specifically used for: The first key point image, the second key point image, the background area image and the anti-occlusion image of clothes to be tried on are input into the appearance flow deformation module AFWM model to obtain a pixel mapping relationship set, wherein the pixel mapping relationship set includes a mapping relationship between each pixel on the anti-occlusion image of clothes to be tried on and each pixel in the area to be tried on in the image to be processed; according to the pixel mapping relationship set, each pixel of the anti-occlusion image of clothes to be tried on is filled into the area to be tried on in the image to be processed to generate an anti-occlusion deformed clothes image.
5. The device according to claim 4, It is characterized in that The erasing module is specifically used for: Performing human body semantic segmentation on the image to be processed to obtain a human body semantic segmentation result image of the image to be processed; The deformed clothing image is simulated and covered on the to-be-trimmed clothing area of the human body semantic segmentation result image, and the first image block that coincides with the position and shape of the occlusion image in the human body semantic segmentation result image is extracted from the deformed clothing image.
6. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 3 when executing a program stored in a memory.
7. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Three-dimensional virtual fitting method and system
CN110189202A
Four-stage virtual fitting method and device based on 2D image
CN112232914A
Virtual fitting method and device based on 2D image
CN112258269A
