Image processing method, device and computer readable storage medium
By acquiring the user's pose angle and inputting it into the image generation model, the target face image is generated using a generator network and a discriminator network. This solves the problems of image fixation and low quality in existing technologies, achieves image generation that better meets user needs, and improves the diversity and quality of image processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GUANGZHOU SHIYUAN ELECTRONICS CO LTD
- Filing Date
- 2021-12-14
- Publication Date
- 2026-05-22
Smart Images

Figure CN116263938B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to an image processing method, apparatus, and computer-readable storage medium. Background Technology
[0002] Image processing is the act of using computers to process image information to meet human visual, psychological, or application needs. It is widely used in professional fields such as surveying, atmospheric science, astronomy, and graphic design.
[0003] However, the images obtained by unsupervised training are too fixed, which cannot meet the diverse needs of users, and the quality of the images is not high. Summary of the Invention
[0004] This application provides an image processing method, apparatus, and computer-readable storage medium, the technical solutions of which are as follows:
[0005] In a first aspect, embodiments of this application provide an image processing method, the method comprising:
[0006] Obtain the first attitude angle;
[0007] Determine the target vector corresponding to the first attitude angle;
[0008] The first pose angle and the target vector are input into the image generation model to obtain the target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and the sample pose angles corresponding to each of the multiple random vectors.
[0009] In one alternative to the first aspect, determining the target vector corresponding to the first attitude angle includes:
[0010] Determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles;
[0011] When the first attitude angle matches any sample attitude angle, the second random vector is collected.
[0012] The second random vector is used as the target vector corresponding to the first attitude angle.
[0013] In another alternative to the first aspect, after calculating the similarity between the first attitude angle and multiple sample attitude angles, the method further includes:
[0014] When the first attitude angle is inconsistent with any sample attitude angle, the first attitude angle is subjected to a first transformation process to obtain a second attitude angle that satisfies the first preset condition.
[0015] The target vector corresponding to the first attitude angle is determined based on the second attitude angle.
[0016] In another alternative to the first aspect, determining the target vector corresponding to the first attitude angle based on the second attitude angle includes:
[0017] The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle;
[0018] Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition;
[0019] The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle.
[0020] The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
[0021] In another alternative to the first aspect, determining the sample attitude angle that satisfies the first preset condition based on the second attitude angle includes:
[0022] Search for sample attitude angles that satisfy the first preset condition among the sample attitude angles corresponding to multiple random vectors;
[0023] The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that meet the first preset condition are taken as the sample attitude angles that meet the first preset condition.
[0024] In another alternative to the first aspect, the target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient, including:
[0025] Determine the average vector corresponding to the reference attitude angle;
[0026] The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
[0027] In another alternative to the first aspect, the first pose angle and the target vector are input into the image generation model to obtain the target face image, including:
[0028] The second pose angle and the target vector are input into the image generation model to obtain the initial face image;
[0029] The initial face image is subjected to a second transformation process to obtain the target face image; the second transformation process corresponds to the first transformation process.
[0030] In another alternative to the first aspect, the image generation model includes a first generation network and a second generation network;
[0031] The first generative network is used to generate random face images based on the input random vector and the sample pose angle;
[0032] The second generator network is trained based on sample images with known prediction values and normalized distance. The sample images include random face images and real face images. The random face images are input into the second generator network to obtain the first prediction value, and the real face images are input into the second generator network to obtain the second prediction value. The normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images.
[0033] The image generation model is used to train the first generation network based on the predicted values corresponding to random face images obtained by the second generation network, so that the trained first generation network, based on random vectors and sample pose angles, inputs the random face images obtained by the second generation network to obtain target prediction values belonging to a preset threshold range.
[0034] Secondly, embodiments of this application also provide an image processing apparatus, the apparatus comprising:
[0035] The acquisition module is used to acquire the first attitude angle;
[0036] The processing module is used to determine the target vector corresponding to the first attitude angle;
[0037] The generation module is used to input the first pose angle and the target vector into the image generation model to obtain the target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and the sample pose angles corresponding to each of the multiple random vectors.
[0038] In one alternative embodiment of the second aspect, the processing module specifically includes:
[0039] The judgment unit is used to determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles;
[0040] The first processing unit is used to collect a second random vector when the first attitude angle is consistent with any sample attitude angle.
[0041] The first determining unit is used to take the second random vector as the target vector corresponding to the first attitude angle.
[0042] In another alternative embodiment of the second aspect, the processing module further includes:
[0043] The second processing unit is used to perform a first transformation process on the first attitude angle when the first attitude angle is inconsistent with any sample attitude angle, so as to obtain a second attitude angle that satisfies the first preset condition.
[0044] The second determining unit is used to determine the target vector corresponding to the first attitude angle based on the second attitude angle.
[0045] In another alternative embodiment of the second aspect, the second determining unit is specifically used for:
[0046] The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle;
[0047] Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition;
[0048] The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle.
[0049] The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
[0050] In another alternative embodiment of the second aspect, the second determining unit is further configured to:
[0051] Search for sample attitude angles that satisfy the first preset condition among the sample attitude angles corresponding to multiple random vectors;
[0052] The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that meet the first preset condition are taken as the sample attitude angles that meet the first preset condition.
[0053] In another alternative embodiment of the second aspect, the second determining unit is further configured to:
[0054] Determine the average vector corresponding to the reference attitude angle;
[0055] The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
[0056] In another alternative solution to the second aspect, the generation module specifically includes:
[0057] The first generation unit is used to input the second pose angle and the target vector into the image generation model to obtain the initial face image;
[0058] The second generation unit is used to perform a second transformation process on the initial face image to obtain the target face image; the second transformation process corresponds to the first transformation process.
[0059] In another alternative of the second aspect, the image generation model includes a first generation network and a second generation network;
[0060] The first generative network is used to generate random face images based on the input random vector and the sample pose angle;
[0061] The second generator network is trained based on sample images with known prediction values and normalized distance. The sample images include random face images and real face images. The random face images are input into the second generator network to obtain the first prediction value, and the real face images are input into the second generator network to obtain the second prediction value. The normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images.
[0062] The image generation model is used to train the first generation network based on the predicted values corresponding to random face images obtained by the second generation network, so that the trained first generation network, based on random vectors and sample pose angles, inputs the random face images obtained by the second generation network to obtain target prediction values belonging to a preset threshold range.
[0063] Thirdly, embodiments of this application also provide an image processing apparatus, including a processor and a memory;
[0064] The processor is connected to the memory;
[0065] Memory, used to store executable program code;
[0066] The processor runs a program corresponding to the executable program code by reading the executable program code stored in the memory, so as to execute the image processing method provided by the first aspect of the embodiments of this application or any implementation thereof.
[0067] Fourthly, embodiments of this application provide a computer storage medium storing a computer program, which includes program instructions. When executed by a processor, the program instructions can implement the image processing method provided by the first aspect or any implementation thereof of the embodiments of this application.
[0068] In this embodiment, a first pose angle is first obtained, and a target vector corresponding to the first pose angle is determined. Then, the first pose angle and the target vector are input together into an image generation model to obtain a target face image with the pose angle of the first pose angle. By inputting the pose angle and the target vector corresponding to the pose angle into a trained image generation model, a target face image with a pose angle that meets the user's needs can be obtained, thereby providing the user with a more diversified image processing experience. Attached Figure Description
[0069] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0070] Figure 1 This is a schematic diagram of the architecture of an image processing system provided in an embodiment of this application;
[0071] Figure 2 A schematic flowchart of an image processing method provided in an embodiment of this application;
[0072] Figure 3 A flowchart illustrating an image generation model provided in an embodiment of this application;
[0073] Figure 4 A schematic flowchart illustrating another image processing method provided in an embodiment of this application;
[0074] Figure 5 A schematic flowchart illustrating another image processing method provided in an embodiment of this application;
[0075] Figure 6 This is a schematic diagram illustrating the effect of an image processing scene provided in an embodiment of this application;
[0076] Figure 7 This is a schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application;
[0077] Figure 8 This is a schematic diagram of the structure of another image processing device provided in an embodiment of this application. Detailed Implementation
[0078] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0079] The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0080] A common image generation model generates mostly frontal face images from input random vectors. These frontal face images can be those with a pose angle of 0. The coordinate system containing the pose angle can be, but is not limited to, a Cartesian coordinate system with the center of the face image as its origin. The X and Y axes of this Cartesian coordinate system are set in the plane containing the face image, and the Z axis is perpendicular to the plane containing the face image. The pose angle in this Cartesian coordinate system can include pose angles around the X-axis (also represented as pitch), around the Y-axis (also represented as yaw), and around the Z-axis (also represented as roll), specifically represented as (pitch, yaw, roll). It can be understood that a pose angle of 0 indicates that the pose angle of the face in the generated face image is 0 around the X-axis, 0 around the Y-axis, and 0 around the Z-axis, specifically represented as (0, 0, 0).
[0081] It's also understandable that common image generation models may include a generator network and a discriminator network. The generator network generates random face images based on input random vectors, while the discriminator network is trained on sample images with known prediction values. The sample images include random face images and real face images. Random face images are input to the discriminator network to obtain a first prediction value, and real face images are input to the discriminator network to obtain a second prediction value. This image generation model trains the generator network based on the prediction values corresponding to random face images obtained by the discriminator network. This allows the trained generator network to obtain target prediction values within a preset threshold range when inputting random face images generated from random vectors into the discriminator network. It should be noted that the network structure of the image generation model mentioned here is a relatively mainstream network structure, such as, but not limited to, ResNet, ShuffleNet, and MobileNet, which will not be elaborated upon further here.
[0082] However, since the facial images presented to users in different scenarios are not frontal faces, such as facial images with large pose angles that frequently appear in fitness scenarios, the frontal face images obtained by the image generation model mentioned above cannot meet the user's need to match the current facial pose angle, thus affecting the user's image processing experience.
[0083] In summary, please refer to Figure 1 , Figure 1 A schematic diagram of the architecture of an image processing system provided in an embodiment of this application is shown.
[0084] like Figure 1 As shown, the image processing system may include at least a mobile terminal 101 and a server 102, wherein:
[0085] Mobile terminal 101 can be used to acquire a first attitude angle and send the first attitude angle to server 102 corresponding to mobile terminal 101, so that server 102 can determine the target vector corresponding to the first attitude angle after receiving the first attitude angle. The first attitude angle can be an attitude angle that meets the user's facial angle requirements, specifically including the attitude angles of the face rotating around the X-axis, Y-axis, and Z-axis in a Cartesian coordinate system, which can be represented as (pitch, yaw, roll). Possibly, mobile terminal 101 can determine the first attitude angle based on the facial angle directly input by the user. For example, the display interface of mobile terminal 101 can be a prompt interface prompting the user to input an attitude angle. This prompt interface may include input boxes for inputting the attitude angle rotating around the X-axis, the Y-axis, and the Z-axis, respectively. The user can input the required angle in each input box, and the angle input in each input box can be, but is not limited to, between -90 degrees and 90 degrees. Understandably, to make it easier for users to select the pose angle, when a user enters an angle in each input box, the mobile terminal 101 can simultaneously display a face image corresponding to the input angle below that input box.
[0086] Possibly, the mobile terminal 101 can first acquire a facial image including the user's face, and then extract the user's current pose angle from the facial image based on a pose angle extraction algorithm, using this current pose angle as the first pose angle. For example, the mobile terminal 101 can acquire the user's current facial image through a camera, extract the current facial pose angle from the current facial image based on a preset pose angle extraction algorithm, and use the extracted facial pose angle as the user's first pose angle. It is understood that the pose angle extraction algorithm mentioned here can be a common natural language processing algorithm, which will not be elaborated upon here.
[0087] The mobile terminal 101 involved in this application embodiment may be a smartphone, tablet computer, desktop computer, laptop computer, notebook computer, ultra-mobile personal computer (UMPC), handheld computer, PC device, personal digital assistant (PDA), router device, virtual reality device, etc.
[0088] After receiving a user's first pose angle, server 102 can determine the target vector corresponding to that first pose angle. The method by which server 102 determines the target vector corresponding to the first pose angle can be, but is not limited to, matching the first pose angle with a plurality of preset sample pose angles, and determining the corresponding target vector based on the matching result of the first pose angle with each sample pose angle. It is understood that the plurality of preset sample pose angles can be determined based on a plurality of sample face images stored by server 102. These plurality of sample face images can be, but are not limited to, obtained based on the current user's scene. For example, when the user is in a fitness exercise scene, the plurality of sample face images can be face images from different fitness scenes, and the face images can cover various face rotation angles, various skin tones, various age groups, and various lighting environments. After server 102 acquires the plurality of sample face images, it can first extract the face region from the plurality of sample face images based on a face detection algorithm, and then extract the plurality of sample pose angles from the face region based on a pose angle extraction algorithm to ensure the accuracy of the extracted face pose angles.
[0089] It should also be noted that since server 102 needs to acquire a large number of sample face images, the same sample pose angle may correspond to one sample face image or multiple different sample face images. That is to say, each sample pose angle corresponds to a frequency of occurrence among all sample pose angles. For example, a sample pose angle that can be represented as (30, 30, 60) can be extracted from three different sample face images, and the frequency of occurrence of this sample pose angle among all sample pose angles can be represented as 3 times.
[0090] Furthermore, after determining the target vector corresponding to the first pose angle, server 102 can input the first pose angle and the target vector into a trained image generation model to obtain a target face image with the first pose angle. This allows for the generation of corresponding face images based on different pose angle requirements of the user, thus satisfying the user's image processing experience. This image generation model differs from the aforementioned image generation model that generates random face images based on input vectors. In this embodiment, the image generation model includes a generation network and a discriminator network. The generation network generates random face images based on input random vectors and sample pose angles, while the discriminator network is trained based on sample images with known prediction values and a normalized distance. The sample images include random face images and real face images. The random face image is input into the discriminator network to obtain a first prediction value, and the real face image is input into the discriminator network to obtain a second prediction value. The normalized distance is obtained based on the sample pose angles input into the generation network and the pose angles of the random face images. This image generation model is used to train the generation network based on the predicted values corresponding to random face images obtained by the discriminant network. The trained generation network is then input into the discriminant network based on random face images obtained by random vectors and sample pose angles to obtain target prediction values belonging to a preset threshold range.
[0091] The server 102 involved in this application embodiment is specifically, but not limited to, a hardware server, a virtual server, a cloud server, etc., and may also be a terminal, specifically, but not limited to, a desktop, laptop, notebook computer, ultra-mobile personal computer (UMPC), handheld computer, netbook, personal digital assistant (PDA), routing device, gateway device, etc.
[0092] It should also be noted that the image processing system mentioned above is not limited to being executed jointly by the mobile terminal 101 and the server 102. For example, it can also be executed by the mobile terminal 101 or the server 102 alone. This embodiment is not limited to this.
[0093] Next, this application will explain and describe several embodiments of the image processing method.
[0094] Please see Figure 2 , Figure 2 A schematic flowchart of an image processing method provided in an embodiment of this application is shown.
[0095] like Figure 2 As shown, the image processing method may include at least the following steps:
[0096] Step 202: Obtain the first attitude angle.
[0097] Specifically, when processing the image, a first pose angle that meets the user's requirements can be obtained first. This first pose angle can be obtained based on user operation; for example, the user can determine the first pose angle by manually selecting or inputting it on a designated interface. Alternatively, the first pose angle can also be obtained based on an image including the user's face. For example, an image including the user's face can be acquired using a camera or other imaging device, and the user's face can be extracted from this image first, then the pose angle of the user's face can be extracted from the user's face using a pose angle extraction algorithm.
[0098] It is understood that the aforementioned first pose angle that meets user needs may specifically include pose angles rotating around the X-axis, Y-axis, and Z-axis in a spatial Cartesian coordinate system, for example, but not limited to, (pitch, yaw, roll). This spatial Cartesian coordinate system can be established based on a frontal face image with a pose angle of 0. The origin of this spatial Cartesian coordinate system can be set at the center of the face in the frontal face image. The X-axis and Y-axis of this spatial Cartesian coordinate system can be set in the plane containing the frontal face image, and the Z-axis can be set in a plane perpendicular to the plane containing the frontal face image. To avoid the obtained first pose angle being too large, the range of the obtained first pose angle can be, but is not limited to, between -90 degrees and 90 degrees.
[0099] Step 204: Determine the target vector corresponding to the first attitude angle.
[0100] Specifically, after obtaining the first attitude angle that meets the user's requirements, a target vector corresponding to the first attitude angle can be determined based on the first attitude angle. The method for determining the target vector corresponding to the first attitude angle can be, but is not limited to, matching the first attitude angle with a preset set of sample attitude angles and determining the target vector corresponding to the first attitude angle based on the matching result. For example, if the matching result between the first attitude angle and the preset set of sample attitude angles is a first result, then the vector matched with the first result can be used as the target vector corresponding to the first attitude angle. If the matching result between the first attitude angle and the preset set of sample attitude angles is a second result, then the vector matched with the second result can be used as the target vector corresponding to the first attitude angle.
[0101] Understandably, the preset multiple sample pose angles can be determined based on multiple stored sample face images. These sample face images can be, but are not limited to, those obtained based on the current user's scenario. For example, when a user is in a fitness activity, the multiple sample face images can be face images from different fitness scenarios, and the face images can cover various face rotation angles, skin tones, age groups, and lighting environments. After acquiring the multiple sample face images, face regions can be extracted from these multiple sample face images using a face detection algorithm, and then multiple sample pose angles can be extracted from these face regions using a pose angle extraction algorithm to ensure the accuracy of the extracted face pose angles.
[0102] Step 206: Input the first pose angle and the target vector into the image generation model to obtain the target face image.
[0103] Specifically, after determining the target vector corresponding to the first pose angle, the first pose angle and the target vector can be input together into the trained image generation model to obtain a target face image with the pose angle of the first pose angle. The image generation model can be trained using multiple first random vectors and sample pose angles corresponding to each of the multiple first random vectors. The multiple first random vectors can be random vectors that satisfy a normal distribution, and the sample pose angles corresponding to each of the multiple first random vectors can be the preset multiple sample pose angles mentioned in step 204 above. These sample pose angles can have a one-to-one correspondence with the first random vectors, meaning that one random vector can correspond to one sample pose angle.
[0104] In this embodiment, by inputting the pose angle and the target vector corresponding to the pose angle into the trained image generation model, a target face image with pose angles that meet the user's needs can be obtained, thereby bringing the user a more diversified image processing experience.
[0105] As an optional embodiment, the image generation model includes a first generation network and a second generation network;
[0106] The first generative network is used to generate random face images based on the input random vector and the sample pose angle;
[0107] The second generator network is trained based on sample images with known prediction values and normalized distance. The sample images include random face images and real face images. The random face images are input into the second generator network to obtain the first prediction value, and the real face images are input into the second generator network to obtain the second prediction value. The normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images.
[0108] The image generation model is used to train the first generation network based on the predicted values corresponding to random face images obtained by the second generation network, so that the trained first generation network, based on random vectors and sample pose angles, inputs the random face images obtained by the second generation network to obtain target prediction values belonging to a preset threshold range.
[0109] See here. Figure 3 The illustration shows a flowchart of an image generation model provided in an embodiment of this application. Figure 3 As shown, the image generation model may include a first generation network and a second generation network, wherein:
[0110] The first generative network can be considered an image generation network used to generate random face images with specified pose angles based on an input random vector and a specified pose angle vector. The random vector can be, but is not limited to, one or more random vectors following a normal distribution. Each random vector input to the first generative network produces a different random face image, but when the same pose angle is input, the face pose angles in the corresponding random face images remain consistent. This can be understood as each random vector corresponding to a sample pose angle, facilitating training the first generative network by inputting random vectors and their corresponding sample pose angles.
[0111] The second generator network can be considered an image discrimination network, used to obtain a predicted value representing whether a face image belongs to a real image based on the input sample image. Specifically, when the input sample image is a random face image obtained based on the first generator network, the output of the second generator network can represent a first predicted value indicating that it does not belong to a real face image; this is, for example, but not limited to, a first predicted value of 0. It is understood that the random face image is obtained by the first generator network based on the input random vector and the sample pose angle. The face pose angle in this random face image differs from the sample pose angle if the first generator network is not properly trained. When the input sample image is a collected sample face image, the output of the second generator network can represent a second predicted value indicating that it belongs to a real face image; this is, for example, but not limited to, a second predicted value of 1. That is, when the predicted value obtained by the second generator network based on the input face image approaches or equals 0.5, it indicates that the second generator network cannot determine whether the input face image is a real face image. To improve the training performance of the second generative network, the pose angle of the face in the sample face image can be determined before the input sample image is the collected sample face image. The sample face image with the same pose angle as the sample pose angle input to the first generative network can be selected and input into the second generative network for training.
[0112] During the training of an image generation model, since a second generator network (i.e., a discriminator network) is included, its training optimization process can be understood as finding a Nash balance between the first and second generator networks. In other words, the purpose of training the first generator network is to enable it to generate a random face image with a pose angle consistent with the input random vector and the sample pose angle. The purpose of training the second generator network is to enable it to generate a prediction value based on the input random face image obtained by the first generator network. This prediction value is used to characterize whether an input face image is a real face image. The entire training process can be understood as the alternating iterative training of the first and second generator networks.
[0113] Specifically, when training the image generation model, multiple real sample face images can be set first. For each sample face image, a pose angle extraction algorithm is used to extract its corresponding face pose angle α, and the expected number of iteration steps (or training steps) is set. The extracted face pose angle α can specifically include pose angles rotating around the X-axis, around the Y-axis, and around the Z-axis, for example, but not limited to, (pitch, yaw, roll). Furthermore, pose angles belonging to a preset interval can be selected from the extracted face pose angles α, which can be set to between -90 degrees and 90 degrees. Then, a Gaussian distribution z ~ N(0,1) can be used. Z A random vector z (which can also be a noise vector) is randomly sampled, with the same number of sample face images as the number of sample face images. Each random vector z is then mapped one-to-one with the face pose angle α of each sample face image. The corresponding random vector z and face pose angle α are then input into the first generator network to obtain random face images. It can be understood that the pose angle can also be extracted from the obtained random face images based on the pose angle extraction algorithm mentioned above. And this attitude angle The face pose angle α corresponding to the input to the first generator network is different when the first generator network is not properly trained.
[0114] Furthermore, the random face image obtained based on the first generator network can be input into the second generator network to obtain a first predicted value, and a first prediction function can be constructed based on the first predicted value, which can be, but is not limited to, represented as S. f Next, the aforementioned real sample face images are input into the second generative network to obtain a second predicted value. A second prediction function can then be constructed based on this second predicted value, which can, but is not limited to, be represented as S. tNext, to ensure that the first generator network, after training, obtains a face pose angle that is more consistent with the input pose angle, it can be based on the face pose angle α input to the first generator network and the pose angle extracted from the random face image. Construct a distance function, which can be expressed as S p The distance function can be calculated as the ratio of the face pose angle α input to the first generator network to the pose angle extracted from the random face image. The distance between two points in a spatial rectangular coordinate system corresponds to the distance between the two points. To ensure the consistency of the constructed function, the distance between the two points in the spatial rectangular coordinate system can be normalized, resulting in the distance function expression shown in formula (1) below:
[0115]
[0116] It should be noted that, in order to achieve more accurate training results, the face pose angle α input to the first generator network is compared with the pose angle in the random face image. This can be considered a correspondence, meaning that a random face image can be obtained by the first generator network based on the input face pose angle α, and the pose angle extracted from this random face image is...
[0117] Furthermore, a second target function for the win path network can be constructed based on the first prediction function, the second construction function, and the distance function mentioned above. Its representation can be shown in the following formula (2):
[0118] L D ←log(s t )+log(1-s f )+log(1-s p (2)
[0119] Here, the objective function of the second generative network can be iteratively trained using gradient descent to make L D The algorithm approaches its maximum value and optimizes the parameters of the second generator network during the iteration process.
[0120] Furthermore, after optimizing the parameters of the second generator network, the first generator network can be based on the first prediction function S corresponding to the first predicted value. f The objective function of the first generator network is constructed, and its form can be expressed as shown in formula (3):
[0121] L G ←log(s f (3)
[0122] Here, the objective function of the first generator network can be iteratively trained using gradient descent to make L GThe algorithm approaches its maximum value and optimizes the parameters of the first generator network during the iteration process.
[0123] It should be noted that when the prediction value obtained by inputting the random face image obtained by the first generation network into the second generation network is 0.5 or close to 0.5, it indicates that the second generation network cannot distinguish the authenticity of the input random face image, and it can be determined that the training of the second image generation model is complete.
[0124] Please see Figure 4 , Figure 4 A flowchart illustrating another image processing method provided in an embodiment of this application is shown.
[0125] like Figure 4 As shown, the image processing method may include at least the following steps:
[0126] Step 402: Obtain the first attitude angle.
[0127] Specifically, step 402 is the same as step 202, and will not be elaborated on here.
[0128] Step 404: Determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles.
[0129] Specifically, after determining the first pose angle, this first pose angle can be compared with multiple sample pose angles used to train the image generation model to determine whether the first pose angle is consistent with any one of the multiple sample pose angles. It can be understood that the trained image generation model can obtain a higher-quality random face image based on any one of the multiple input sample pose angles. Therefore, a higher-quality target face image can be obtained by determining whether the first pose angle is any one of the multiple sample pose angles. It should be noted that the method for determining whether the first attitude angle is consistent with any one of the multiple sample attitude angles can be to determine whether all the attitude angles included in the first attitude angle correspond to all the attitude angles included in any one of the multiple sample attitude angles. For example, if the first attitude angle can be represented as (p1, y1, r1) and any one of the multiple sample attitude angles can be represented as (p2, y2, r2), we can determine whether p1 is equal to p2, whether y1 is equal to y2, and whether r1 is equal to r2. Only when p1 is equal to p2, y1 is equal to y2, and r1 is equal to r2 can it be determined whether the first attitude angle is consistent with any one of the multiple sample attitude angles.
[0130] Step 406: When the first attitude angle is consistent with any sample attitude angle, collect the second random vector.
[0131] Specifically, when the first pose angle is detected to be the same as any sample pose angle, it indicates that the trained image generation model can obtain a higher quality random face image based on the input first pose angle and the second random vector. The face pose angle in this random face image can be the same as the first pose angle. It can be understood that the second random vector here can be different from the first random vector used to train the image generation model, and it can be randomly sampled from vectors that satisfy a normal distribution.
[0132] Of course, since the first pose angle is consistent with any sample pose angle, each sample pose angle can correspond to a random vector during the training of the image generation model. Based on this, the first random vector corresponding to the sample pose angle that is consistent with the first pose angle can also be used as the second random vector. This application is not limited to this.
[0133] Step 408: Use the second random vector as the target vector corresponding to the first attitude angle.
[0134] Specifically, after obtaining the second random vector, the second random vector can be used as the target vector corresponding to the first pose angle, thereby ensuring that the obtained target face image better meets the user's pose angle requirements.
[0135] Step 410: Input the first pose angle and the target vector into the image generation model to obtain the target face image.
[0136] Specifically, step 410 is the same as step 206, so I will not go into details here.
[0137] In this embodiment of the application, when the first pose angle is consistent with any sample pose angle, a higher quality target face image can be obtained directly based on the collected random vector and the first pose angle, which not only meets the user's pose angle requirements, but also improves image processing efficiency.
[0138] Please see Figure 5 , Figure 5 A flowchart illustrating another image processing method provided in an embodiment of this application is shown.
[0139] like Figure 5 As shown, the image processing method may include at least the following steps:
[0140] Step 502: Obtain the first attitude angle.
[0141] Specifically, step 502 is the same as steps 402 and 202, and will not be elaborated further here.
[0142] Step 504: Determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles.
[0143] Specifically, step 504 is the same as step 404, so I will not go into details here.
[0144] Step 506: When the first attitude angle is inconsistent with any sample attitude angle, perform a first transformation process on the first attitude angle to obtain a second attitude angle that satisfies the first preset condition.
[0145] Specifically, when the first pose angle is detected to be different from any sample pose angle, it indicates that the trained image generation model cannot guarantee that the face pose angle in the face image obtained based on the first pose angle is identical to the first pose angle. Since the image generation model can have the characteristics of the highest average face sharpness and the decoupling characteristics of latent space features, the first pose angle can be first transformed to obtain the second pose angle that meets the first preset condition, thereby simplifying the interpolation process and reducing the processing difficulty of generating the average face.
[0146] The first preset condition can be that the angle of any one of the first attitude angles is 0. Based on this, the first conversion process for the first attitude angle can be to convert the angle of any one of the first attitude angles to 0, so as to obtain a second attitude angle that satisfies the first preset condition. Here, taking the first attitude angle as (p1, y1, r1) as an example, the second attitude angle obtained by performing the first conversion process on the first attitude angle can be, but is not limited to, expressed as (p1, 0, r1), (p1, y1, 0), or (0, y1, r1). Preferably, the angle of the attitude angle rotating around the Z-axis in the first attitude angle can be converted to 0, that is, the second attitude angle corresponding to the above-mentioned second attitude angle that can be expressed as (p1, y1, 0), so as to obtain the target face image with the same attitude angle as the first attitude angle more quickly and accurately.
[0147] It is understood that, in the embodiments of this application, the first preset condition may also be that the angles of any two attitude angles in the first attitude angle are 0. Based on this, the first conversion process of the first attitude angle may be to convert the angles of any two attitude angles in the first attitude angle to 0, so as to obtain a second attitude angle that satisfies the first preset condition. Here, taking the first attitude angle as (p1, y1, r1) as an example, the second attitude angle obtained by performing the first conversion process on the first attitude angle may, but is not limited to, be represented as (p1, 0, 0), (0, y1, 0), or (0, 0, r1).
[0148] Step 508: Determine the target vector corresponding to the first attitude angle based on the second attitude angle.
[0149] Specifically, after performing a first transformation on the first pose angle to obtain a second pose angle, a corresponding target vector can be determined based on the second pose angle. Since this target vector is determined based on the transformed second pose angle, the input to the trained image generation model can be this second pose angle and the corresponding target vector. It can be understood that the target vector here can be determined by multiple random vectors used to train the image generation model to ensure the accuracy of the target face image.
[0150] Step 510: Input the second pose angle and the target vector into the image generation model to obtain the initial face image.
[0151] Specifically, the second pose angle and the target vector can be input into the trained image generation model to obtain an initial face image with the pose angle of the second pose angle. The initial face image obtained here can ensure the accuracy of the face pose angle being the second pose angle. Then, by processing the initial face image, a more accurate target face image can be obtained.
[0152] Step 512: Perform a second transformation on the initial face image to obtain the target face image.
[0153] Specifically, after obtaining an initial face image with a second pose angle, a second transformation process corresponding to the first transformation process can be performed on the initial face image to make the face pose angle in the processed face image meet the user's requirements for a first pose angle. The first transformation process can be to convert any pose angle in the first pose angle to 0, and the second transformation process can be to convert the pose angle with an angle of 0 in the initial face image to the corresponding pose angle in the first pose angle. Taking the first pose angle as (p1, y1, r1) as an example, the second pose angle can be represented as (p1, y1, 0), meaning the first transformation process can be to convert the pose angle rotating around the Z-axis to 0. By inputting the second pose angle and the target vector into the trained image generation model, an initial face image with a pose angle of (p1, y1, 0) is obtained, and the initial face image can be subjected to the second transformation process, which can be to convert the pose angle rotating around the Z-axis to r1, so that the pose angle in the processed initial face image is (p1, y1, r1).
[0154] It is understandable that the attitude angle (corresponding to roll) around the Z-axis can be directly converted by rotating the image. The second conversion process mentioned above can be to directly rotate the initial face image clockwise by the angle corresponding to r1 or counterclockwise by the angle corresponding to r1, so as to improve the efficiency and accuracy of image processing.
[0155] See here. Figure 6 The illustration shows an effect diagram of an image processing scene provided by an embodiment of this application. For example... Figure 6 As shown, Figure 6 In this context, 6a can be represented as the initial face image obtained by inputting the second pose angle and the target vector into the trained image processing model. The angle of rotation around the Z-axis in the face pose angle of this initial face image is 0. By rotating this initial face image clockwise around the image center by a certain angle, we can obtain... Figure 6 The target face image represented by 6b in the diagram, where a certain angle rotated clockwise around the center of the image is the angle of rotation around the Z-axis corresponding to the first transformation process.
[0156] In this embodiment of the application, when the first pose angle is inconsistent with any sample pose angle, the first pose angle can be first transformed to obtain the second pose angle, and then the face image obtained based on the second pose angle and the target vector can be transformed to the second transformation corresponding to the first transformation, so that the final face image can also ensure the accuracy of the pose angle, and at the same time improve the efficiency of image processing.
[0157] As an optional embodiment, determining the target vector corresponding to the first attitude angle based on the second attitude angle includes:
[0158] The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle;
[0159] Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition;
[0160] The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle.
[0161] The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
[0162] Specifically, after obtaining the processed second pose angle that satisfies the first preset condition, sample pose angles that satisfy the first preset condition can be selected from multiple sample pose angles used to train the image generation model. Here, taking the first transformation process as converting the pose angle angle rotating around the Z-axis in the first pose angle to 0 as an example, the first preset condition can be that the pose angle angle rotating around the Z-axis in the pose angle is equal to 0, and sample pose angles with the pose angle angle rotating around the Z-axis equal to 0 can be selected from multiple sample pose angles used to train the image generation model. That is to say, sample pose angles that can be represented as (p, y, 0) are selected, where p can correspond to any angle in the range of -90 degrees to 90 degrees, and y can also correspond to any angle in the range of -90 degrees to 90 degrees.
[0163] Furthermore, after determining the sample attitude angles that satisfy the first preset condition, the Euclidean distance between the second attitude angle and each sample attitude angle that satisfies the first preset condition in the coordinate system can be calculated. The Euclidean distance can be used to characterize the similarity between the second attitude angle and the corresponding sample attitude angle. A closer Euclidean distance indicates a higher similarity between the corresponding sample attitude angle and the second attitude angle, while a larger Euclidean distance indicates a lower similarity. It can be understood that the second attitude angle and the sample attitude angles that satisfy the first preset condition can be mapped to a spatial rectangular coordinate system. The attitude angle rotating around the X-axis can correspond to the coordinates on the X-axis of the spatial rectangular coordinate system, and the attitude angle rotating around the X-axis and its coordinates on the X-axis can be in a corresponding relationship; the attitude angle rotating around the Y-axis can correspond to the coordinates on the Y-axis of the spatial rectangular coordinate system, and the attitude angle rotating around the Y-axis and its coordinates on the Y-axis can be in a corresponding relationship; the attitude angle rotating around the Z-axis can correspond to the coordinates on the Z-axis of the spatial rectangular coordinate system, and the attitude angle rotating around the Z-axis and its coordinates on the Z-axis can be in a corresponding relationship. By calculating the Euclidean distance between the coordinates corresponding to the second attitude angle and the coordinates corresponding to each sample attitude angle that meets the first preset condition, the sample attitude angles that are more or less similar to the second attitude angle can be determined.
[0164] Furthermore, after calculating the Euclidean distance between the second attitude angle and each sample attitude angle that satisfies the first preset condition, the sample attitude angles whose Euclidean distance satisfies the second preset condition can be used as reference attitude angles. Here, the second preset condition can be at least two sample attitude angles with the smallest Euclidean distance; that is, when there are three reference attitude angles, the Euclidean distance between these three reference attitude angles and the second attitude angle is minimized. Of course, the second preset condition can also be, but is not limited to, an Euclidean distance lower than a preset distance threshold. In this case, the reference attitude angle can be one or more sample attitude angles with an Euclidean distance lower than the preset distance threshold. Next, after determining the reference attitude angles, reference coefficients for interpolation can be determined based on the second attitude angle and the reference attitude angles. It can be understood that, in conjunction with the aforementioned spatial rectangular coordinate system, the second attitude angle and the reference attitude angle can first be converted to their corresponding coordinates in the spatial rectangular coordinate system, and then the reference coefficients can be obtained through interpolation calculations. Here, taking the coordinates of the second attitude angle in the spatial rectangular coordinate system as (x1, y1, z1) and the coordinates of the reference attitude angle in the spatial rectangular coordinate system as (x2, y2, z2), (x3, y3, z3), and (x4, y4, z4) respectively as examples, the reference coefficient can be calculated by the following formulas (4), (5), and (6):
[0165] x1=u*x2+v*x3+w*x4 (4)
[0166] y1=u*y2+v*y3+w*y4 (5)
[0167] z1=u*z2+v*z3+w*z4 (6)
[0168] Where u, v, and w are reference coefficients to be calculated, and their calculation process can be solved by conventional equation solving, which will not be elaborated here.
[0169] Furthermore, after calculating the reference coefficients based on the second attitude angle and the reference attitude angle, the target vector can be obtained from these reference coefficients and the vectors corresponding to the reference attitude angles. The vectors corresponding to the reference attitude angles can be, but are not limited to, the random vectors corresponding to the reference attitude angles in the training samples used to train the image generation model, as mentioned above. When a reference attitude angle corresponds to one random vector, the vector corresponding to the reference attitude angle can be any random vector in the training samples. When a reference attitude angle corresponds to multiple random vectors, the average of these multiple random vectors can be selected as the vector corresponding to the reference attitude angle.
[0170] It should be noted that the vectors corresponding to the aforementioned reference attitude angles are all different; that is, each reference attitude angle can correspond to a vector.
[0171] In this embodiment, the reference vector most similar to the pose angle can be determined by calculating the Euclidean distance. Then, the target vector corresponding to the pose angle can be determined based on the reference vector and the decoupling characteristics of the latent space features. This enables the image generation model to output a higher quality target face image based on the pose angle that does not appear in the sample pose angle.
[0172] As another option in this embodiment, determining the sample attitude angle that satisfies the first preset condition based on the second attitude angle includes:
[0173] Search for sample attitude angles that satisfy the first preset condition among the sample attitude angles corresponding to multiple random vectors;
[0174] The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that meet the first preset condition are taken as the sample attitude angles that meet the first preset condition.
[0175] Specifically, after selecting sample pose angles that meet the first preset condition from multiple sample pose angles used to train the image generation model, the sample pose angles that meet the first preset condition can be statistically analyzed, and the sample pose angles whose frequency of occurrence meets a preset threshold can be used as the final sample pose angles that meet the first preset condition. It can be understood that, since the number of sample pose angles used to train the image generation model is large and repetitive, for sample pose angles with high repetition, a more accurate random face image can be obtained based on the trained image generation model. Therefore, after initially selecting sample pose angles that meet the first preset condition, the frequency of occurrence of each sample pose angle can be statistically analyzed, and the sample pose angles whose frequency of occurrence reaches a preset threshold can be used as the final sample pose angles that meet the first preset condition, thereby improving the accuracy of face pose angles in the target face image.
[0176] As another option in this embodiment, determining the target vector corresponding to the first attitude angle based on the reference attitude angle and the reference coefficient includes:
[0177] Determine the average vector corresponding to the reference attitude angle;
[0178] The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
[0179] Specifically, after determining the reference pose angle, the average vector corresponding to that reference pose angle can be calculated first. Each reference pose angle may correspond to one or more random vectors in the training samples of the image generation model. It is possible, but not limited to, when a reference pose angle corresponds to only one random vector, to first determine multiple sample pose angles whose Euclidean distance in a Cartesian coordinate system satisfies a preset distance threshold, and then calculate the random vectors corresponding to each of these sample pose angles, as well as the average vector of the random vectors corresponding to the reference pose angle, to ensure a higher quality target face image with better identity consistency. It can be understood that the multiple sample pose angles satisfying the preset distance threshold can be the multiple sample pose angles most similar to the reference pose angle, or the coordinates of the multiple sample pose angles satisfying the preset distance threshold in the coordinate system are closest to the coordinates of the reference pose angle in the coordinate system.
[0180] It is possible, when a reference attitude angle corresponds to multiple random vectors, to calculate, but not limited to, the average vector of these multiple random vectors, and to use this average vector as the vector corresponding to the reference attitude angle. Of course, in this embodiment, it is also possible to first determine multiple sample attitude angles whose Euclidean distance in a Cartesian coordinate system satisfies a preset distance threshold, then calculate the random vectors corresponding to each of the multiple sample attitude angles and the average vector of the random vectors corresponding to each of the multiple random vectors, and then calculate the average vector of the average vector corresponding to each random vector, which is not limited to this.
[0181] Furthermore, after determining the average vector corresponding to the reference attitude angle, the target vector corresponding to the first attitude angle can be calculated based on the reference coefficients. Here, the reference vectors are represented as Q2, Q3, and Q4 respectively. Taking u, v, and w mentioned above as examples, the target vector can be obtained through the following formula (7):
[0182] Q1=u*Q2+v*Q3+w*Q4 (7)
[0183] The reference coefficient can be determined by the second attitude angle and the reference attitude angle mentioned above.
[0184] Please see Figure 7 , Figure 7 A schematic diagram of the structure of an image processing apparatus provided in an embodiment of this application is shown.
[0185] like Figure 7 As shown, the image processing apparatus may include at least an acquisition module 701, a processing module 702, and a generation module 703, wherein:
[0186] The acquisition module 701 is used to acquire the first attitude angle;
[0187] Processing module 702 is used to determine the target vector corresponding to the first attitude angle;
[0188] The generation module 703 is used to input the first pose angle and the target vector into the image generation model to obtain the target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and the sample pose angles corresponding to each of the multiple random vectors.
[0189] In some possible embodiments, the processing module 702 specifically includes:
[0190] The judgment unit is used to determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles;
[0191] The first processing unit is used to collect a second random vector when the first attitude angle is consistent with any sample attitude angle.
[0192] The first determining unit is used to take the second random vector as the target vector corresponding to the first attitude angle.
[0193] In some possible embodiments, the processing module 702 further includes:
[0194] The second processing unit is used to perform a first transformation process on the first attitude angle when the first attitude angle is inconsistent with any sample attitude angle, so as to obtain a second attitude angle that satisfies the first preset condition.
[0195] The second determining unit is used to determine the target vector corresponding to the first attitude angle based on the second attitude angle.
[0196] In some possible embodiments, the second determining unit is specifically used for:
[0197] The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle;
[0198] Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition;
[0199] The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle.
[0200] The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
[0201] In some possible embodiments, the second determining unit is further configured to:
[0202] Search for sample attitude angles that satisfy the first preset condition among the sample attitude angles corresponding to multiple random vectors;
[0203] The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that meet the first preset condition are taken as the sample attitude angles that meet the first preset condition.
[0204] In some possible embodiments, the second determining unit is further configured to:
[0205] Determine the average vector corresponding to the reference attitude angle;
[0206] The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
[0207] In some possible embodiments, the generation module 703 specifically includes:
[0208] The first generation unit is used to input the second pose angle and the target vector into the image generation model to obtain the initial face image;
[0209] The second generation unit is used to perform a second transformation process on the initial face image to obtain the target face image; the second transformation process corresponds to the first transformation process.
[0210] In some possible embodiments, the image generation model includes a first generation network and a second generation network;
[0211] The first generative network is used to generate random face images based on the input random vector and the sample pose angle;
[0212] The second generator network is trained based on sample images with known prediction values and normalized distance. The sample images include random face images and real face images. The random face images are input into the second generator network to obtain the first prediction value, and the real face images are input into the second generator network to obtain the second prediction value. The normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images.
[0213] The image generation model is used to train the first generation network based on the predicted values corresponding to random face images obtained by the second generation network, so that the trained first generation network, based on random vectors and sample pose angles, inputs the random face images obtained by the second generation network to obtain target prediction values belonging to a preset threshold range.
[0214] Please see Figure 8 , Figure 8 A schematic diagram of the structure of another image processing apparatus provided in an embodiment of this application is shown.
[0215] like Figure 8 As shown, the image processing device 800 may include at least one processor 801, at least one network interface 804, a user interface 803, a memory 805, and at least one communication bus 802.
[0216] The communication bus 802 can be used to realize the connection and communication of the above components.
[0217] The user interface 803 may include buttons, and the optional user interface may also include a standard wired interface or a wireless interface.
[0218] The network interface 804 may include, but is not limited to, Bluetooth modules, NFC modules, Wi-Fi modules, etc.
[0219] The processor 801 may include one or more processing cores. The processor 801 connects to various parts within the electronic device 800 using various interfaces and lines. It executes instructions, programs, code sets, or instruction sets stored in the memory 805, and calls data stored in the memory 805 to perform various functions and process data within the routing device 800. Optionally, the processor 801 may be implemented using at least one hardware form of DSP, FPGA, or PLA. The processor 801 may integrate one or more of the following: CPU, GPU, and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 801 and may be implemented as a separate chip.
[0220] The memory 805 may include RAM or ROM. Optionally, the memory 805 may include a non-transitory computer-readable medium. The memory 805 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 805 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 805 may also be at least one storage device located remotely from the aforementioned processor 801. Figure 8 As shown, the memory 805, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an image processing application.
[0221] Specifically, the processor 801 can be used to call the image processing application stored in the memory 805 and perform the following operations:
[0222] Obtain the first attitude angle;
[0223] Determine the target vector corresponding to the first attitude angle;
[0224] The first pose angle and the target vector are input into the image generation model to obtain the target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and the sample pose angles corresponding to each of the multiple random vectors.
[0225] In some possible embodiments, when processor 801 determines the target vector corresponding to the first attitude angle, it specifically performs the following:
[0226] Determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles;
[0227] When the first attitude angle matches any sample attitude angle, the second random vector is collected.
[0228] The second random vector is used as the target vector corresponding to the first attitude angle.
[0229] In some possible embodiments, after calculating the similarity between the first attitude angle and multiple sample attitude angles, the processor 801 is further configured to perform:
[0230] When the first attitude angle is inconsistent with any sample attitude angle, the first attitude angle is subjected to a first transformation process to obtain a second attitude angle that satisfies the first preset condition.
[0231] The target vector corresponding to the first attitude angle is determined based on the second attitude angle.
[0232] In some possible embodiments, when processor 801 determines the target vector corresponding to the first attitude angle based on the second attitude angle, it specifically performs the following:
[0233] The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle;
[0234] Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition;
[0235] The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle.
[0236] The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
[0237] In some possible embodiments, when the processor 801 determines the sample attitude angle that satisfies the first preset condition based on the second attitude angle, it specifically executes:
[0238] Search for sample attitude angles that satisfy the first preset condition among the sample attitude angles corresponding to multiple random vectors;
[0239] The sample attitude angles that meet the first preset condition and whose frequency reaches a preset threshold are taken as the sample attitude angles that meet the first preset condition.
[0240] In some possible embodiments, when processor 801 determines the target vector corresponding to the first attitude angle based on the reference attitude angle and reference coefficients, it specifically executes:
[0241] Determine the average vector corresponding to the reference attitude angle;
[0242] The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
[0243] In some possible embodiments, when the processor 801 inputs the first pose angle and the target vector into the image generation model to obtain the target face image, it specifically executes:
[0244] The second pose angle and the target vector are input into the image generation model to obtain the initial face image;
[0245] The initial face image is subjected to a second transformation process to obtain the target face image; the second transformation process corresponds to the first transformation process.
[0246] In some possible embodiments, the image generation model includes a first generation network and a second generation network;
[0247] The first generative network is used to generate random face images based on the input random vector and the sample pose angle;
[0248] The second generator network is trained based on sample images with known prediction values and normalized distance. The sample images include random face images and real face images. The random face images are input into the second generator network to obtain the first prediction value, and the real face images are input into the second generator network to obtain the second prediction value. The normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images.
[0249] The image generation model is used to train the first generation network based on the predicted values corresponding to random face images obtained by the second generation network, so that the trained first generation network, based on random vectors and sample pose angles, inputs the random face images obtained by the second generation network to obtain target prediction values belonging to a preset threshold range.
[0250] This application also provides a computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the above-described instructions. Figure 2 or Figure 4 or Figure 5 One or more steps in the illustrated embodiment. If the constituent modules of the above-described electronic device are implemented as software functional units and sold or used as independent products, they can be stored in the computer-readable storage medium.
[0251] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially as 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, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., digital versatile discs (DVDs)), or semiconductor media (e.g., solid-state drives (SSDs)).
[0252] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks. Unless otherwise specified, the technical features of this embodiment and its implementation can be combined arbitrarily.
[0253] The embodiments described above are merely preferred embodiments of this application and are not intended to limit the scope of this application. Any modifications and improvements made by those skilled in the art to the technical solutions of this application without departing from the spirit of this application should fall within the protection scope defined by the claims of this application.
Claims
1. An image processing method, characterized in that, include: Obtain the first attitude angle; Determine the target vector corresponding to the first attitude angle; The first pose angle and the target vector are input into the image generation model to obtain the target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and sample pose angles corresponding to each of the multiple random vectors. Determining the target vector corresponding to the first attitude angle includes: Determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles; When the first attitude angle is consistent with any of the sample attitude angles, a second random vector is collected. The second random vector is randomly collected from vectors that satisfy a normal distribution, or the first random vector corresponding to the sample attitude angle that is consistent with the first attitude angle is used as the second random vector. The second random vector is used as the target vector corresponding to the first attitude angle.
2. The method according to claim 1, characterized in that, After determining whether the first attitude angle is consistent with any one of the plurality of sample attitude angles, the method further includes: When the first attitude angle is inconsistent with any of the sample attitude angles, the first attitude angle is subjected to a first transformation process to obtain a second attitude angle that satisfies the first preset condition. The target vector corresponding to the first attitude angle is determined based on the second attitude angle.
3. The method according to claim 2, characterized in that, The step of determining the target vector corresponding to the first attitude angle based on the second attitude angle includes: The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle; Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition; The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle. The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
4. The method according to claim 3, characterized in that, The step of determining the sample attitude angle that satisfies the first preset condition based on the second attitude angle includes: Find the sample attitude angle that satisfies the first preset condition among the sample attitude angles corresponding to each of the plurality of random vectors; The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that satisfy the first preset condition are taken as the sample attitude angles that satisfy the first preset condition.
5. The method according to claim 3, characterized in that, Determining the target vector corresponding to the first attitude angle based on the reference attitude angle and the reference coefficient includes: Determine the average vector corresponding to the reference attitude angle; The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
6. The method according to claim 2, characterized in that, The step of inputting the first pose angle and the target vector into the image generation model to obtain the target face image includes: The second pose angle and the target vector are input into the image generation model to obtain the initial face image; The initial face image is subjected to a second transformation process to obtain the target face image; the second transformation process corresponds to the first transformation process.
7. The method according to any one of claims 1-6, characterized in that, The image generation model includes a first generation network and a second generation network; The first generative network is used to generate random face images based on the input random vector and the sample pose angle; The second generator network is trained based on sample images with known prediction values and normalized distance; the sample images include the random face images and real face images, the random face images are input into the second generator network to obtain a first prediction value, and the real face images are input into the second generator network to obtain a second prediction value; the normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images; The image generation model is used to train the first generation network based on the predicted value corresponding to the random face image obtained by the second generation network, so that the trained first generation network is input into the second generation network based on the random vector and the sample pose angle to obtain the target predicted value belonging to the preset threshold range.
8. An image processing apparatus, characterized in that, include: The acquisition module is used to acquire the first attitude angle; The processing module is used to determine the target vector corresponding to the first attitude angle; The generation module is used to input the first pose angle and the target vector into the image generation model to obtain a target face image; the pose angle of the target face image is the first pose angle, and the image generation model is trained by multiple first random vectors and sample pose angles corresponding to each of the multiple random vectors. The processing module specifically includes: The judgment unit is used to determine whether the first attitude angle is consistent with any one of the multiple sample attitude angles; The first processing unit is configured to collect a second random vector when the first attitude angle is consistent with any of the sample attitude angles. The second random vector is randomly collected from vectors that satisfy a normal distribution, or the first random vector corresponding to the sample attitude angle that is consistent with the first attitude angle is used as the second random vector. The first determining unit is used to take the second random vector as the target vector corresponding to the first attitude angle.
9. The apparatus according to claim 8, characterized in that, The processing module further includes: The second processing unit is used to perform a first conversion process on the first attitude angle when the first attitude angle is inconsistent with any of the sample attitude angles, so as to obtain a second attitude angle that satisfies the first preset condition. The second determining unit is used to determine the target vector corresponding to the first attitude angle based on the second attitude angle.
10. The apparatus according to claim 9, characterized in that, The second determining unit is specifically used for: The sample attitude angle that satisfies the first preset condition is determined based on the second attitude angle; Calculate the Euclidean distance in the coordinate system between the second attitude angle and the attitude angle of each sample that satisfies the first preset condition; The sample attitude angle that satisfies the first preset condition and whose distance satisfies the second preset condition is used as the reference attitude angle, and the reference coefficient is determined based on the second attitude angle and the reference attitude angle. The target vector corresponding to the first attitude angle is determined based on the reference attitude angle and the reference coefficient.
11. The apparatus according to claim 10, characterized in that, The second determining unit is further configured to: Find the sample attitude angle that satisfies the first preset condition among the sample attitude angles corresponding to each of the plurality of random vectors; The sample attitude angles that appear with a frequency reaching a preset threshold among the sample attitude angles that satisfy the first preset condition are taken as the sample attitude angles that satisfy the first preset condition.
12. The apparatus according to claim 10, characterized in that, The second determining unit is further configured to: Determine the average vector corresponding to the reference attitude angle; The target vector corresponding to the first attitude angle is calculated based on the reference coefficient and the average vector corresponding to the reference attitude angle.
13. The apparatus according to claim 9, characterized in that, The generation module specifically includes: The first generation unit is used to input the second pose angle and the target vector into the image generation model to obtain an initial face image; The second generation unit is used to perform a second transformation process on the initial face image to obtain a target face image; the second transformation process corresponds to the first transformation process.
14. The apparatus according to any one of claims 8-13, characterized in that, The image generation model includes a first generation network and a second generation network; The first generative network is used to generate random face images based on the input random vector and the sample pose angle; The second generator network is trained based on sample images with known prediction values and normalized distance; the sample images include the random face images and real face images, the random face images are input into the second generator network to obtain a first prediction value, and the real face images are input into the second generator network to obtain a second prediction value; the normalized distance is obtained based on the pose angle of the sample images input into the first generator network and the pose angle of the random face images; The image generation model is used to train the first generation network based on the predicted value corresponding to the random face image obtained by the second generation network, so that the trained first generation network is input into the second generation network based on the random vector and the sample pose angle to obtain the target predicted value belonging to the preset threshold range.
15. An image processing apparatus, characterized in that, Including the processor and memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code stored in the memory to perform the method as described in any one of claims 1-7.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-7.