WO2024149294A1 - 虚拟试衣及试衣模型训练的方法、装置和设备 - Google Patents

虚拟试衣及试衣模型训练的方法、装置和设备 Download PDF

Info

Publication number
WO2024149294A1
WO2024149294A1 PCT/CN2024/071592 CN2024071592W WO2024149294A1 WO 2024149294 A1 WO2024149294 A1 WO 2024149294A1 CN 2024071592 W CN2024071592 W CN 2024071592W WO 2024149294 A1 WO2024149294 A1 WO 2024149294A1
Authority
WO
WIPO (PCT)
Prior art keywords
image
optical flow
fitting
clothing
clothing image
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2024/071592
Other languages
English (en)
French (fr)
Inventor
李安
蒋剑斌
李玉乐
项伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bigo Technology Pte Ltd
Original Assignee
Bigo Technology Pte Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bigo Technology Pte Ltd filed Critical Bigo Technology Pte Ltd
Publication of WO2024149294A1 publication Critical patent/WO2024149294A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/0464Convolutional networks [CNN, ConvNet]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • G06N3/084Backpropagation, e.g. using gradient descent
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T19/00Manipulating three-dimensional [3D] models or images for computer graphics
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image

Definitions

  • the present application relates to the field of data processing technology, for example, to a virtual fitting method, a fitting model training method, a virtual fitting device, a fitting model training device, an electronic device, a computer-readable storage medium and a computer program product.
  • the virtual fitting technology mentioned in the related art mainly reconstructs a three-dimensional (3D) human body and warps 3D clothes onto the reconstructed 3D human body.
  • 3D clothes are difficult to obtain, and if the reconstructed 3D human body is not realistic enough, it will affect the effect of fitting clothes and cause poor fitting.
  • the present application provides a method, device and equipment for virtual fitting and fitting model training to solve the problem that the fitting effect is not realistic enough and the fit is poor in the virtual fitting technology in the related art.
  • an embodiment of the present application provides a virtual fitting method, the method comprising:
  • the target clothing image is predicted to correspond to
  • the target predicted optical flow is used to generate a target deformed clothing image according to the target predicted optical flow and the target clothing image;
  • a fitting effect image is generated according to the target deformed clothing image.
  • an embodiment of the present application provides a method for training a fitting model, the method comprising:
  • each first training data in the first training data set includes a sample clothing image and a first deformed clothing image after the sample clothing corresponding to the sample clothing image is worn on a human body;
  • the fitting optical flow model is used to generate an optical flow between the sample clothing image and the first deformed clothing image, and optical flow pair data is generated based on the optical flow and the sample clothing image;
  • each second training data in the second training data set includes the sample clothing image and a human body image obtained after the sample clothing corresponding to the sample clothing image is worn on a human body;
  • a fitting model is trained based on the second training data set and the optical flow pair data.
  • an embodiment of the present application further provides a virtual fitting device, the device comprising:
  • An image acquisition module configured to acquire a target clothing image and a fitting object image input by a user
  • a human body information acquisition module configured to acquire a target human body mask image and a target human body key point image of a human body region of the fitting object image
  • a clothing mask image acquisition module configured to acquire a target clothing mask image corresponding to the target clothing image
  • a target deformable clothing image acquisition module is configured to input the target clothing image, the target clothing mask image, the target human body mask image and the target human body key point image into a pre-generated fitting model; in the fitting model, based on the received input data, a target predicted optical flow corresponding to the target clothing image is predicted, and a target deformable clothing image is generated according to the target predicted optical flow and the target clothing image;
  • the fitting effect image generation module is configured to generate a fitting effect image according to the target deformed clothing image.
  • an embodiment of the present application further provides a device for training a fitting model, the device comprising:
  • a first training data set acquisition module is configured to acquire a first training data set, wherein each first training data in the first training data set includes a sample clothing image and a first deformed clothing image of the sample clothing corresponding to the sample clothing image after the sample clothing is worn on a human body;
  • a fitting optical flow model training module configured to train a fitting optical flow model using the first training data set
  • an optical flow pair data generating module configured to use the fitting optical flow model to generate an optical flow between the sample clothing image and the first deformed clothing image, and to generate optical flow pair data based on the optical flow and the sample clothing image;
  • the fitting model training module is configured to train the fitting model based on the second training data set and the optical flow pair data.
  • an embodiment of the present application further provides an electronic device, the electronic device comprising:
  • a storage device configured to store at least one program
  • the at least one processor When the at least one program is executed by the at least one processor, the at least one processor implements the method of the first aspect or the second aspect mentioned above.
  • an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the program is executed by a processor, the method of the first aspect or the second aspect described above is implemented.
  • an embodiment of the present application further provides a computer program product, wherein the computer program product comprises computer executable instructions, and the computer executable instructions are used to implement the method of the first aspect or the second aspect when executed.
  • FIG1 is a flow chart of an embodiment of a method for training a fitting model provided in Embodiment 1 of the present application;
  • FIG2 is a schematic diagram of the architecture of a fitting optical flow model provided in Example 1 of the present application.
  • FIG3 is a flowchart of an exemplary method for training a fitting optical flow model provided in Example 1 of the present application
  • FIG4 is a schematic diagram of a sample clothing image provided in Example 1 of the present application.
  • FIG5 is a schematic diagram of an optical flow of a training process provided in Example 1 of the present application.
  • FIG6 is a schematic diagram of a second deformed clothing image provided in Example 1 of the present application.
  • FIG. 7 is a schematic diagram of the structure of a fitting model provided in Example 1 of the present application.
  • FIG9 is a schematic diagram of the structure of a residual block provided in Embodiment 1 of the present application.
  • FIG10 is a flow chart of an embodiment of a virtual fitting method provided in Embodiment 2 of the present application.
  • FIG12 is a structural block diagram of an embodiment of a virtual fitting device provided in Embodiment 4 of the present application.
  • this embodiment may include the following steps:
  • Step 101 Acquire a first training data set, wherein each first training data in the first training data set includes a sample clothing image and a first deformed clothing image of the sample clothing corresponding to the sample clothing image after the sample clothing is worn on a human body.
  • the first training data set may be a set consisting of a plurality of first training data.
  • each first training data may include a sample clothing image and a first deformed clothing image.
  • the sample clothing image may be a flattened image of the sample clothing, that is, an image taken after the sample clothing is flattened. It can be understood that the sample clothing image is an image of the sample clothing without deformation, as shown in the schematic diagram of the sample clothing image C1 in FIG2 .
  • step 101 may include the following steps:
  • Step 101 - 1 obtaining a full training data set, where each training data in the full training data set includes a sample clothing image and a dressing image of the sample clothing corresponding to the sample clothing image after being worn on a human body.
  • the dressing image is a photograph of a sample clothing corresponding to the sample clothing image being worn on a human body, and includes an image of the sample clothing and the human body.
  • Each training data in the full training data set contains a sample clothing image and an associated dressing image.
  • the full training data set should cover as many samples as possible.
  • sample clothing in sample clothing images it can include short-sleeved, long-sleeved, coats, dresses, long skirts, short skirts and other clothing styles available on the market;
  • human body postures in dressing images it can include different types of postures such as different hand postures, different leg postures, simple postures, complex postures, etc.
  • the full training data set in order to improve the training effect of the model, can also be divided into training data subsets of different difficulty levels, and then batch training is performed according to the difficulty of the training data subsets.
  • the full training data set is divided into a difficult sample data set and a normal sample data set.
  • separate training can be performed by iterative overfitting.
  • the following method can be used to determine whether the training data is difficult sample data: the clothing image in the training data is subjected to key point extraction through a pre-trained key point model to obtain the human key point information in the clothing image, and then the training data is determined to be difficult sample data based on the human key point information.
  • the posture of the arm and the posture of the leg are determined based on the human key point information to determine whether the training data is difficult sample data. For example, if the hands or legs are bent or opened to a large extent, then the corresponding training data is difficult sample data, and the difficult sample data is placed in the difficult sample data set. After all the training data are traversed, the training data other than the difficult sample data set is placed in the ordinary sample data set.
  • Step 101 - 2 extracting the sample clothes from the clothing image to generate a first deformed clothing image.
  • a segmentation model can be pre-trained to segment clothes in a clothing image to obtain a mask image of sample clothes, and then the sample clothes are extracted from the clothing image based on the mask image of the sample clothes to generate a first deformed clothing image.
  • Step 101 - 3 associating the first deformed clothing image with the corresponding sample clothing image and recording them as a first training data.
  • Step 101 - 4 forming a first training data set from all the first training data obtained.
  • the sample clothing image and the corresponding first deformed clothing image may be associated and recorded as a first training data.
  • all first training data constitute a first training data set.
  • Step 102 Use the first training data set to train a fitting optical flow model.
  • the fitting optical flow model is used to determine the optical flow between the sample clothing image and the first deformed clothing image corresponding to the sample clothing image, that is, the optical flow of the sample clothing worn on the human body.
  • the human eye observes a moving object
  • the scene of the object forms a series of continuously changing images on the retina of the human eye.
  • This series of continuously changing information continuously "flows" through the retina (i.e., the image plane), like a "flow” of light, so it is called optical flow.
  • Optical flow expresses the changes in the image. Since it contains the target The information of the movement can be used by the observer to determine the movement of the target.
  • the optical flow can be used to express the deformation between the sample clothing and its deformed clothing.
  • the fitting optical flow model may be an unsupervised optical flow model. As shown in the schematic diagram of fitting optical flow model training in FIG3 , the fitting optical flow model may be trained in step 102 by using the following steps:
  • Step 102 - 1 determining the training process optical flow between the sample clothing image and the first deformed clothing image.
  • the optical flow method may be used to calculate the optical flow between the sample clothing image and the first deformed clothing image.
  • the optical flow at this stage is referred to as the training process optical flow.
  • the first feature information can be extracted from the sample clothing image
  • the second feature information can be extracted from the first deformed clothing image.
  • the sample clothing image C1 can be input into a first feature extraction network for feature extraction, and the first feature extraction network outputs the first feature information
  • the first deformed clothing image C2 can be input into a second feature extraction network for feature extraction, and the second feature extraction network outputs the second feature information.
  • both the first feature extraction network and the second feature extraction network can be convolutional neural networks
  • the first feature extraction network can include a plurality of first sub-networks P1 connected in sequence
  • the second feature extraction network can include a plurality of second sub-networks P2 connected in sequence.
  • each P1 or P2 can include: a convolution layer, a normalization layer, and an activation function layer, wherein the activation function used in the activation function layer can include a leaky linear rectifier activation function (leaky_relu).
  • the correlation between the first feature information and the second feature information is calculated to obtain the training process optical flow of the first feature information and the second feature information.
  • O1 represents the optical flow w obtained by calculating the correlation between the features.
  • Optical flow can be understood as a matrix of size (N, H, W, 2) that is used to reflect changes such as translation, rotation, and distortion between images.
  • Step 102-2 predicting a second deformed clothing image of the sample clothing image corresponding to the sample clothing image and the optical flow of the training process, when the sample clothing image is worn on a human body.
  • the shape of the output feature map tensor is (N, C, H, W), and the value of each cell on the output feature map is determined by the last dimension (x, y) of the grid. Then calculating the value of each point on the output feature map tensor may include: finding the sampling position on the input map through (x, y).
  • the value range of x and y is [-1, 1]
  • the sample clothing image is shown in FIG. 4
  • the training process optical flow of the sample clothing image is shown in FIG. 5
  • the second deformed clothing image obtained after grid_sampling the training process optical flow and the sample clothing image is shown in FIG. 6 .
  • Step 102 - 3 determining the deformation loss according to the first deformed clothing image and the second deformed clothing image.
  • the second deformed clothing image C3 may be compared with the first deformed clothing image C2 to determine the deformation loss.
  • step 102-3 may include the following steps:
  • the mean absolute error loss and the perceptual domain loss are determined; and the sum of the mean absolute error loss and the perceptual domain loss is used as the deformation loss.
  • deformation loss Loss L1_loss+Perceptual_loss
  • L1_loss is L1 loss, that is, mean absolute error loss
  • Perceptual_loss is perceptual domain loss.
  • Step 102-4 performing back propagation based on the deformation loss to optimize the parameters of the fitting optical flow model, and continuing to train the fitting optical flow model until the deformation loss reaches the minimum, and the training of the fitting optical flow model is completed.
  • Step 103 Generate an optical flow between the sample clothing image and the first deformed clothing image using a fitting optical flow model, and generate optical flow pair data based on the optical flow and the sample clothing image.
  • a deformed clothing image is generated according to the optical flow in the optical flow pair data and the sample clothing image; the deformed clothing image is input into a pre-generated binary classification model to obtain a deformation recognition result output by the binary classification model; when it is determined based on the deformation recognition result that the deformed clothing in the deformed clothing image has a deformation problem, the current optical flow pair data is filtered out.
  • the sample clothing image in the optical flow pair data can be grid_sampled with the corresponding optical flow to obtain the corresponding deformed clothing image.
  • the deformed clothing image is then input into a pre-generated binary classification model, which performs deformation problem recognition.
  • the binary classification model can wear (Warp) the deformed clothing image on a model to determine whether there are problems such as fit, texture distortion, clarity, etc., and output the deformation recognition result.
  • the binary classification model can be a deep residual network model (Deep Residual Network), such as a model generated based on ResNet50.
  • Deep Residual Network such as a model generated based on ResNet50.
  • a deformed clothing image without deformation problems may consider the following factors: the sleeves or trouser legs are not twisted; the pattern is clear and without distortion; there are no fit issues, such as fit issues at the neck, sleeves, etc.; there are no problems with the pattern, and there are no pattern confusion issues such as the length of the clothes.
  • Step 104 obtaining a second training data set, each second training data in the second training data set includes a sample clothing image and a human body image obtained after the sample clothing corresponding to the sample clothing image is worn on a human body, and the second training data set is used to train a fitting model.
  • the human body image may include a human body mask image of a human body region and a human body key point image
  • step 104 may include the following steps:
  • Step 104 - 1 extracting a mask image of the human body region from the clothed image, recorded as a human body mask image.
  • a mask image of the human body area is extracted from the clothed image, which is referred to as a human body mask image, as shown in human body mask image C5 in FIG7 .
  • step 104-1 may include the following steps:
  • Step 104-1-1 using the pre-trained DensePose (pose conversion model) to extract human body feature information from the clothed image, and generating a binary human body preliminary mask image based on the human body feature information.
  • DensePose pose conversion model
  • the human body feature information may be a human body posture recognition result output by a DensePose model, and may include, for example, human body analysis features such as arm analysis information and leg analysis information.
  • the human body feature information is then binarized to obtain a preliminary human body mask image.
  • the human body mask image can be a mask image of a human body without clothes.
  • the preliminary human body mask image may not achieve the above effect, so the mask image can be segmented according to the following steps to obtain a better human body mask image.
  • Step 104-1-2 obtaining a human body segmentation mask image.
  • the human body segmentation mask image may include mask images of different parts of the human body in the clothed image, such as a hand mask image, a leg mask image, a foot mask image, a torso mask image, and the like.
  • the clothed image may be input into a pre-trained human body parsing model, which divides the human body region of the clothed image into multiple human body parts and generates a corresponding mask image.
  • Step 104-1-3 taking the intersection of the preliminary human body mask image and the human body segmentation mask image to generate a mask image of the human body area.
  • the human body preliminary mask image and the human body segmentation mask image can be intersected to obtain the final human body area mask image.
  • the advantage of the above approach is that it can avoid the problem that the accuracy of DensePose affects the fit.
  • the information output by densepose is not used directly, because the information output by densepose is prone to data leakage, such as the length of a person's clothes. Therefore, the binary features of densepose are used, so that the trained model is more stable and the model generalization performance is stronger.
  • Step 104 - 2 using a pre-generated key point model to extract a human key point image of the human body region in the clothing image.
  • a human key point image of the human body region may be extracted from the clothed image, as shown in human key point image C6 in FIG7 .
  • the nx32x32 image is input into a preset hourglass network (Hourglass), and upsampling and convolution operations are performed to obtain a corresponding heatmap, and the result corresponding to the heatmap is determined as the human key point detection result.
  • a preset hourglass network Hourglass
  • Step 104 - 4 the sample clothing image, the sample clothing mask image, the human body mask image, and the human body key point image are associated and recorded as a second training data.
  • Step 105 training a fitting model based on the second training data set and the optical flow pair data.
  • the advantage of splicing the human body mask image and the corresponding human body key point image as the second input data in this embodiment is that it can better present the posture information of the human body, facilitate the warping of clothes, and achieve a better fitting effect.
  • the correlation between the first output feature of the first residual block at the same position and the second output feature of the second residual block is calculated to obtain the predicted optical flow of the first residual block and the second residual block at the same position.
  • the predicted optical flows w 1 of the first residual block P3 and the second residual block P4 are obtained by calculating the correlation based on the first output feature of the first residual block P3 and the second output feature of the second residual block P4.
  • Step 105-3 the predicted optical flow is input into the next first residual block as the feature of the sample clothes, so that the next first residual block obtains the deformed clothes feature as the first output feature based on the sample clothes feature and the obtained predicted optical flow, and returns the first output feature of the first residual block based on the same position and the second output feature of the second residual block, calculates the optical flow of the first residual block and the second residual block at the same position, and is recorded as the step of predicting the optical flow, and so on, until the last first residual block and the second residual block are processed.
  • the third first residual block will consider the predicted optical flow w 2 when performing feature extraction, and use the predicted optical flow w 2 to grid_sample the sample clothing features to obtain the deformed clothing features as the first output features for output.
  • the first output feature output by the third first residual block and the second output feature output by the third second residual block are correlated to obtain the predicted optical flow w 3 of the third first residual block and the third second residual block;
  • the resolution of the output feature map of each first residual block is different, and the resolution of the output feature map of each second residual block is also different.
  • the resolution size of the first input data and the second input data is 1024*768*N
  • the output resolution of the first first residual block and the first second residual block is 512*384*32
  • the output resolution of the second first residual block and the second second residual block is 256*192*64
  • the output resolution of the third first residual block and the third second residual block is 128*96*128,
  • the output resolution of the fourth first residual block and the fourth second residual block is 64*48*512
  • the output resolution of the fifth first residual block and the fifth second residual block is 32*24*512.
  • Step 105-4 each time after the predicted optical flow is obtained, based on the currently obtained predicted optical flow and the sample clothing image corresponding to the predicted optical flow, a deformed clothing image of the sample clothing corresponding to the sample clothing image worn on a human body is predicted, which is recorded as the predicted deformed clothing image.
  • step 105-5 may include the following steps:
  • Step 105-5-1 find the optical flow corresponding to the current sample clothing image from the optical flow pair data, and record it as the real optical flow.
  • Step 105-5-2 determining the optical flow difference between the currently obtained predicted optical flow and the real optical flow, and determining the optical flow loss according to the optical flow difference.
  • w k represents the value of the kth optical flow, such as w 1 , w 2 , w 3 , w 4 , w 5 ;
  • w gt represents the real optical flow in step 105-5-1;
  • w gtc represents the first deformed clothing image of the sample clothing corresponding to the current sample clothing image actually worn on a human body
  • vgg represents the vgg model, which is used to calculate Perceptual_loss
  • a, b, and c represent the weights of flow_pair_loss, mean absolute error loss (i.e., L1_loss), and Perceptual_loss, respectively.
  • L1_loss mean absolute error loss
  • Perceptual_loss Perceptual_loss
  • the fitting model When training the fitting model, we first use sample clothing images and multiple sample clothing images to train the fitting model.
  • the fitting optical flow model is trained with the first deformed clothing image of the corresponding sample clothing worn on the human body, and then the optical flow between the sample clothing image and the corresponding first deformed clothing image is generated based on the fitting optical flow model, and optical flow pair data is generated based on the optical flow and the corresponding sample clothing image. Then, the fitting model is trained in combination with the generated optical flow pair data and a second training data set containing human body images obtained after the sample clothing corresponding to the sample clothing image is worn on the human body.
  • FIG10 is a flow chart of a virtual fitting method embodiment provided in Embodiment 2 of the present application, which can be implemented by a virtual fitting device, which can be connected to an application (Application, APP) or a Web (World Wide Web) page according to the development document to implement a virtual fitting function in the APP or Web page.
  • the terminal where the APP or Web page is located can include a mobile phone, a tablet computer, a fitting robot, etc.
  • the principle of virtual fitting in this embodiment is not only applicable to clothes, but also to other wearable items, such as shoes, socks, jewelry, etc.
  • the target clothing in the target clothing image needs to retain important features of the wearer such as texture and shape as much as possible, for example, it may be an image of the clothing after being flattened, as shown in C1 of FIG. 2 .
  • the fitting object image may also include: each image frame containing the fitting object in the target video.
  • each image frame containing the fitting object in the target video For example, in a live broadcast scene, when a user triggers a virtual fitting function in the live broadcast interface and specifies a person who needs to try on clothes, the image frame containing the specified person in the live broadcast scene may be used as the fitting object image.
  • the sizes of the two images may be processed into a uniform size, for example, by using center proportional cutting and proportional scaling to process the two images into a uniform size.
  • step 104 - 1 Regarding the method of obtaining the target human body mask image and the target human body key point image, reference may be made to the description of step 104 - 1 to step 104 - 2 in the first embodiment.
  • the method of obtaining the target clothing mask image may refer to the description of step 104 - 3 .
  • Step 204 input the target clothing image, the target clothing mask image, the target human body mask image and the target human body key point image into a pre-generated fitting model.
  • the target clothing image and the target clothing mask image can be concatenated together as an input stream of the fitting model, which can be referred to as clothing input data.
  • the human body key point images are spliced together as another input stream of the fitting model, which can be referred to as fitting object input data.
  • the fitting model can extract clothing features from clothing input data and fitting object features from fitting object input data, and then calculate the optical flow corresponding to the target clothing image based on the clothing features and fitting object features, which is called target predicted optical flow.
  • the target predicted optical flow and the target clothing image can be grid_sampled to obtain the target deformed clothing image.
  • Step 206 Generate a fitting effect image according to the target deformed clothing image.
  • the original clothes of the fitting subject may be erased first, and then the target deformed clothes image may be pasted (Warp) on the fitting subject to generate a fitting effect image.
  • the target deformed clothes image may be pasted (Warp) on the fitting subject to generate a fitting effect image.
  • the fitting effect image may also be returned to the user.
  • the original clothes of the fitting object can be erased by drawing an elliptical image mask based on the key points of the arm.
  • the size of this ellipse needs to be larger than the range of the original arm, and the size of the ellipse can be determined based on empirical values.
  • a square mask can be drawn based on the body parts in the preliminary human body analysis results, and then the masks of the two arms and the masks of the body parts are connected into a complete mask.
  • the expansion and corrosion method is used to process it to obtain the result of erasing the human body clothes.
  • the target human body mask image and the target human body key point image of the human body area of the fitting object image can be obtained, and the target clothing mask image corresponding to the target clothing image can be obtained.
  • the target clothing image, the target clothing mask image, the target human body mask image and the target human body key point image are input into the pre-generated fitting model, and the fitting model predicts the target predicted optical flow corresponding to the target clothing image, and generates the target deformed clothing image based on the target predicted optical flow and the target clothing image, and then the fitting effect image can be generated based on the target deformed clothing image.
  • the generated fitting effect image is more realistic, and can solve the problems of sleeve distortion, poor fitting aesthetics, low clarity and fit. And the whole process is free of Without requiring the user to perform other complicated operations, a realistic try-on effect can be obtained, and the user does not need to perform other complicated operations, and the versatility is strong.
  • FIG11 is a structural block diagram of an embodiment of a fitting model training device provided in Embodiment 3 of the present application, which may include the following modules:
  • a first training data set acquisition module 301 is configured to acquire a first training data set, wherein each first training data in the first training data set includes a sample clothing image and a first deformed clothing image after the sample clothing corresponding to the sample clothing image is worn on a human body;
  • a fitting optical flow model training module 302 is configured to train a fitting optical flow model using the first training data set
  • an optical flow pair data generating module 303 configured to generate an optical flow between the sample clothing image and the first deformed clothing image using the fitting optical flow model, and generate optical flow pair data based on the optical flow and the sample clothing image;
  • a second training data set acquisition module 304 is configured to acquire a second training data set, wherein each second training data in the second training data set includes the sample clothing image and a human body image obtained after the sample clothing corresponding to the sample clothing image is worn on a human body;
  • the first training data set acquisition module 301 is configured to:
  • a predicted optical flow acquisition module configured to calculate the optical flow of the first residual block and the second residual block at the same position based on the first output feature of the first residual block and the second output feature of the second residual block at the same position, recorded as predicted optical flow;
  • the predicted deformable clothing image determination module is configured to predict a deformable clothing image of the sample clothing corresponding to the sample clothing image worn on a human body according to the currently obtained predicted optical flow and the sample clothing image corresponding to the predicted optical flow each time after the predicted optical flow is obtained, and record it as the predicted deformable clothing image;
  • a fitting loss determination module configured to determine the fitting loss based on the currently obtained predicted optical flow, the sample clothing image, and the predicted deformed clothing image;
  • the fitting loss determination module is configured to:
  • the sum of the optical flow loss, the mean absolute error loss and the perceptual domain loss is taken as the fitting loss.
  • the device may further include an optical flow data screening module configured to:
  • FIG. 12 is a structural block diagram of an embodiment of a virtual fitting device provided in Embodiment 4 of the present application, which may include the following modules:
  • a human body information acquisition module 402 is configured to acquire a target human body mask image and a target human body key point image of a human body region of the fitting object image;
  • the target deformable clothing image acquisition module 404 is configured to input the target clothing image, the target clothing mask image, the target human body mask image and the target human body key point image into a pre-generated fitting model; in the fitting model, based on the received input data, predict the target predicted optical flow corresponding to the target clothing image, and generate a target deformable clothing image according to the target predicted optical flow and the target clothing image;
  • the fitting effect image generating module 405 is configured to generate a fitting effect image according to the target deformed clothing image.
  • the virtual fitting device provided in the embodiment of the present application can execute a virtual fitting device of the second embodiment of the present application.
  • the simulated fitting method has functional modules and effects corresponding to the execution method.
  • FIG13 shows a schematic diagram of the structure of an electronic device 10 that can be used to implement the method embodiment of the present application.
  • the electronic device 10 includes at least one processor 11, and a storage device that is connected to the at least one processor 11 in communication, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the storage device stores one or more computer programs that can be executed by at least one processor, and the processor 11 can perform a variety of appropriate actions and processes according to the computer program stored in the ROM 12 or the computer program loaded from the storage unit 18 to the random access RAM 13.
  • the RAM 13 a variety of programs and data required for the operation of the electronic device 10 can also be stored.
  • the method in the first or second embodiment may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18.
  • a computer-readable storage medium such as a storage unit 18.
  • part or all of the computer program may be loaded and/or installed on the electronic device 10 via the ROM 12 and/or the communication unit 19.
  • the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the method in the first or second embodiment described above may be performed.
  • the method in embodiment one or embodiment two may be implemented as a computer program product, which includes computer executable instructions, which are used to perform one or more steps of the method in embodiment one or embodiment two described above when executed.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Biomedical Technology (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Computer Graphics (AREA)
  • Computer Hardware Design (AREA)
  • Processing Or Creating Images (AREA)
  • Image Analysis (AREA)

Abstract

一种虚拟试衣及试衣模型训练的方法、装置和设备,该虚拟试衣方法包括:获取用户输入的目标衣服图像以及试衣对象图像(201);获取该试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像(202);获取该目标衣服图像对应的目标衣服mask图像(203);将该目标衣服图像、该目标衣服mask图像、该目标人体mask图像以及该目标人体关键点图像输入至预先生成的试衣模型中(204);在该试衣模型中,基于接收到的输入数据,预测目标衣服图像对应的目标预测光流,并根据目标预测光流以及该目标衣服图像生成目标形变衣服图像(205);根据目标形变衣服图像生成试衣效果图像(206)。

Description

虚拟试衣及试衣模型训练的方法、装置和设备
本申请要求在2023年01月13日提交中国专利局、申请号为202310038842.5的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及数据处理技术领域,例如涉及一种虚拟试衣方法、一种试衣模型训练的方法、一种虚拟试衣装置、一种试衣模型训练的装置、一种电子设备、一种计算机可读存储介质以及一种计算机程序产品。
背景技术
随着互联网的发展,网络购物越来越受大众喜欢,但和线下购物相比,线上购物存在一些体验差的问题,例如购买的衣服没有办法试穿,不知道效果如何,导致退货率高。而虚拟试衣技术目的就是提供一种虚拟的试衣场景,给用户带来更好的体验。虚拟试衣技术是计算机视觉领域的一种重要技术方向,虚拟试衣技术可以广泛用于电商平台中,以提升用户体验。
相关技术中提及的虚拟试衣技术,主要是通过重构三维(three Dimension,3D)人体,将3D的衣服变换(warp)到重构的3D人体身上。然而,3D的衣服是比较难获取的,并且重构的3D人体如果不够真实则会影响衣服试穿效果,存在贴合度差的问题。
发明内容
本申请提供了一种虚拟试衣及试衣模型训练的方法、装置和设备,以解决相关技术中的虚拟试衣技术中试衣效果不够真实、贴合度差的问题。
第一方面,本申请实施例提供了一种虚拟试衣方法,所述方法包括:
获取用户输入的目标衣服图像以及试衣对象图像;
获取所述试衣对象图像的人体区域的目标人体mask(掩膜)图像以及目标人体关键点图像;
获取所述目标衣服图像对应的目标衣服mask图像;
将所述目标衣服图像、所述目标衣服mask图像、所述目标人体mask图像以及所述目标人体关键点图像输入至预先生成的试衣模型中;
在所述试衣模型中,基于接收到的输入数据,预测所述目标衣服图像对应 的目标预测光流,并根据所述目标预测光流以及所述目标衣服图像生成目标形变衣服图像;
根据所述目标形变衣服图像生成试衣效果图像。
第二方面,本申请实施例提供了一种试衣模型训练的方法,所述方法包括:
获取第一训练数据集,所述第一训练数据集中每个第一训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像;
采用所述第一训练数据集训练试衣光流模型;
采用所述试衣光流模型生成所述样本衣服图像与所述第一形变衣服图像之间的光流,并基于所述光流与所述样本衣服图像生成光流对数据;
获取第二训练数据集,所述第二训练数据集中每个第二训练数据包括所述样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像;
基于所述第二训练数据集以及所述光流对数据训练试衣模型。
第三方面,本申请实施例还提供了一种虚拟试衣装置,所述装置包括:
图像获取模块,设置为获取用户输入的目标衣服图像以及试衣对象图像;
人体信息获取模块,设置为获取所述试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像;
衣服mask图像获取模块,设置为获取所述目标衣服图像对应的目标衣服mask图像;
目标形变衣服图像获取模块,设置为将所述目标衣服图像、所述目标衣服mask图像、所述目标人体mask图像以及所述目标人体关键点图像输入至预先生成的试衣模型中;在所述试衣模型中,基于接收到的输入数据,预测所述目标衣服图像对应的目标预测光流,并根据所述目标预测光流以及所述目标衣服图像生成目标形变衣服图像;
试衣效果图像生成模块,设置为根据所述目标形变衣服图像生成试衣效果图像。
第四方面,本申请实施例还提供了一种试衣模型训练的装置,所述装置包括:
第一训练数据集获取模块,设置为获取第一训练数据集,所述第一训练数据集中每个第一训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像;
试衣光流模型训练模块,设置为采用所述第一训练数据集训练试衣光流模型;
光流对数据生成模块,设置为采用所述试衣光流模型生成所述样本衣服图像与所述第一形变衣服图像之间的光流,并基于所述光流与所述样本衣服图像生成光流对数据;
第二训练数据集获取模块,设置为获取第二训练数据集,所述第二训练数据集中每个第二训练数据包括所述样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像;
试衣模型训练模块,设置为基于所述第二训练数据集以及所述光流对数据训练试衣模型。
第五方面,本申请实施例还提供了一种电子设备,所述电子设备包括:
至少一个处理器;
存储装置,设置为存储至少一个程序,
当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现上述第一方面或第二方面的方法。
第六方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该程序被处理器执行时实现上述第一方面或第二方面的方法。
第七方面,本申请实施例还提供了一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述计算机可执行指令在被执行时用于实现上述第一方面或第二方面的方法。
附图说明
图1是本申请实施例一提供的一种试衣模型训练的方法实施例的流程图;
图2是本申请实施例一提供的一种试衣光流模型的架构示意图;
图3是本申请实施例一提供的一种试衣光流模型训练的示例性方法流程图;
图4是本申请实施例一提供的一种样本衣服图像示意图;
图5是本申请实施例一提供的一种训练过程光流示意图;
图6是本申请实施例一提供的一种第二形变衣服图像示意图;
图7是本申请实施例一提供的一种试衣模型的架构示意图;
图8是本申请实施例一提供的一种试衣模型训练的示例性方法流程图;
图9是本申请实施例一提供的一种残差块的结构示意图;
图10是本申请实施例二提供的一种虚拟试衣方法实施例的流程图;
图11是本申请实施例三提供的一种试衣模型训练的装置实施例的结构框图;
图12是本申请实施例四提供的一种虚拟试衣装置实施例的结构框图;
图13是本申请实施例五提供的一种电子设备的结构示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行说明。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
实施例一
图1为本申请实施例一提供的一种试衣模型训练的方法实施例的流程图,该试衣模型可以应用在虚拟试衣场景中,实现虚拟试衣的功能。例如,在电商平 台、短视频娱乐、图像处理、电影制作、直播、游戏等场景下都可添加虚拟试衣功能。
如图1所示,本实施例可以包括如下步骤:
步骤101,获取第一训练数据集,该第一训练数据集中的每个第一训练数据包括样本衣服图像、以及该样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像。
第一训练数据集可以为由多个第一训练数据组成的集合。可选地,每个第一训练数据可以包括样本衣服图像以及第一形变衣服图像。
样本衣服图像可以是样本衣服的平铺图像,也就是,将样本衣服进行平铺后拍摄的图像,可以理解为,样本衣服图像为样本衣服没有发生形变的图像,如图2的样本衣服图像C1示意图所示。
第一形变衣服图像为样本衣服图像对应的样本衣服穿着在人体身上后发生形变的衣服图像。例如,第一形变衣服图像可以为样本衣服穿着在模特身上后从模特身上扣下来的衣服图像,如图2的第一形变衣服图像C2示意图所示。
在一种实施例中,步骤101可以包括如下步骤:
步骤101-1,获取全量训练数据集,该全量训练数据集中的每个训练数据包括样本衣服图像、以及该样本衣服图像对应的样本衣服穿着在人体身上后的穿衣图像。
该穿衣图像为样本衣服图像对应的样本衣服穿着在人体身上后进行拍照的,包含该样本衣服以及人体的图像。
在全量训练数据集中的每个训练数据包含样本衣服图像以及与之关联的穿衣图像。为了提升训练效果,全量训练数据集覆盖的样本越全越好。例如,对于样本衣服图像中的样本衣服,可以包括短袖、长袖、外套、连衣裙、长裙、短裙等市面上有的衣服样式;对于穿衣图像中的人体姿势,可以包括手的不同姿势、腿的不同姿势、简单的姿势、复杂的姿势等不同类型的姿势。
在本申请实施例中,为了提升模型的训练效果,还可以将全量训练数据集划分成不同难度等级的训练数据子集,然后根据训练数据子集的难易程度进行分批训练。例如,将全量训练数据集划分成难样本数据集以及普通样本数据集, 对于难样本数据集,可以采用迭代过拟合的方式进行单独训练。在一种实现中,可以采用如下方式判断训练数据是否为难样本数据:将训练数据中的穿衣图像通过预先训练的关键点模型进行关键点提取,得到该穿衣图像中的人体关键点信息,然后根据该人体关键点信息来判断该训练数据是否为难样本数据,例如,根据该人体关键点信息判断手臂的姿势、腿的姿势等来判断该训练数据是否为难样本数据,比如如果手或腿弯曲或者张开的程度比较大,那么对应的训练数据就是难样本数据,将该难样本数据放入难样本数据集,则当所有训练数据都遍历完毕以后,除难样本数据集以外的训练数据则放入普通样本数据集。
步骤101-2,从穿衣图像中提取所述样本衣服,生成第一形变衣服图像。
在一种实现中,可以预先训练分割模型,通过该分割模型来对穿衣图像中的衣服进行分割,获得样本衣服的mask图像,然后基于样本衣服的mask图像将样本衣服从穿衣图像中提取出来,生成第一形变衣服图像。
步骤101-3,将第一形变衣服图像与对应的样本衣服图像关联记录为一条第一训练数据。
步骤101-4,将获得的所有第一训练数据组成第一训练数据集。
针对当前样本衣服图像,当获得当前样本衣服图像对应的第一形变衣服图像以后,则可以将该样本衣服图像与对应的第一形变衣服图像关联记录为一条第一训练数据。
当所有样本衣服图像都生成第一训练数据以后,则所有的第一训练数据组成第一训练数据集。
本实施例的训练数据,除了样本衣服图像以外,还可以包括第一形变衣服图像,将第一形变衣服图像作为训练数据训练试衣光流模型可以提升试衣光流模型的训练效果,得到更真实的光流。
步骤102,采用所述第一训练数据集训练试衣光流模型。
该试衣光流模型用于确定样本衣服图像与样本衣服图像对应的第一形变衣服图像之间的光流(Optical Flow),即,样本衣服穿到人体身上的光流。在人的眼睛观察运动物体的情况下,物体的景象在人眼的视网膜上形成一系列连续变化的图像,这一系列连续变化的信息不断“流过”视网膜(即图像平面),好像一种光的“流”,故称之为光流。光流表达了图像的变化,由于它包含了目标 运动的信息,因此可被观察者用来确定目标的运动情况。在本实施例中,则可以采用光流来表达样本衣服与其形变衣服之间的形变情况。
利用图像序列中像素在时间域上的变化以及相邻帧之间的相关性来找到上一帧跟当前帧之间存在的对应关系,从而计算出相邻帧之间物体的运动信息的方法称为光流法,本实施例的试衣光流模型可以依据光流法获取样本衣服图像与样本衣服图像对应的第一形变衣服图像之间的光流。
在一种实施例中,该试衣光流模型可以为无监督光流模型,如图3的试衣光流模型训练示意图所示,在步骤102中可以采用如下步骤训练试衣光流模型:
步骤102-1,确定样本衣服图像与第一形变衣服图像之间的训练过程光流。
在本实施例中,可以使用光流法计算样本衣服图像与第一形变衣服图像之间的光流,为了便于区分,将此阶段的光流称为训练过程光流。
可选的,可以从样本衣服图像中提取第一特征信息,以及,从第一形变衣服图像中提取第二特征信息。在一种实现中,如图2所示,可以将样本衣服图像C1输入至第一特征提取网络进行特征提取,由第一特征提取网络输出第一特征信息;以及,将第一形变衣服图像C2输入至第二特征提取网络进行特征提取,由第二特征提取网络输出第二特征信息。
示例性地,第一特征提取网络以及第二特征提取网络均可以为卷积神经网络,第一特征提取网络中可以包括多个次第相连的第一子网络P1,第二特征提取网络中可以包括多个次第相连的第二子网络P2。可选的,每个P1或P2中可以包括:卷积层、归一化层以及激活函数层,其中,该激活函数层中使用的激活函数可以包括带泄露线性整流激活函数(leaky_relu)。
接着,计算第一特征信息与第二特征信息之间的相关性,得到第一特征信息与第二特征信息的训练过程光流。如图2所示,O1表示特征之间计算相关性得到光流w。
光流可以理解为一个大小为(N,H,W,2)的矩阵,用于反映图像之间的平移、旋转、扭曲等变化情况。
步骤102-2,根据样本衣服图像与训练过程光流,预测样本衣服图像对应的样本衣服穿着在人体身上的第二形变衣服图像。
在一种实现中,可以将训练过程光流与样本衣服图像进行grid_sample(一种特殊的采样算法),以预测样本衣服图像对应的样本衣服穿着在人体身上后发生形变的样子,生成第二形变衣服图像,如图2的第二形变衣服图像C3所示。
grid_sample的原理如下。假设输入图(即本实施例中的样本衣服图像)的shape(形状)为(N,C,H,W)(N表示单次训练样本数(batch size)、C表示通道数、H表示特征图长、W表示特征图宽),grid(流场,本实施例中为训练过程光流的光流场)的shape设定为(N,H,W,2),以双线性差值为例进行处理。首先,根据input(输入图)和grid设定,输出特征图tensor(张量)的shape为(N,C,H,W),输出特征图上每一个cell(单元)上的值由grid最后一维(x,y)确定。那么计算输出特征图tensor上每一个点的值可以包括:通过(x,y)找到输入图上的采样位置,由于x、y取值范围为[-1,1],为了便于计算,先将x、y取值范围调整为[0,1];通过(w-1)*(x+1)/2、(wh-1)*(y+1)/2将x、y映射为输入图的具体坐标位置;将x、y映射到特征图实际坐标后,取该坐标附近四个角点特征值,通过四个角点特征值的坐标与采样点坐标相对关系进行双线性插值,得到采样点的值。
例如,若样本衣服图像如图4所示,样本衣服图像的训练过程光流如图5所示,训练过程光流与样本衣服图像进行grid_sample后得到的第二形变衣服图像如图6所示。
步骤102-3,根据第一形变衣服图像以及第二形变衣服图像,确定形变损失。
在获得第二形变衣服图像以后,则可以将该第二形变衣服图像C3与第一形变衣服图像C2进行比较,确定形变损失。
在一种实施例中,步骤102-3可以包括如下步骤:
根据第一形变衣服图像以及第二形变衣服图像,确定平均绝对误差损失以及感知域损失;将平均绝对误差损失与感知域损失的和作为形变损失。
可选的,如图2所示,形变损失Loss=L1_loss+Perceptual_loss,L1_loss为L1损失,也就是平均绝对误差损失;Perceptual_loss为感知域损失。
在一种实现中,L1_loss的计算方式可以为:L1_loss=abs(C3-C2),其中,“abs”为绝对值。第二形变衣服图像C3与第一形变衣服图像C2的Perceptual_loss可表示为Perceptual loss(C3,C2),C3与C2的感知域损失可以采用卷积神经网络(Visual Geometry Group,VGG)模型(例如VGG-19或VGG-16)的特征层计算 平方差损失得到,因此也可以称为VGG_loss,即:Perceptual loss(C3,C2)=E((VGG(C3)-VGG(C2))2,其中,E为均值。
步骤102-4,基于所述形变损失进行反向传播,以优化所述试衣光流模型的参数,继续训练所述试衣光流模型,直到所述形变损失达到最小,则所述试衣光流模型训练完成。
在对试衣光流模型进行训练的情况下,形变损失越小,训练得到的试衣光流模型输出的光流就会越接近真实光流。
步骤103,采用试衣光流模型生成样本衣服图像与第一形变衣服图像之间的光流,并基于该光流与样本衣服图像生成光流对数据。
当试衣光流模型训练完成以后,则可以将第一训练数据集中的第一样本衣服图像与对应的第一形变衣服图像输入至试衣光流模型,由第一训练数据集获取第一样本衣服图像与对应的第一形变衣服图像之间的光流。然后可以将该光流与对应的样本衣服图像进行绑定,得到光流对(pair)数据,则每个光流pair数据可以包括样本衣服图像与样本衣服图像对应的光流。
在一种实施例中,通过步骤103可以得到多种不同的光流pair数据。在这些光流pair数据中可能会包含存在美感、扭曲以及贴合度等问题的光流pair数据,如果直接拿这些光流pair数据去训练试衣模型,无法得到理想的效果,因此可以过滤掉这些存在问题的光流pair数据,以得到更好的pair数据。则在步骤103之后,还可以包括如下步骤:
根据光流对数据中的光流以及样本衣服图像,生成形变衣服图像;将该形变衣服图像输入至预先生成的二分类模型中,获取该二分类模型输出的形变识别结果;在基于该形变识别结果判断该形变衣服图像中的形变衣服存在形变问题的情况下,过滤掉当前光流对数据。
可选的,针对每个光流pair数据,可以将该光流pair数据中的样本衣服图像与对应的光流进行grid_sample,得到对应的形变衣服图像。然后将该形变衣服图像输入至预先生成的二分类模型中,由该二分类模型进行形变问题识别,例如,二分类模型可以将形变衣服图像穿着(Warp)在模特身上,判断是否存在贴合度、纹理扭曲、清晰度等问题,并输出形变识别结果。
例如,形变识别结果可以包括0和1,0表示该形变衣服图像存在形变问题, 1表示该形变衣服图像不存在形变问题。在光流pair数据生成的形变衣服图像存在形变问题的情况下,可以将该光流pair数据作为缺陷光流pair数据,并可以过滤掉该光流pair数据;在光流pair数据生成的形变衣服图像不存在形变问题的情况下,可以将该光流pair数据作为完美光流pair数据,并可以保留该光流pair数据。
示例性地,该二分类模型可以为深度残差网络模型(Deep Residual Network),例如基于ResNet50生成的模型。
示例性地,一个不存在形变问题的形变衣服图像可以考虑如下因素:衣袖或者裤腿没有扭曲;图案清晰、无扭曲;没有出现贴合度的问题,例如脖子处、衣袖处等的贴合问题;版型没有问题,没有出现衣服的长度等版型错乱问题。
步骤104,获取第二训练数据集,该第二训练数据集中的每个第二训练数据包括样本衣服图像、以及该样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像,该第二训练数据集用于训练试衣模型。
示例性地,人体图像可以包括人体区域的人体mask图像以及人体关键点图像,则步骤104可以包括如下步骤:
步骤104-1,从穿衣图像中提取所述人体区域的mask图像,记作人体mask图像。
可选的,对于全量训练数据集中的每条训练数据,可以提取其穿衣图像,然后从穿衣图像中提取人体区域的mask图像,此处记作人体mask图像,如图7的人体mask图像C5所示。
在一种实施例中,步骤104-1可以包括如下步骤:
步骤104-1-1,采用预训练的DensePose(姿态转换模型)从穿衣图像中提取人体特征信息,并基于该人体特征信息生成二值化的人体初步mask图像。
该人体特征信息可以为DensePose模型输出的人体姿态识别结果,例如可以包括手臂解析信息、腿部的解析信息等人体解析特征,然后对该人体特征信息进行二值化处理,得到人体初步mask图像。
为了得到更好效果的试衣模型,人体mask图像可以为没有穿衣服的人体的mask图像。而人体初步mask图像未必能达到上述的效果,因此可以根据下述步骤采用分割mask图像的方式来得到效果更好的人体mask图像。
步骤104-1-2,获取人体分割mask图像。
示例性地,人体分割mask图像可以包括穿衣图像中的人体的不同部位的mask图像,例如手部mask图像、腿部mask图像、脚部mask图像、躯干mask图像等。
在一种实现中,可以将穿衣图像输入至预训练的人体解析模型中,由人体解析模型将该穿衣图像的人体区域划分成多个人体部位并生成对应的mask图像。
步骤104-1-3,取该人体初步mask图像与人体分割mask图像的交集,生成人体区域的mask图像。
当获得人体分割mask图像以后,则可以将人体初步mask图像与人体分割mask图像取交集,获得最终的人体区域的mask图像。
上述做法的好处是可以避免DensePose的准确率影响贴合度的问题,同时不直接使用densepose输出的信息,因为densepose输出的信息容易出现数据泄露,例如容易直接泄露了人的衣服的长度等,所以采用densepose的二值化特征,这样训练的模型更加稳定,模型泛化性能更强。
步骤104-2,采用预先生成的关键点模型提取穿衣图像中人体区域的人体关键点图像。
可选的,对于全量训练数据集中的每条训练数据,可以提取其穿衣图像,然后从穿衣图像中提取人体区域的人体关键点图像,如图7的人体关键点图像C6所示。
人体关键点是指人体的多个部位的关键位置点,人体关键点对于描述人体姿态、预测人体行为至关重要。例如人体关键点可以包括左、右手臂的三个点(手腕、手肘、肩膀),左、右腿的三个点(脚腕、膝盖、胯骨),髋、臀部点以及头部点(眼睛,下巴,头顶)等。
在该步骤中,可以通过关键点模型来对穿衣图像进行关键点检测。可选的,人体关键点检测也称人体姿态估计,其任务是要在给定的图片中定位人体的身体关键部件,例如头部、颈部、肩部、手部等。在不同数据集上,需要检测的具体部位不同,检测出的关键点的数量也不同。
在一种实现中,关键点模型可以是一种基于深度学习的模型。可选地,关键点模型还可以是预训练的经过多次推理检测、精度较高的无差别的关键点检测模型。例如,将穿衣图像输入一个无差别检测的人体关键点检测模型,得到每一人体关键点对应的概率分布图。根据实际的处理情况和网络结构,可以对穿衣图像进行不同的采样处理,例如,穿衣图像是大小为3x256x256,经过三次下采样和卷积操作将穿衣图像预处理为nx32x32的图像。接着,将nx32x32的图像输入一个预设的沙漏网络(Hourglass),进行升采样处理和卷积操作,得到对应的热力图(heatmap),将该热力图对应的结果确定为人体关键点检测结果。
步骤104-3,从样本衣服图像中提取样本衣服区域的mask图像,记作样本衣服mask图像。
可选的,对于全量训练数据集中的每条训练数据,可以提取其样本衣服图像,然后从样本衣服图像中提取样本衣服的mask图像,如图7的样本衣服mask图像C4所示。
在一种实现中,可以预先训练人体解析模型,通过该人体解析模型来从样本衣服图像中生成样本衣服的mask图像。人体解析就是将人体的多个部位分割出来,是一种细粒度的语义分割任务。例如,通过人体解析后可以将目标人体分割成头发、脸部、衣服、裤子、四肢等部位。
步骤104-4,将样本衣服图像、样本衣服mask图像、人体mask图像、人体关键点图像关联记录为一条第二训练数据。
在第二训练数据中,可以将样本衣服图像和样本衣服mask图像拼接在一起作为样本衣服的相关训练数据,以及,将人体mask图像和人体关键点图像拼接在一起作为人体的相关训练数据,然后将样本衣服的相关训练数据和人体的相关训练数据关联起来生成第二训练数据。
步骤104-5,将获得的所有第二训练数据组成第二训练数据集。
步骤105,基于第二训练数据集以及光流对数据训练试衣模型。
在该步骤中,可以结合保留下来的完美光流pair数据和第二训练数据集训练试衣模型,使得训练试衣模型达到切合度更好的试衣效果。
在一种实施例中,如图8所示,步骤105可以包括如下步骤:
步骤105-1,将样本衣服图像以及对应的样本衣服mask图像进行拼接作为第一输入数据输入至试衣网络,以及,将人体mask图像以及对应的人体关键点图像进行拼接作为第二输入数据输入至所述试衣网络。
在试衣网络中可以包括与第一输入数据对应的多个级联的第一残差块(即第一res_block模块),以及,与第二输入数据对应的多个级联的第二残差块(即第二res_block模块)。例如,如图7所示,试衣网络包含第一残差网络和第二残差网络,第一残差网络中可以包括多个级联的第一残差块P3,第二残差网络中可以包括多个级联的第二残差块P4。C1和C4拼接后作为第一输入数据输入至第一残差网络,C5和C6拼接后作为第二输入数据输入至第二残差网络。
本实施例将样本衣服图像以及对应的样本衣服mask图像进行拼接作为第一输入数据的好处是,因为增加了mask信息的输入,类似于告诉试衣网络哪部分是背景,哪部分是样本衣服的区域,解决了在样本衣服的背景和衣服颜色相近的情况下出现的一些模型崩溃的问题。
另外,本实施例将人体mask图像以及对应的人体关键点图像进行拼接作为第二输入数据的好处是,可以更好地呈现人体的姿态信息,便于进行衣服的warp,达到更好的试衣效果。
在一种实现中,第一残差块和第二残差块的结构如图9所示,每个第一残差块或第二残差块中均可以包括若干相连的第三子网络P5,每个第三子网络P5可以包括:卷积层、归一化层以及激活函数层,其中,该激活函数层中使用的激活函数可以包括带泄露线性整流激活函数(leaky_relu)。在图9中,O2符号表示特征相加。
步骤105-2,基于同一位置的第一残差块的第一输出特征以及第二残差块的第二输出特征,计算同一位置的第一残差块与第二残差块的光流,记作预测光流。
第一残差网络中的第N个残差块与第二残差网络中的第N个残差块属于同一位置的第一残差块和第二残差块。例如,图7中P3和P4属于同一位置的第一残差块和第二残差块。
将同一位置的第一残差块的第一输出特征与第二残差块的第二输出特征计算相关性得到同一位置的第一残差块与第二残差块的预测光流,例如,图7中, 基于第一残差块P3的第一输出特征与第二残差块P4的第二输出特征计算相关性得到第一残差块P3与第二残差块P4的预测光流w1
步骤105-3,将该预测光流作为样本衣服的特征输入至下一第一残差块中,使得下一第一残差块基于样本衣服特征以及获得的预测光流获得形变衣服特征作为第一输出特征进行输出,并返回基于同一位置的所述第一残差块的第一输出特征以及所述第二残差块的第二输出特征,计算同一位置的第一残差块与第二残差块的光流,记作预测光流的步骤,以此类推,直到最后的第一残差块和第二残差块处理完毕。
例如,如图7所示,基于第一残差块P3(假设为第一个第一残差块)的第一输出特征与第二残差块P4(假设为第一个第二残差块)的第二输出特征计算相关性得到第一个第一残差块与第一个第二残差块的预测光流w1
第二个第一残差块在进行特征提取的情况下会考虑预测光流w1,使用预测光流w1对样本衣服特征进行grid_sample,得到形变衣服特征作为第一输出特征进行输出,接着,第二个第一残差块输出的第一输出特征与第二个第二残差块输出的第二输出特征计算相关性得到第二个第一残差块与第二个第二残差块的预测光流w2
第三个第一残差块在进行特征提取的情况下会考虑预测光流w2,使用预测光流w2对样本衣服特征进行grid_sample,得到形变衣服特征作为第一输出特征进行输出接着,第三个第一残差块输出的第一输出特征与第三个第二残差块输出的第二输出特征计算相关性得到第三个第一残差块与第三个第二残差块的预测光流w3
第四个第一残差块在进行特征提取的情况下会考虑预测光流w3,使用预测光流w3对样本衣服特征进行grid_sample,得到形变衣服特征作为第一输出特征进行输出,接着,第四个第一残差块输出的第一输出特征与第四个第二残差块输出的第二输出特征计算相关性得到第四个第一残差块与第四个第二残差块的预测光流w4
第五个第一残差块在进行特征提取的情况下会考虑预测光流w4,使用预测光流w4对样本衣服特征进行grid_sample,得到形变衣服特征作为第一输出特征进行输出,接着,第五个第一残差块输出的第一输出特征与第五个第二残差块输 出的第二输出特征计算相关性得到第五个第一残差块与第五个第二残差块的预测光流w5。在图7的架构中,预测光流w5为最后输出的预测光流。
每个第一残差块的输出特征图的分辨率是不一样的,每个第二残差块的输出特征图的分辨率也是不一样的,例如,假设第一输入数据和第二输入数据的分辨率大小为1024*768*N,第一个第一残差块和第一个第二残差块的输出分辨率为512*384*32,第二个第一残差块和第二个第二残差块的输出分辨率为256*192*64,第三个第一残差块和第三个第二残差块的输出分辨率为128*96*128,第四个第一残差块和第四个第二残差块的输出分辨率为64*48*512,第五个第一残差块和第五个第二残差块的输出分辨率为32*24*512。则w1的分辨率为512*384*32,w2的分辨率为256*192*64,w3的分辨率为128*96*128,w4的分辨率为64*48*512,w5的分辨率为32*24*512,多级光流形成一个金字塔形的光流。
本实施例通过多级光流与残差块相结合,每个光流都会作用在下一层样本衣服的特征上面,可以更好地提升模型的学习效果。
步骤105-4,每次获得预测光流以后,根据当前获得的预测光流以及该预测光流对应的样本衣服图像,预测该样本衣服图像对应的样本衣服穿着在人体身上的形变衣服图像,记作预测形变衣服图像。
每一次获得预测光流w以后,则可以根据该预测光流与其对应的样本衣服图像进行grid_sample,得到对应的预测形变衣服图像。
例如,在图7中,获得最后输出的预测光流w5以后,则可以将样本衣服图像C1与预测光流w5进行grid_sample,生成预测形变衣服图像C7。
步骤105-5,基于当前获得的所述预测光流、样本衣服图像、预测形变衣服图像确定试衣损失。
如图7所示,试衣损失Loss可以包括平均绝对误差损失(即L1_loss)、感知域损失(Perceptual_loss)以及光流损失(flow_pair_loss)。
在一种实施例中,步骤105-5可以包括如下步骤:
步骤105-5-1,从光流对数据中查找当前样本衣服图像对应的光流,记作真实光流。
步骤105-5-2,确定当前获得的所述预测光流与真实光流的光流差异,并根据该光流差异确定光流损失。
步骤105-5-3,确定当前样本衣服图像对应的第一形变衣服图像与预测形变衣服图像的形变差异,并根据该形变差异确定平均绝对误差损失。
步骤105-5-4,根据当前样本衣服图像对应的第一形变衣服图像与预测形变衣服图像,确定感知域损失。
步骤105-5-5,将光流损失、平均绝对误差损失与感知域损失之和作为试衣损失。
例如,图7的架构中,试衣损失Loss可以采用如下公式计算:
其中,
k表示多级光流,在图7中共5个光流;
wk表示第k个光流的值,如w1、w2、w3、w4、w5
wgt表示步骤105-5-1中的真实光流;
wkc表示第k个光流的值对应的预测形变衣服图像,即步骤105-4中的预测形变衣服图像;
wgtc表示当前样本衣服图像对应的样本衣服真实穿着在人体身上的第一形变衣服图像;
vgg表示vgg模型,用于计算Perceptual_loss;
a、b、c分别表示flow_pair_loss、平均绝对误差损失(即L1_loss)和Perceptual_loss的权重,在训练时,可以设定a=10、b=1、c=1。
步骤105-6,基于试衣损失进行反向传播,以优化所述试衣网络的参数,继续训练所述试衣模型,直到所述试衣损失达到最小,则所述试衣模型训练完成。
每一次计算得到试衣损失以后,则可以基于该试衣损失进行梯度反向传播,以优化试衣网络的参数,直到试衣损失达到最小则试衣模型训练完成。
在训练试衣模型时,首先通过样本衣服图像,以及,多个样本衣服图像对 应的样本衣服穿着在人体身上后的第一形变衣服图像训练试衣光流模型,然后基于该试衣光流模型生成样本衣服图像与对应的第一形变衣服图像之间的光流,并基于该光流与对应的样本衣服图像生成光流对数据。接着结合生成的光流对数据以及包含样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像的第二训练数据集训练试衣模型。在该实施例中,结合光流pair数据来训练试衣模型,使得最终得到的试衣模型能够解决衣袖扭曲、试穿美感差、清晰度低以及贴合度的问题,达到更加逼真的试穿效果。且本实施例无需复杂的建模过程,模型的泛化性能强、适用范围广。
实施例二
图10为本申请实施例二提供的一种虚拟试衣方法实施例的流程图,该方法可以通过虚拟试衣装置实现,该虚拟试衣装置可以按开发文档接入到应用(Application,APP)或Web(万维网)页面中,以在该APP或者Web页面中实现虚拟试衣功能。该APP或Web页面所在的终端可以包括手机、平板电脑、试衣机器人等。
本实施例可以应用于电商平台、短视频娱乐、图像处理、电影制作、直播、游戏等场景的虚拟试衣功能上。例如,在电商平台中,买家用户选定衣服以后,可以上传一张包含想要试穿该衣服的人物的照片,则通过虚拟试衣功能用户可以直接看到在该人物身上穿上该选定衣服的穿衣效果图;卖家用户给定模特的图以及拍好的衣服以后,则可以通过本实施例的虚拟穿衣功能得到电商平台的衣服主图。又如,给定一段视频,指定视频中需要试穿衣服的人物,以及想要试穿的衣服,则通过视频应用程序中的虚拟试衣功能,可以将视频中的该指定的人物的衣服换成想要试穿的衣服。
本实施例的虚拟试衣的原理不仅仅适用于衣服上,也可以适用于其他的穿戴物,例如可以包括鞋子、袜子、首饰等。
如图10所示,本实施例可以包括如下步骤:
步骤201,获取用户输入的目标衣服图像以及试衣对象图像。
示例性地,目标衣服图像可以是用户上传的包含目标衣服的图像;或者,目标衣服图像还可以是用户在当前APP或者Web页面展示的衣服图像序列中选定的图像;或者,目标衣服图像还可以是用户在视频中选定某个人物,然后从 该人物身上提取出衣服并查找该衣服对应的目标衣服的图像,本实施例对目标衣服图像的获取方式不作限定。
可选地,目标衣服图像中的目标衣服需要尽可能保留穿戴物的纹理、形状等重要特征,例如可以是平铺后的衣服的图像,如图2的C1所示。
在一种例子中,试衣对象图像可以包括:经由虚拟试衣功能页面导入的图像。例如,当用户触发虚拟试衣功能进入虚拟试衣功能页面以后,可以根据页面中的导入接口导入试衣对象图像。试衣对象图像为包含需要试穿的试衣对象的图像,该试衣对象可以是用户本人,也可以是其他人;该试衣对象图像可以是自拍图像,也可以是其他非自拍图像,本实施例对此不作限制。
在另一种例子中,试衣对象图像还可以包括:目标视频中包含试衣对象的各图像帧。例如,在直播场景中,在用户在直播界面中触发虚拟试衣功能、并指定需要试穿衣服的人物的情况下,可以将该直播场景中包含该指定人物的图像帧作为试衣对象图像。
试衣对象图像中的试衣对象需要尽可能地完整保留人体的正面特征,至少是保留与试穿衣服相关的人体部位的正面特征。
在获得目标衣服图像以及试衣对象图像以后,可以将这两个图像的尺寸处理成统一尺寸,例如采用中心等比例切割和等比例缩放等方式将两个图像处理成统一尺寸。
步骤202,获取试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像。
关于目标人体mask图像以及目标人体关键点图像的获取方式可以参考实施例一中步骤104-1至步骤104-2的描述。
步骤203,获取目标衣服图像对应的目标衣服mask图像。
目标衣服mask图像的获取方式可以参考步骤104-3的描述。
步骤204,将目标衣服图像、目标衣服mask图像、目标人体mask图像以及目标人体关键点图像输入至预先生成的试衣模型中。
可选的,可以将目标衣服图像和目标衣服mask图像拼接在一起作为试衣模型的一路输入流,此处可以称为衣服输入数据;将目标人体mask图像以及目标 人体关键点图像拼接在一起作为试衣模型的另一路输入流,此处可以称为试衣对象输入数据。
步骤205,在试衣模型中,基于接收到的输入数据,预测目标衣服图像对应的目标预测光流,并根据目标预测光流以及目标衣服图像生成目标形变衣服图像。
在本实施例中,试衣模型可以从衣服输入数据中提取衣服特征,以及,从试衣对象输入数据中提取试衣对象特征。然后基于该衣服特征和试衣对象特征计算目标衣服图像对应的光流,称为目标预测光流。
得到目标预测光流以后,则可以将该目标预测光流与目标衣服图像进行grid_sample,得到目标形变衣服图像。
步骤206,根据目标形变衣服图像生成试衣效果图像。
可选的,可以先擦除试衣对象原有的衣服,然后将该目标形变衣服图像贴在(Warp)在试衣对象身上,生成试衣效果图像。
获得试衣效果图像以后,在一种实施例中还可以将试衣效果图像返回用户。
在一种实现中,擦除试衣对象原有的衣服的方式可以为:可以基于手臂关键点绘制一个椭圆的图像掩模mask,这个椭圆的大小需要比原有手臂的范围大,椭圆的大小可以根据经验值确定。然后对于身体部分,可以基于初步人体解析结果中的身体部位,绘制方形mask,然后将两手臂的mask与身体部位的mask连接成一个完整的masks,最后再通过膨胀腐蚀的方法进行处理,得到擦除人体衣服的结果。
在本实施例中,在虚拟试衣场景中,用户输入目标衣服图像以及试衣对象图像以后,则可以获取试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像,并获取目标衣服图像对应的目标衣服mask图像。然后将目标衣服图像、目标衣服mask图像、目标人体mask图像以及目标人体关键点图像输入至预先生成的试衣模型中,由试衣模型预测目标衣服图像对应的目标预测光流,并根据该目标预测光流以及目标衣服图像生成目标形变衣服图像,然后就可以根据目标形变衣服图像生成试衣效果图像。由于试衣模型的处理过程中采用光流来预测目标衣服的形变衣服图像,使得生成的试衣效果图像更加逼真,能够解决衣袖扭曲、试穿美感差、清晰度低以及贴合度的问题。且整个过程无 需用户进行其他复杂的操作,则可以得到逼真的试穿效果,无需用户进行其他复杂的操作,通用性强。
实施例三
图11为本申请实施例三提供的一种试衣模型训练的装置实施例的结构框图,可以包括如下模块:
第一训练数据集获取模块301,设置为获取第一训练数据集,所述第一训练数据集中的每个第一训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像;
试衣光流模型训练模块302,设置为采用所述第一训练数据集训练试衣光流模型;
光流对数据生成模块303,设置为采用所述试衣光流模型生成所述样本衣服图像与所述第一形变衣服图像之间的光流,并基于所述光流与所述样本衣服图像生成光流对数据;
第二训练数据集获取模块304,设置为获取第二训练数据集,所述第二训练数据集中的每个第二训练数据包括所述样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像;
试衣模型训练模块305,设置为基于所述第二训练数据集以及所述光流对数据训练试衣模型。
在一种实施例中,试衣光流模型训练模块302可以包括如下模块:
训练过程光流确定模块,设置为确定所述样本衣服图像与所述第一形变衣服图像之间的训练过程光流;
第二形变衣服图像确定模块,设置为根据所述样本衣服图像与所述训练过程光流,预测所述样本衣服图像对应的样本衣服穿着在人体身上的第二形变衣服图像;
形变损失确定模块,设置为根据所述第一形变衣服图像以及所述第二形变衣服图像,确定形变损失;
模型优化模块,设置为基于所述形变损失进行反向传播,以优化所述试衣 光流模型的参数,继续训练所述试衣光流模型,直到所述形变损失达到最小,则所述试衣光流模型训练完成。
在一种实施例中,形变损失确定模块是设置为:
根据所述第一形变衣服图像以及所述第二形变衣服图像,确定平均绝对误差损失以及感知域损失;
将所述平均绝对误差损失与所述感知域损失的和作为所述形变损失。
在一种实施例中,第一训练数据集获取模块301是设置为:
获取全量训练数据集,所述全量训练数据集中的每个训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的穿衣图像;
从所述穿衣图像中提取所述样本衣服,生成第一形变衣服图像;
将所述第一形变衣服图像与对应的所述样本衣服图像关联记录为一条第一训练数据;
将获得的所有第一训练数据组成第一训练数据集。
在一种实施例中,所述人体图像包括所述人体区域的人体mask图像以及人体关键点图像;
第二训练数据集获取模块304是设置为:
从所述穿衣图像中提取所述人体区域的mask图像,记作人体mask图像;
采用预先生成的关键点模型提取所述穿衣图像中所述人体区域的人体关键点图像;
从所述样本衣服图像中提取所述样本衣服区域的mask图像,记作样本衣服mask图像;
将所述样本衣服图像、所述样本衣服mask图像、所述人体mask图像、所述人体关键点图像关联记录为一条第二训练数据;
将获得的所有第二训练数据组成第二训练数据集。
在一种实施例中,试衣模型训练模块305可以包括如下模块:
输入模块,设置为将所述样本衣服图像以及对应的所述样本衣服mask图像进行拼接作为第一输入数据输入至试衣网络,以及,将所述人体mask图像以及 对应的所述人体关键点图像进行拼接作为第二输入数据输入至所述试衣网络,其中,所述试衣网络包括与所述第一输入数据对应的多个级联的第一残差块,以及,与所述第二输入数据对应的多个级联的第二残差块;
预测光流获取模块,设置为基于同一位置的所述第一残差块的第一输出特征以及所述第二残差块的第二输出特征,计算同一位置的所述第一残差块与所述第二残差块的光流,记作预测光流;
残差处理模块,设置为将该预测光流作为样本衣服的特征输入至下一第一残差块中,使得下一第一残差块基于样本衣服特征以及获得的预测光流获得形变衣服特征作为第一输出特征进行输出,并返回基于同一位置的所述第一残差块的第一输出特征以及所述第二残差块的第二输出特征,计算同一位置的所述第一残差块与所述第二残差块的光流,记作预测光流的步骤,以此类推,直到最后的第一残差块和第二残差块处理完毕;
预测形变衣服图像确定模块,设置为每次获得预测光流以后,根据当前获得的预测光流以及该预测光流对应的所述样本衣服图像,预测所述样本衣服图像对应的样本衣服穿着在人体身上的形变衣服图像,记作预测形变衣服图像;
试衣损失确定模块,设置为基于当前获得的所述预测光流、所述样本衣服图像、所述预测形变衣服图像确定试衣损失;
试衣模型优化模块,设置为基于所述试衣损失进行反向传播,以优化所述试衣网络的参数,继续训练所述试衣模型,直到所述试衣损失达到最小,则所述试衣模型训练完成。
在一种实施例中,试衣损失确定模块是设置为:
从所述光流对数据中查找所述样本衣服图像对应的光流,记作真实光流;
确定当前获得的所述预测光流与所述真实光流的光流差异,并根据所述光流差异确定光流损失;
确定所述样本衣服图像对应的第一形变衣服图像与所述预测形变衣服图像的形变差异,并根据所述形变差异确定平均绝对误差损失;
根据所述样本衣服图像对应的第一形变衣服图像与所述预测形变衣服图像,确定感知域损失;
将所述光流损失、所述平均绝对误差损失与所述感知域损失之和作为所述试衣损失。
在一种实施例中,所述装置还可以包括光流对数据筛选模块,设置为:
在基于所述光流与所述样本衣服图像生成光流对数据之后,根据所述光流对数据中的光流以及所述样本衣服图像,生成形变衣服图像;
将所述形变衣服图像输入至预先生成的二分类模型中,获取所述二分类模型输出的形变识别结果;
在基于所述形变识别结果判断所述形变衣服图像中的形变衣服存在形变问题的情况下,过滤掉当前光流对数据。
本申请实施例所提供的一种试衣模型训练的装置可执行本申请实施例一的一种试衣模型训练的方法,具备执行方法相应的功能模块和效果。
实施例四
图12为本申请实施例四提供的一种虚拟试衣装置实施例的结构框图,可以包括如下模块:
图像获取模块401,设置为获取用户输入的目标衣服图像以及试衣对象图像;
人体信息获取模块402,设置为获取所述试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像;
衣服mask图像获取模块403,设置为获取所述目标衣服图像对应的目标衣服mask图像;
目标形变衣服图像获取模块404,设置为将所述目标衣服图像、所述目标衣服mask图像、所述目标人体mask图像以及所述目标人体关键点图像输入至预先生成的试衣模型中;在所述试衣模型中,基于接收到的输入数据,预测所述目标衣服图像对应的目标预测光流,并根据所述目标预测光流以及所述目标衣服图像生成目标形变衣服图像;
试衣效果图像生成模块405,设置为根据所述目标形变衣服图像生成试衣效果图像。
本申请实施例所提供的一种虚拟试衣装置可执行本申请实施例二的一种虚 拟试衣方法,具备执行方法相应的功能模块和效果。
实施例五
图13示出了可以用来实施本申请的方法实施例的电子设备10的结构示意图。如图13所示,电子设备10包括至少一个处理器11,以及与至少一个处理器11通信连接的存储装置,如只读存储器(Read-Only Memory,ROM)12、随机访问存储器(Random Access Memory,RAM)13等,其中,存储装置存储有可被至少一个处理器执行的一个或多个计算机程序,处理器11可以根据存储在ROM12中的计算机程序或者从存储单元18加载到随机访问RAM13中的计算机程序,来执行多种适当的动作和处理。在RAM13中,还可存储电子设备10操作所需的多种程序和数据。
在一些实施例中,实施例一或实施例二中的方法可被实现为计算机程序,其被有形地包含于计算机可读存储介质,例如存储单元18。在一些实施例中,计算机程序的部分或者全部可以经由ROM12和/或通信单元19而被载入和/或安装到电子设备10上。当计算机程序加载到RAM13并由处理器11执行时,可以执行上文描述的实施例一或实施例二中的方法的一个或多个步骤。
在一些实施例中,实施例一或实施例二中的方法可被实现为计算机程序产品,该计算机程序产品包括计算机可执行指令,该计算机可执行指令在被执行时用于执行上文描述的实施例一或实施例二中的方法的一个或多个步骤。

Claims (14)

  1. 一种虚拟试衣方法,所述方法包括:
    获取用户输入的目标衣服图像以及试衣对象图像;
    获取所述试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像;
    获取所述目标衣服图像对应的目标衣服mask图像;
    将所述目标衣服图像、所述目标衣服mask图像、所述目标人体mask图像以及所述目标人体关键点图像输入至预先生成的试衣模型中;
    在所述试衣模型中,基于接收到的输入数据,预测所述目标衣服图像对应的目标预测光流,并根据所述目标预测光流以及所述目标衣服图像生成目标形变衣服图像;
    根据所述目标形变衣服图像生成试衣效果图像。
  2. 一种试衣模型训练的方法,所述方法包括:
    获取第一训练数据集,所述第一训练数据集中每个第一训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像;
    采用所述第一训练数据集训练试衣光流模型;
    采用所述试衣光流模型生成所述样本衣服图像与所述第一形变衣服图像之间的光流,并基于所述光流与所述样本衣服图像生成光流对数据;
    获取第二训练数据集,所述第二训练数据集中每个第二训练数据包括所述样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像;
    基于所述第二训练数据集以及所述光流对数据训练试衣模型。
  3. 根据权利要求2所述的方法,其中,所述采用所述第一训练数据集训练试衣光流模型,包括:
    确定所述样本衣服图像与所述第一形变衣服图像之间的训练过程光流;
    根据所述样本衣服图像与所述训练过程光流,预测所述样本衣服图像对应的样本衣服穿着在人体身上的第二形变衣服图像;
    根据所述第一形变衣服图像以及所述第二形变衣服图像,确定形变损失;
    基于所述形变损失进行反向传播,以优化所述试衣光流模型的参数,继续训练所述试衣光流模型,直到所述形变损失达到最小,则所述试衣光流模型训练完成。
  4. 根据权利要求3所述的方法,其中,所述根据所述第一形变衣服图像以及所述第二形变衣服图像,确定形变损失,包括:
    根据所述第一形变衣服图像以及所述第二形变衣服图像,确定平均绝对误差损失以及感知域损失;
    将所述平均绝对误差损失与所述感知域损失的和作为所述形变损失。
  5. 根据权利要求2-4任一项所述的方法,其中,所述获取第一训练数据集,包括:
    获取全量训练数据集,所述全量训练数据集中的每个训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的穿衣图像;
    从所述穿衣图像中提取所述样本衣服,生成第一形变衣服图像;
    将所述第一形变衣服图像与对应的所述样本衣服图像关联记录为一条第一训练数据;
    将获得的所有第一训练数据组成第一训练数据集。
  6. 根据权利要求5所述的方法,其中,所述人体图像包括所述人体区域的 人体mask图像以及人体关键点图像;
    所述获取第二训练数据集,包括:
    从所述穿衣图像中提取所述人体区域的mask图像,记作人体mask图像;
    采用预先生成的关键点模型提取所述穿衣图像中所述人体区域的人体关键点图像;
    从所述样本衣服图像中提取所述样本衣服区域的mask图像,记作样本衣服mask图像;
    将所述样本衣服图像、所述样本衣服mask图像、所述人体mask图像、所述人体关键点图像关联记录为一条第二训练数据;
    将获得的所有第二训练数据组成第二训练数据集。
  7. 根据权利要求6所述的方法,其中,所述基于所述第二训练数据集以及所述光流对数据训练试衣模型,包括:
    将所述样本衣服图像以及对应的所述样本衣服mask图像进行拼接作为第一输入数据输入至试衣网络,以及,将所述人体mask图像以及对应的所述人体关键点图像进行拼接作为第二输入数据输入至所述试衣网络,其中,所述试衣网络包括与所述第一输入数据对应的多个级联的第一残差块,以及,与所述第二输入数据对应的多个级联的第二残差块;
    基于同一位置的所述第一残差块的第一输出特征以及所述第二残差块的第二输出特征,计算同一位置的所述第一残差块与所述第二残差块的光流,记作预测光流;
    将所述预测光流作为样本衣服的特征输入至下一所述第一残差块中,使得下一所述第一残差块基于样本衣服特征以及获得的预测光流获得形变衣服特征作为所述第一输出特征进行输出,并返回基于同一位置的所述第一残差块的第 一输出特征以及所述第二残差块的第二输出特征,计算同一位置的所述第一残差块与所述第二残差块的光流,记作预测光流的步骤,以此类推,直到最后的第一残差块和第二残差块处理完毕;
    每次获得预测光流以后,根据当前获得的预测光流以及该预测光流对应的所述样本衣服图像,预测所述样本衣服图像对应的样本衣服穿着在人体身上的形变衣服图像,记作预测形变衣服图像;
    基于当前获得的所述预测光流、所述样本衣服图像、所述预测形变衣服图像确定试衣损失;
    基于所述试衣损失进行反向传播,以优化所述试衣网络的参数,继续训练所述试衣模型,直到所述试衣损失达到最小,则所述试衣模型训练完成。
  8. 根据权利要求7所述的方法,其中,所述基于当前获得的所述预测光流、所述样本衣服图像、所述预测形变衣服图像确定试衣损失,包括:
    从所述光流对数据中查找所述样本衣服图像对应的光流,记作真实光流;
    确定当前获得的所述预测光流与所述真实光流的光流差异,并根据所述光流差异确定光流损失;
    确定所述样本衣服图像对应的第一形变衣服图像与所述预测形变衣服图像的形变差异,并根据所述形变差异确定平均绝对误差损失;
    根据所述样本衣服图像对应的第一形变衣服图像与所述预测形变衣服图像,确定感知域损失;
    将所述光流损失、所述平均绝对误差损失与所述感知域损失之和作为所述试衣损失。
  9. 根据权利要求2-4任一项所述的方法,在所述基于所述光流与所述样本衣服图像生成光流对数据之后,所述方法还包括:
    根据所述光流对数据中的光流以及所述样本衣服图像,生成形变衣服图像;
    将所述形变衣服图像输入至预先生成的二分类模型中,获取所述二分类模型输出的形变识别结果;
    在基于所述形变识别结果判断所述形变衣服图像中的形变衣服存在形变问题的情况下,过滤掉当前光流对数据。
  10. 一种虚拟试衣装置,所述装置包括:
    图像获取模块,设置为获取用户输入的目标衣服图像以及试衣对象图像;
    人体信息获取模块,设置为获取所述试衣对象图像的人体区域的目标人体mask图像以及目标人体关键点图像;
    衣服mask图像获取模块,设置为获取所述目标衣服图像对应的目标衣服mask图像;
    目标形变衣服图像获取模块,设置为将所述目标衣服图像、所述目标衣服mask图像、所述目标人体mask图像以及所述目标人体关键点图像输入至预先生成的试衣模型中;在所述试衣模型中,基于接收到的输入数据,预测所述目标衣服图像对应的目标预测光流,并根据所述目标预测光流以及所述目标衣服图像生成目标形变衣服图像;
    试衣效果图像生成模块,设置为根据所述目标形变衣服图像生成试衣效果图像。
  11. 一种试衣模型训练的装置,所述装置包括:
    第一训练数据集获取模块,设置为获取第一训练数据集,所述第一训练数据集中每个第一训练数据包括样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后的第一形变衣服图像;
    试衣光流模型训练模块,设置为采用所述第一训练数据集训练试衣光流模 型;
    光流对数据生成模块,设置为采用所述试衣光流模型生成所述样本衣服图像与所述第一形变衣服图像之间的光流,并基于所述光流与所述样本衣服图像生成光流对数据;
    第二训练数据集获取模块,设置为获取第二训练数据集,所述第二训练数据集中每个第二训练数据包括所述样本衣服图像、以及所述样本衣服图像对应的样本衣服穿着在人体身上后获得的人体图像;
    试衣模型训练模块,设置为基于所述第二训练数据集以及所述光流对数据训练试衣模型。
  12. 一种电子设备,所述电子设备包括:
    至少一个处理器;
    存储装置,设置为存储至少一个程序,
    当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如权利要求1-9任一项所述的方法。
  13. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该程序被处理器执行时实现如权利要求1-9任一项所述的方法。
  14. 一种计算机程序产品,所述计算机程序产品包括计算机可执行指令,所述计算机可执行指令在被执行时用于实现权利要求1-9中任一项所述的方法。
PCT/CN2024/071592 2023-01-13 2024-01-10 虚拟试衣及试衣模型训练的方法、装置和设备 Ceased WO2024149294A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202310038842.5A CN115994994A (zh) 2023-01-13 2023-01-13 虚拟试衣及试衣模型训练的方法、装置和设备
CN202310038842.5 2023-01-13

Publications (1)

Publication Number Publication Date
WO2024149294A1 true WO2024149294A1 (zh) 2024-07-18

Family

ID=85994857

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2024/071592 Ceased WO2024149294A1 (zh) 2023-01-13 2024-01-10 虚拟试衣及试衣模型训练的方法、装置和设备

Country Status (2)

Country Link
CN (1) CN115994994A (zh)
WO (1) WO2024149294A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119398865A (zh) * 2024-10-16 2025-02-07 杭州电子科技大学 一种基于时序增强扩散模型的视频虚拟试衣方法
CN120707754A (zh) * 2025-08-26 2025-09-26 苏州大学 一种服装合体性预测方法
CN121482212A (zh) * 2026-01-06 2026-02-06 贵州大学 一种层级上下文迭代与密集融合的精炼虚拟试衣系统

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115994994A (zh) * 2023-01-13 2023-04-21 百果园技术(新加坡)有限公司 虚拟试衣及试衣模型训练的方法、装置和设备
CN116486210A (zh) * 2023-04-27 2023-07-25 广州博冠信息科技有限公司 装束转换模型训练方法、装置、存储介质及设备
CN117036851B (zh) * 2023-07-28 2026-04-21 深圳数联天下智能科技有限公司 训练虚拟试衣模型的方法、生成试衣图像的方法及相关装置
CN119359972B (zh) * 2024-12-23 2025-03-21 深圳盈天下视觉科技有限公司 虚拟试衣方法、虚拟试衣装置、电子设备及存储介质

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113361560A (zh) * 2021-03-22 2021-09-07 浙江大学 一种基于语义的多姿势虚拟试衣方法
CN114170403A (zh) * 2021-11-24 2022-03-11 深圳数联天下智能科技有限公司 虚拟试衣方法、装置、服务器及存储介质
US20220245876A1 (en) * 2019-07-17 2022-08-04 Beijing Jingdong Shangke Information Technology Co., Ltd. Method and apparatus for virtual fitting
US20220318892A1 (en) * 2021-03-26 2022-10-06 Nhn Corporation Method and system for clothing virtual try-on service based on deep learning
CN115272822A (zh) * 2022-07-20 2022-11-01 深圳数联天下智能科技有限公司 训练解析模型的方法、虚拟试衣方法及相关装置
CN115439309A (zh) * 2022-08-17 2022-12-06 深圳数联天下智能科技有限公司 训练衣服变形模型的方法、虚拟试衣方法及相关装置
CN115564871A (zh) * 2022-09-29 2023-01-03 深圳数联天下智能科技有限公司 训练试衣模型的方法、虚拟试衣方法及相关装置
CN115994994A (zh) * 2023-01-13 2023-04-21 百果园技术(新加坡)有限公司 虚拟试衣及试衣模型训练的方法、装置和设备

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112634331B (zh) * 2020-12-04 2025-01-14 北京迈格威科技有限公司 一种光流预测方法及装置
CN114937286A (zh) * 2022-05-27 2022-08-23 深圳市皓丽软件有限公司 虚拟试衣方法、装置、设备及介质
CN115439308A (zh) * 2022-08-11 2022-12-06 深圳数联天下智能科技有限公司 训练试衣模型的方法、虚拟试衣方法及相关装置

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20220245876A1 (en) * 2019-07-17 2022-08-04 Beijing Jingdong Shangke Information Technology Co., Ltd. Method and apparatus for virtual fitting
CN113361560A (zh) * 2021-03-22 2021-09-07 浙江大学 一种基于语义的多姿势虚拟试衣方法
US20220318892A1 (en) * 2021-03-26 2022-10-06 Nhn Corporation Method and system for clothing virtual try-on service based on deep learning
CN114170403A (zh) * 2021-11-24 2022-03-11 深圳数联天下智能科技有限公司 虚拟试衣方法、装置、服务器及存储介质
CN115272822A (zh) * 2022-07-20 2022-11-01 深圳数联天下智能科技有限公司 训练解析模型的方法、虚拟试衣方法及相关装置
CN115439309A (zh) * 2022-08-17 2022-12-06 深圳数联天下智能科技有限公司 训练衣服变形模型的方法、虚拟试衣方法及相关装置
CN115564871A (zh) * 2022-09-29 2023-01-03 深圳数联天下智能科技有限公司 训练试衣模型的方法、虚拟试衣方法及相关装置
CN115994994A (zh) * 2023-01-13 2023-04-21 百果园技术(新加坡)有限公司 虚拟试衣及试衣模型训练的方法、装置和设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
YING ZHANG, LIU CHENGXIA: "Research progress on the application of generative adversarial network in virtual fitting", JOURNAL OF SILK, vol. 58, no. 12, 24 November 2021 (2021-11-24), pages 63 - 72, XP093190772 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN119398865A (zh) * 2024-10-16 2025-02-07 杭州电子科技大学 一种基于时序增强扩散模型的视频虚拟试衣方法
CN120707754A (zh) * 2025-08-26 2025-09-26 苏州大学 一种服装合体性预测方法
CN121482212A (zh) * 2026-01-06 2026-02-06 贵州大学 一种层级上下文迭代与密集融合的精炼虚拟试衣系统

Also Published As

Publication number Publication date
CN115994994A (zh) 2023-04-21

Similar Documents

Publication Publication Date Title
WO2024149294A1 (zh) 虚拟试衣及试衣模型训练的方法、装置和设备
Black et al. Bedlam: A synthetic dataset of bodies exhibiting detailed lifelike animated motion
EP3972239B1 (en) Method and apparatus for virtual fitting
Liu et al. Psgan++: Robust detail-preserving makeup transfer and removal
US12462516B2 (en) Methods of estimating a bare body shape from a concealed scan of the body
CN110096156A (zh) 基于2d图像的虚拟换装方法
CN114926324B (zh) 基于真实人物图像的虚拟试衣模型训练方法、虚拟试衣方法、装置及设备
CN110263768A (zh) 一种基于深度残差网络的人脸识别方法
Xie et al. Was-vton: Warping architecture search for virtual try-on network
CN115147508B (zh) 服饰生成模型的训练、生成服饰图像的方法和装置
CN114820907B (zh) 人脸图像卡通化处理方法、装置、计算机设备和存储介质
Kubo et al. Uvton: Uv mapping to consider the 3d structure of a human in image-based virtual try-on network
CN114004772A (zh) 图像处理方法、图像合成模型的确定方法、系统及设备
CN113283953B (zh) 一种虚拟试衣方法、装置、设备及存储介质
CN117670695A (zh) 一种用于改善遮挡问题的循环外观流虚拟试衣方法
CN116452601A (zh) 虚拟试衣方法、装置、电子设备及存储介质
CN119809920A (zh) 一种基于扩散模型保持局部细节的虚拟试衣系统及方法
CN110838042B (zh) 一种商品展示方法及系统
Attallah et al. A cost-efficient approach for creating virtual fitting room using generative adversarial networks (gans)
CN119672591A (zh) 虚拟试穿视频生成方法、模型训练方法及电子设备
CN112884638B (zh) 虚拟试衣方法及装置
CN118052964A (zh) 基于虚拟对象穿戴的数据处理方法及装置、设备、介质
Sun et al. A digital simulation and Re-Editing method for clothing patterns based on deep learning and somatosensory interaction
Jiang et al. Self-supervised feature matched virtual try-on
Yanda et al. DL-VTON: An Image-Based Virtual Try-On Framework Using Deep Learning Models

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 24741291

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 24741291

Country of ref document: EP

Kind code of ref document: A1