Application background replacement method, device, equipment and storage medium
By collecting face images on the terminal and combining facial feature extraction and emotion recognition models, the dynamic replacement of the application background is realized, solving the problem of customer emotions not being displayed as attribute tags, and improving the user experience.
Patent Information
- Application Number
- CN202111264135.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2041-10-28
AI Technical Summary
It is difficult for the existing technology to effectively use customer emotions as customer attribute tags to replace the application background, resulting in poor user experience.
By collecting the user's face image on the terminal, using the facial feature extraction model to extract facial features, and inputting them into the emotion recognition model for emotion recognition, the application background is dynamically changed based on the recognition results.
It improves the user experience, realizes the function of changing the background in real time according to the user's facial emotions, and solves the problem that customer emotions cannot be displayed as attribute tags.
Smart Images

Figure CN113947798B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a background replacement method, device, equipment and storage medium for an application program. Background Art
[0002] With the increasing trend of full-screen and large-screen mobile communication devices, the App has become more high-tech and interesting; adding a skin mall page improves the operability of the skin mall and enhances the user experience.
[0003] In order to improve the accuracy of facial expression recognition and ensure that facial expressions can accurately express the needs of users, currently, smart terminals will extract a series of facial expressions made by users within a set time to generate dynamic facial expression images, and perform facial expression recognition based on dynamic facial expression images. However, compared with static facial expression images, dynamic facial expression images have a larger amount of data. When performing facial expression recognition, it will increase the amount of computing of smart terminals to a certain extent and prolong the computing time. Facial expression recognition is a function that requires high timeliness. Therefore, using customer emotions as customer attribute labels for page display has become a technical problem that technicians in this field need to solve. Summary of the invention
[0004] The main purpose of the present invention is to solve the current technical problem of being unable to use customer emotions as customer attribute tags to replace the background of an application program by accurately identifying customer facial emotions.
[0005] The first aspect of the present invention provides a method for replacing the background of an application, comprising: collecting a facial image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal; inputting the facial image into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; inputting the facial features of the facial image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; obtaining a corresponding background based on the emotion type of the target user in the current state, and replacing the background in the application based on the background.
[0006] Optionally, in a first implementation manner of the first aspect of the present invention, the facial feature extraction model includes a facial feature extraction layer, a facial feature relationship processing layer, a feature fusion layer and a facial recognition layer; the step of inputting the facial image into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image includes: inputting the facial image into the facial feature extraction layer of a preset facial feature extraction model, extracting features of the facial image through the facial feature extraction layer to obtain facial features of the facial image; determining the facial feature relationship between the facial features based on the time point corresponding to the facial image and the facial feature relationship processing layer; performing feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain target facial features; performing recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain facial features of the facial image.
[0007] Optionally, in a second implementation manner of the first aspect of the present invention, determining the facial feature relationship between the facial features based on the time point corresponding to the facial image and the facial feature relationship processing layer includes: sorting the facial features of the facial image through the facial feature relationship processing layer and the video time point corresponding to the facial image to obtain a facial feature queue; and determining the facial feature relationship between the facial features based on the facial feature queue.
[0008] Optionally, in a third implementation method of the first aspect of the present invention, before inputting the facial features of the facial image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state, it also includes: obtaining a facial emotion recognition data set, wherein the facial expression image recognition data set includes a plurality of facial expression images; inputting each facial expression image in the facial emotion recognition data set into a preset multi-task convolutional neural network, performing face detection on the facial expression images through the multi-task convolutional neural network to obtain a plurality of corresponding facial feature images; adding black blocks to the facial feature images based on preset rules, and using the obtained images as a training image set; inputting the training image set into a preset neural network to be trained to train the neural network to be trained, and using the trained neural network to be trained as an emotion recognition model.
[0009] Optionally, in a fourth implementation manner of the first aspect of the present invention, the inputting the training image set into a preset neural network to be trained to train the neural network to be trained, and using the trained neural network to be trained as an emotion recognition model includes: initializing the network parameters of the neural network to be trained; inputting the training image set into the neural network to be trained in batches, training the neural network to be trained by a preset learning rate, and obtaining gradient values of the network parameters of the neural network to be trained; updating the network parameters of the neural network to be trained according to the gradient values, and obtaining a neural network with updated network parameters; using the neural network with updated network parameters as the neural network to be trained, and returning to input the training image set into the neural network to be trained in sequence for training until the loss function of the neural network to be trained converges, and obtaining a target emotion recognition model.
[0010] Optionally, in a fifth implementation manner of the first aspect of the present invention, the inputting the facial features of the facial image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state includes: inputting the facial image into a preset emotion recognition model for preprocessing to obtain a preset number of facial expression units; identifying the facial expression units based on the emotion recognition model to obtain features of the facial expression units; performing feature fusion on the facial features and features of the facial expression units to obtain facial emotion fusion features; inputting the facial emotion fusion features into a preset Gaussian classifier, and using the Gaussian classifier to perform emotion classification on the facial image to obtain the emotion type of the target user in the current state.
[0011] Optionally, in a sixth implementation manner of the first aspect of the present invention, the feature fusion of the facial features and the features of the facial expression unit to obtain facial emotion fusion features includes: segmenting the face image, and inputting the segmented face image into a preset emotion recognition model to extract features of the front face to obtain facial features of the face image; and fusing the features of the facial expression unit and the facial features at the feature level to obtain facial emotion fusion features.
[0012] The second aspect of the present invention provides a background replacement device for an application, comprising: an acquisition module, used to acquire a facial image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal; a feature extraction module, used to input the facial image into a preset facial feature extraction model for feature extraction, and obtain facial features of the facial image; an emotion recognition module, used to input the facial features of the facial image into a preset emotion recognition model for emotion recognition, and obtain the emotion type of the target user in the current state; a replacement module, used to obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0013] Optionally, in a first implementation of the second aspect of the present invention, the feature extraction module includes: a feature extraction unit, used to input the face image into a facial feature extraction layer of a preset facial feature extraction model, extract features of the face image through the facial feature extraction layer, and obtain facial features of the face image; a determination unit, used to determine the facial feature relationship between the facial features based on the time point corresponding to the face image and the facial feature relationship processing layer;
[0014] The first feature fusion unit is used to perform feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain target facial features; the recognition unit is used to perform recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain facial features of the face image.
[0015] Optionally, in a second implementation method of the second aspect of the present invention, the determination unit is specifically used to: sort the facial features of the facial image through the facial feature relationship processing layer and the video time point corresponding to the facial image to obtain a facial feature queue; and determine the facial feature relationship between the facial features according to the facial feature queue.
[0016] Optionally, in a third implementation of the second aspect of the present invention, the background replacement device of the application further includes: an acquisition module, used to acquire a facial emotion recognition data set, wherein the facial expression image recognition data set includes a plurality of facial expression images; a detection module, used to input each facial expression image in the facial emotion recognition data set into a preset multi-task convolutional neural network, and perform facial detection on the facial expression images through the multi-task convolutional neural network to obtain a plurality of corresponding facial feature images; based on preset rules, black blocks are added to the facial feature images respectively, and the obtained images are used as a training image set; a training module, used to input the training image set into a preset neural network to be trained, so as to train the neural network to be trained, and use the trained neural network to be trained as an emotion recognition model.
[0017] Optionally, in a fourth implementation method of the second aspect of the present invention, the training module is specifically used to: initialize the network parameters of the neural network to be trained; input the training image set into the neural network to be trained in batches, train the neural network to be trained by a preset learning rate, and obtain the gradient values of the network parameters of the neural network to be trained; update the network parameters of the neural network to be trained according to the gradient values, and obtain a neural network with updated network parameters; use the neural network with updated network parameters as the neural network to be trained, and return to input the training image set into the neural network to be trained in sequence for training until the loss function of the neural network to be trained converges, so as to obtain a target emotion recognition model.
[0018] Optionally, in a fifth implementation of the second aspect of the present invention, the emotion recognition module includes: a preprocessing unit, used to input the facial image of the target user into a preset emotion recognition model for preprocessing, and presetting a number of facial expression units of the facial image; a recognition unit, used to recognize the facial expression unit based on the emotion recognition model to obtain features of the facial expression unit; a second feature fusion unit, used to perform feature fusion on the facial features and the features of the facial expression unit to obtain facial emotion fusion features; a classification unit, used to input the facial emotion fusion features into a preset Gaussian classifier, use the Gaussian classifier to perform emotion classification on the facial image, and obtain the emotion type of the target user in the current state.
[0019] Optionally, in a sixth implementation method of the second aspect of the present invention, the second feature fusion unit is specifically used to: segment the facial image, and input the segmented facial image into a preset emotion recognition model to extract features of the front face, thereby obtaining facial features of the facial image; and fuse the features of the facial expression unit and the facial features at the feature level, thereby obtaining facial emotion fusion features.
[0020] A third aspect of the present invention provides a background replacement device for an application, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via a line;
[0021] The at least one processor calls the instructions in the memory to enable the background replacement device of the application to execute the steps of the above-mentioned background replacement method of the application.
[0022] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the above-mentioned method for changing the background of an application.
[0023] In the technical solution provided by the present invention, a facial image of a target user is collected through a camera on a terminal installed with the application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the target user's emotion type in the current state; the corresponding background is obtained based on the target user's emotion type in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the application background based on the recognition of the user's facial emotions. The technical problem that customer emotions cannot be used as customer attribute labels for page display is solved, thereby improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of a first embodiment of a method for replacing the background of an application provided by the present invention;
[0025] Figure 2 A schematic diagram of a second embodiment of the background replacement method of an application provided by the present invention;
[0026] Figure 3 A schematic diagram of a third embodiment of the background replacement method of an application provided by the present invention;
[0027] Figure 4 A schematic diagram of a fourth embodiment of the background replacement method of an application provided by the present invention;
[0028] Figure 5 A schematic diagram of a fifth embodiment of the background replacement method of an application provided by the present invention;
[0029] Figure 6 A schematic diagram of a first embodiment of a background replacement device for an application provided by the present invention;
[0030] Figure 7 A schematic diagram of a second embodiment of the background replacement device for an application provided by the present invention;
[0031] Figure 8 A schematic diagram of an embodiment of a background replacement device for an application provided by the present invention. DETAILED DESCRIPTION
[0032] The background replacement method, device, equipment and storage medium of an application provided by an embodiment of the present invention first collects a facial image of a target user through a camera on a terminal installed with the application, wherein the target user is a user who uses or operates the terminal; inputs the facial image into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; inputs the facial features of the facial image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; obtains a corresponding background based on the emotion type of the target user in the current state, and replaces the background in the application based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the background of the application based on the recognition of the user's facial emotions. It solves the technical problem that customer emotions cannot be used as customer attribute labels for page display, thereby improving the user experience.
[0033] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned appendix are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 The first embodiment of the background replacement method of the application program in the embodiment of the present invention includes:
[0035] 101. Collecting a face image of a target user through a camera on a terminal on which an application is installed, wherein the target user is a user who uses or operates the terminal;
[0036] In this embodiment, a facial image of a target user is collected. The facial image of the target user includes a first recognition area and a second recognition area. As an example, the first recognition area may cover the area where the eyebrows and eyes of the target user are located, and the second recognition area may cover the area where the nose and mouth of the target user are located.
[0037] In the embodiment of the present application, facial recognition is performed on the first recognition area and the second recognition area of the facial image of the target user respectively. Based on the above-mentioned facial recognition method, even if one of the first recognition area and the second recognition area is blocked, the facial recognition of the facial image can still be guaranteed to have a high recognition accuracy.
[0038] 102. Input the face image into a preset facial feature extraction model to extract features, and obtain facial features of the face image;
[0039] In this embodiment, the server can obtain a facial image to be identified in real time or at preset intervals, and the facial image to be identified includes the user's facial information. When applying for a loan or a credit card, the user can record a facial image containing the user's facial information through a terminal device and upload the facial image to the server. The server stores the facial image, and the server writes the facial image to be reviewed into the facial image review queue, so that the server can subsequently obtain a facial image from the facial image review queue at a scheduled time or in real time as the facial image to be identified for review, and determine whether the user applying for a loan or a credit card is suspected of fraud. Furthermore, the server can also perform facial recognition on the facial image uploaded by the terminal device in real time.
[0040] The server or server cluster stores a facial feature extraction model, which includes a facial feature extraction layer, a facial feature relationship processing layer, a feature fusion layer and a facial recognition layer. The facial feature extraction layer is used to extract facial features from a target video, the facial feature relationship processing layer is used to determine the facial feature relationship between facial features of each frame image, the feature fusion layer is used to fuse facial features based on the facial feature relationship between facial features of each frame image, and the facial recognition layer is used to recognize the user's facial movements from the video and obtain facial recognition results. The terminal device can be an electronic device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device.
[0041] Specifically, the facial feature extraction model is obtained based on training, and the specific training process is: collect a large number of face images annotated with facial movements, and use the face images annotated with facial movements as model sample data, and then use the model sample data to iteratively train the facial emotion recognition layer in the facial feature extraction model until the model converges. Among them, the facial feature extraction model is designed based on a deep neural network, and the model parameters to be trained of the facial feature extraction model are the model parameters of the facial emotion recognition layer.
[0042] 103. Input the facial features of the face image into a preset emotion recognition model to perform emotion recognition, and obtain the emotion type of the target user in the current state;
[0043] In this embodiment, the training image set is input into a preset neural network to be trained, so as to train the neural network to be trained, and the trained neural network to be trained is used as an emotion recognition model, which specifically includes: initializing the network parameters of the neural network to be trained; inputting the training image set into the neural network to be trained in batches, training the neural network to be trained based on a preset first learning rate and a second learning rate, and using the trained neural network to be trained as an emotion recognition model.
[0044] Specifically, the network parameters of the neural network to be trained are initialized using the InsightFace and Xavier initialization methods, wherein InsightFace is a face recognition model. That is, the network parameters of the feature layer in the neural network to be trained in this embodiment are initialized by the parameters of the InsightFace pre-trained model, and the network parameters of the classification layer in the neural network to be trained in this embodiment are initialized by the Xavier initialization method. It can be understood that the fully connected layer of the neural network to be trained uses the Xavier initialization method to initialize the network parameters, and the network parameters of other layers are initialized to the parameters of the InsightFace pre-trained model, that is, the parameters of the InsightFace pre-trained model are migrated to the neural network to be trained. After the network parameters of the neural network to be trained are initialized, the training image set is input into the neural network to be trained in batches. That is, the facial feature images in the training image set are input into the neural network in batches according to batches. In this embodiment, the batch is preferably n. It can be understood that the facial feature images in the training image set are input into the neural network to be trained after the network parameters are initialized in batches. The network to be trained is trained in stages based on the preset first learning rate and second learning rate. The first learning rate is 0.001, and the second learning rate is 0.0001. In this embodiment, the network structure of the neural network to be trained is also optimized ResNet50 model, that is, the last fully connected layer of the traditional ResNet50 model is replaced with a fully connected layer with 12 output channels. The optimizer also uses the adam optimizer, and the loss function is preferably the binary cross entropy loss function.
[0045] In one embodiment, the training image sets are input into the neural network to be trained in batches, the neural network to be trained is trained based on the preset first learning rate and the second learning rate, and the trained neural network to be trained is used as an emotion recognition model, including: the training image sets are input into the neural network to be trained in batches, the neural network to be trained is trained in the first stage based on the first learning rate and the second learning rate, and the neural network to be trained trained in the first stage is used as the initial emotion recognition model; the training image sets are input into the initial emotion recognition model in batches, the initial emotion recognition model is trained in the second stage based on the preset second learning rate, and the initial emotion recognition model trained in the second stage is used as the emotion recognition model. Furthermore, the facial features of the face image are input into the preset emotion recognition model for emotion recognition, and the emotion type of the target user in the current state is obtained.
[0046] 104. Obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0047] In this embodiment, based on the results of facial emotion recognition, the user's emotions are identified, and the customer's emotions are used as a customer attribute label for page display. After determining the current customer mood, after entering the App, the skinning method is called to change the skin; after the customer enters, the App he sees is the effect after the skinning, because the online skins available to the user have labels, and there is a mapping relationship between the mood and the skin label, and then a skin with the greatest correlation is matched, and the App theme atmosphere is used.
[0048] Furthermore, if the user logs in without face recognition and has the camera permission turned on, the camera can be turned on to capture the customer's face to get the customer's mood, and then the skin can be changed. If the camera is not turned on, the skin can also be changed according to the time the user enters the App, such as morning, noon, evening, and midnight, and different skins can be corresponding.
[0049] In an embodiment of the present invention, a facial image of a target user is collected by a camera on a terminal installed with the application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; the corresponding background is obtained based on the emotion type of the target user in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the background of the application based on the recognition of the user's facial emotions. The technical problem that customer emotions cannot be used as customer attribute labels for page display is solved, thereby improving the user experience.
[0050] See also Figure 2 The second embodiment of the background replacement method of the application program in the embodiment of the present invention includes:
[0051] 201. Collecting a facial image of a target user through a camera on a terminal on which an application is installed, wherein the target user is a user who uses or operates the terminal;
[0052] 202. Inputting the facial image into a facial feature extraction layer of a preset facial feature extraction model, extracting features of the facial image through the facial feature extraction layer to obtain facial features of the facial image;
[0053] In this embodiment, the server can obtain the facial image to be identified in real time or at preset intervals. The facial image to be identified includes the facial information of the user. The server can also perform facial recognition on the facial image uploaded by the terminal device in real time.
[0054] The server or server cluster stores a facial feature extraction model, which includes a facial feature extraction layer, a facial feature relationship processing layer, a feature fusion layer and a facial recognition layer. The facial feature extraction layer is used to extract facial features from a target video, the facial feature relationship processing layer is used to determine the facial feature relationship between facial features of each frame image, the feature fusion layer is used to fuse facial features based on the facial feature relationship between facial features of each frame image, and the facial recognition layer is used to recognize the user's facial movements from the video and obtain facial recognition results. The terminal device can be an electronic device such as a mobile phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant, and a wearable device.
[0055] Specifically, the facial feature extraction model is obtained based on training, and the specific training process is: collect a large number of face images annotated with facial movements, and use the face images annotated with facial movements as model sample data, and then use the model sample data to iteratively train the facial emotion recognition layer in the facial feature extraction model until the model converges. Among them, the facial feature extraction model is designed based on a deep neural network, and the model parameters to be trained of the facial feature extraction model are the model parameters of the facial emotion recognition layer.
[0056] In this embodiment, feature extraction is performed on each frame of the face image to be identified to obtain facial features corresponding to each frame, that is, the facial features corresponding to each frame are extracted from each frame of the face image to be identified through the facial feature extraction layer in the facial feature extraction model.
[0057] Specifically, the face image to be identified is split into each frame image, and a preset number of facial key points are extracted from each frame image; according to the preset number of facial key points extracted from each frame image, the facial features corresponding to each frame image are determined. Taking a frame image as an example, n facial key points are extracted from a frame image, and the extracted n facial key points are used as the facial features corresponding to this frame image. It should be noted that the above preset number can be set based on actual conditions, and this application does not make specific restrictions on this. Optionally, the number of facial key points is n or m, and the facial feature is a feature matrix composed of n or m facial key points. Among them, the facial feature extraction algorithm includes but is not limited to a facial feature extraction algorithm based on Gabor filtering, a facial feature extraction algorithm based on local binarization, a facial feature extraction algorithm based on a deep neural network, and a facial feature extraction algorithm based on geometric features, and this application does not make specific restrictions on this.
[0058] 203. Determine a facial feature relationship between facial features based on the time point corresponding to the face image and the facial feature relationship processing layer;
[0059] In this embodiment, after the facial features corresponding to each frame of image are obtained, the facial feature relationship between the facial features corresponding to each frame of image is determined according to the video time point corresponding to each frame of image by the facial feature relationship processing layer in the facial feature extraction model. It should be noted that the video time point is the time point of each frame of image in the face image to be recognized, which is used to represent the time sequence of each frame of image.
[0060] Specifically, according to the video time point of each frame of image, the facial features corresponding to each frame of image are sorted to obtain a facial feature queue; according to the facial feature queue, the facial feature relationship between the facial features corresponding to each frame of image is determined. It should be noted that the smaller the video time point, the higher the facial features are ranked, and the larger the video time point, the lower the facial features are ranked.
[0061] Among them, the method of determining the facial feature relationship based on the facial feature queue is specifically: select one facial feature from the facial feature queue as the target facial feature in turn, and obtain the facial features adjacent to the target facial feature and the facial features not adjacent to the target facial feature from the facial feature queue, so as to obtain the facial feature relationship between the target facial feature and each of the remaining facial features, that is, the adjacent relationship and the non-adjacent relationship. For example, if the facial feature queue is [A, B, C, D], then it can be obtained that the facial feature relationship between facial feature A and facial feature B is an adjacent relationship, the facial feature relationship between facial feature A and facial feature C is a non-adjacent relationship, the facial feature relationship between facial feature A and facial feature D is a non-adjacent relationship, the facial feature relationship between facial feature B and facial feature C is an adjacent relationship, the facial feature relationship between facial feature B and facial feature D is a non-adjacent relationship, and the facial feature relationship between facial feature C and facial feature D is an adjacent relationship.
[0062] 204. Perform feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain target facial features;
[0063] In this embodiment, after determining the facial features and facial feature relationships corresponding to each frame of image, based on the feature fusion layer, the facial features corresponding to each frame of image are fused according to the facial feature relationships corresponding to each frame of image to obtain target facial features. By fusing the facial features corresponding to each frame of image according to the facial feature relationships corresponding to each frame of image, accurate facial features can be obtained, which can improve the accuracy of facial recognition.
[0064] 205. Recognize and process the target facial features through the facial recognition layer of the facial feature extraction model to obtain facial features of the face image;
[0065] In this embodiment, the facial image of the user in the facial image is determined based on the target facial features through the facial recognition layer in the facial feature extraction model.
[0066] 206. Input the facial features of the face image into a preset emotion recognition model to perform emotion recognition, and obtain the emotion type of the target user in the current state;
[0067] 207. Obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0068] Steps 201, 206-207 in this embodiment are similar to steps 101, 103-104 in the first embodiment, and are not described again here.
[0069] In an embodiment of the present invention, a facial image of a target user is collected by a camera on a terminal installed with the application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; the corresponding background is obtained based on the emotion type of the target user in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the background of the application based on the recognition of the user's facial emotions. The technical problem that customer emotions cannot be used as customer attribute labels for page display is solved, thereby improving the user experience.
[0070] See also Figure 3 A third embodiment of the background replacement method of an application program in an embodiment of the present invention includes:
[0071] 301. Collecting a facial image of a target user through a camera on a terminal on which an application is installed;
[0072] 302. Input the face image into a face feature extraction layer of a preset face feature extraction model, and extract features from each frame of the face image through the face feature extraction layer to obtain facial features corresponding to each frame of the face image;
[0073] 303. Sort facial features of the face image by using the facial feature relationship processing layer and the video time points corresponding to the face image to obtain a facial feature queue;
[0074] In this embodiment, after the facial features corresponding to each frame of image are obtained, the facial feature relationship between the facial features corresponding to each frame of image is determined according to the video time point corresponding to each frame of image by the facial feature relationship processing layer in the facial feature extraction model. It should be noted that the video time point is the time point of each frame of image in the face image to be recognized, which is used to represent the time sequence of each frame of image.
[0075] After obtaining the facial features and facial feature relationships corresponding to each frame of image, based on the feature fusion layer, the facial features corresponding to each frame of image are sorted according to the facial feature relationships corresponding to each frame of image, and the target facial feature queue is obtained. For example, the facial features corresponding to each frame of image are facial feature 1, facial feature 2, facial feature 3, and facial feature 4, and the facial feature relationships are facial feature 1 is adjacent to facial feature 3, and is not adjacent to facial feature 4 and facial feature 2; facial feature 3 is adjacent to facial feature 1 and facial feature 4, and is not adjacent to facial feature 2; facial feature 2 is adjacent to facial feature 4, and is not adjacent to facial feature 1 and facial feature 3; facial feature 4 is adjacent to facial feature 3 and facial feature 2, and is not adjacent to facial feature 1. Through the above facial feature relationships, the facial feature queue obtained is [1, 3, 4, 2].
[0076] 304. Determine facial feature relationships between facial features according to the facial feature queue;
[0077] In this embodiment, after the facial features corresponding to each frame of image are obtained, the facial feature relationship between the facial features corresponding to each frame of image is determined according to the video time point corresponding to each frame of image by the facial feature relationship processing layer in the facial feature extraction model. It should be noted that the video time point is the time point of each frame of image in the face image to be recognized, which is used to represent the time sequence of each frame of image.
[0078] 305. Perform feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain the facial features of the face image;
[0079] 306. Performing recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain a facial image of the target user in the facial image;
[0080] 307. Input the facial features of the face image into a preset emotion recognition model to perform emotion recognition, and obtain the emotion type of the target user in the current state;
[0081] 308. Obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0082] Steps 301, 307-308 in this embodiment are similar to steps 101, 103-104 in the first embodiment, and are not described again here.
[0083] In an embodiment of the present invention, a facial image of a target user is collected through a camera on a terminal installed with an application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the target user's emotion type in the current state; the corresponding background is obtained based on the target user's emotion type in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the application background based on the recognition of the user's facial emotions. It solves the technical problem that customer emotions cannot be used as customer attribute labels for page display, thereby improving the user experience.
[0084] See also Figure 4 The fourth embodiment of the background replacement method of the application program in the embodiment of the present invention includes:
[0085] 401. Collecting a facial image of a target user through a camera on a terminal on which an application is installed;
[0086] 402. Input the face image into a preset facial feature extraction model to extract features, and obtain facial features of the face image;
[0087] 403. Obtain a facial emotion recognition dataset, wherein the facial expression image recognition dataset includes multiple facial expression images;
[0088] In this embodiment, the facial emotion recognition dataset is a collection of multiple facial expression images. It can be understood that the facial expression images in the facial expression dataset are images of different types, such as different expressions, different genders, different ages, different shapes, and different colors. The facial expression images in the facial emotion recognition dataset can be manually pre-collected and stored in a database, or can be obtained from an open source database using a crawler.
[0089] Specifically, when the user has a need to train an emotion recognition model, the user sends a model training instruction to the server through the operation terminal. After the server receives the model training instruction, it responds to the model training instruction to obtain a pre-stored facial emotion recognition data set from the database. Alternatively, the facial emotion recognition data set is obtained from an open source crawler using the URL (Uniform Resource Locator) link carried in the model training instruction.
[0090] 404. Input each facial expression image in the facial emotion recognition data set into a preset multi-task convolutional neural network, perform facial detection on the facial expression image through the multi-task convolutional neural network, and obtain a plurality of corresponding facial feature images;
[0091] In this embodiment, a multi-task convolutional neural network (MTCNN) is a neural network for face detection. MTCNN can be divided into three parts, namely, P-Net (Proposal Network), R-Net (Refine Network) and O-Net (Output Network) three-layer network structure. The basic structure of P-Net is a fully connected neural network, and the basic structure of R-Net is a convolutional neural network. Compared with P-Net, R-Net adds a fully connected layer, so R-Net will be more strict in screening input data. R-Net and O-Net are more complex convolutional neural networks, with one more convolution layer than R-Net. The difference between the effect of O-Net and R-Net is that this layer of structure will identify the facial area through more supervision, and will regress the facial feature points of the person, and finally output the facial feature image including the facial feature points.
[0092] Specifically, after the server obtains the facial emotion recognition data set, the preset multi-task convolutional neural network is called. Each facial expression image in the facial emotion recognition data set is input into the multi-task convolutional neural network respectively, and the facial expression image is detected by the P-Net, R-Net and O-Net of the multi-task convolutional neural network in turn to obtain the corresponding facial feature image. That is, the image output by P-Net is used as the input of R-Net, and the image output by R-Net is used as the input of O-Net. It can be understood that since the facial emotion recognition data set includes a variety of different facial expression images, and each facial expression image can obtain a corresponding facial feature image, the facial feature images finally obtained are also a variety of different images, and each facial feature image has a corresponding facial expression image.
[0093] 405. Add black blocks to the facial feature images based on preset rules, and use the obtained images as training image sets;
[0094] In this embodiment, the preset rules refer to a file storing rules for indicating how to add black blocks. Black blocks refer to occluding graphics with black or gray colors, that is, the grayscale value is between 0-50. Among them, when the grayscale value is 0, the color of the black block is completely black. Black blocks can be understood as graphics of various inconsistent shapes. For example, black blocks can be triangles, circles, squares or irregular shapes. The training data set refers to a collection of facial feature images with black blocks added, that is, the training data set includes multiple facial feature images with black blocks added. Alternatively, in order to increase the diversity of the data, the training data set may include facial feature images with black blocks added, and facial feature images that are determined not to add black blocks, that is, including two types of facial feature images, including black blocks and not including black blocks.
[0095] In one embodiment, black blocks are added to facial feature images based on preset rules, and the resulting images are used as training image sets, including: generating corresponding random numbers for facial feature images respectively, and determining whether to add images to the corresponding facial feature images according to the random numbers; if the image is determined to be added according to the random numbers, black block information is determined based on the random numbers and the corresponding facial feature images; and black blocks are added to the corresponding facial feature images according to the black block information, and the resulting images are used as training image sets. The random number refers to a randomly generated value, and the range of the random number is 0 to 1. Whether to add a black block is determined by the random number. The black block information includes the black block coverage position, coverage angle, and color.
[0096] In this embodiment, the amount of data for traditional facial expression training is too small, and most of the data sets are in an unobstructed state. However, in actual application scenarios, the face is usually obstructed, for example, masks, hats, and hand movements will cause certain obstructions. Therefore, the facial expression recognition model trained with such unobstructed data is different from the actual application scenario, so that the accuracy of the model in actual application is not high. Therefore, by randomly adding different black blocks to the acquired multiple different facial feature images, the facial feature images with added black blocks are made to block part of the features in the image through the black blocks, thereby ensuring diverse training data, and thus training the neural network through unobstructed images and obstructed images, which can improve the robustness of the neural network and improve the accuracy of the model.
[0097] 406. Initialize network parameters of the neural network to be trained;
[0098] In this embodiment, the network parameters of each layer in the neural network to be trained are initially preset using the Xavier method, wherein Xavier is a very effective method for initializing a neural network. After determining the initial network parameters of the neural network to be trained, the training image set is input into the neural network to be trained in batches. That is, the facial feature images in the training image set are input into the neural network in batches.
[0099] 407. Input the training image set into the neural network to be trained in batches, train the neural network to be trained using a preset learning rate, and obtain the gradient value of the network parameter of the neural network to be trained;
[0100] In this embodiment, batch is preferably n. It can be understood that n facial feature images in the training image set are input as a batch into the neural network to be trained after the network parameters are initialized, and the feature layer and classification layer in the neural network to be trained forward propagate the input facial feature images based on the preset first learning rate to obtain the corresponding output value. Among them, the first learning rate is preset, and the first learning rate is fixed to 0.001. It can be understood that the feature layer and classification layer in the neural network to be trained both use the learning rate, and the neural network to be trained calculates the loss value of this training according to the preset loss function and the corresponding output value, and performs back propagation based on the loss value, so as to obtain the gradient value of each network parameter, and the network parameters are updated according to the obtained gradient value.
[0101] 408. Update the network parameters of the neural network to be trained according to the gradient value to obtain a neural network with updated network parameters;
[0102] In this embodiment, back propagation is performed based on the loss value to obtain the gradient value of each network parameter, and the network parameters are updated according to the obtained gradient value to obtain a neural network with updated network parameters.
[0103] 409. The neural network with updated network parameters is used as the neural network to be trained, and the training image set is input into the neural network to be trained in sequence until the loss function of the neural network to be trained converges, thereby obtaining a target emotion recognition model;
[0104] In this embodiment, the next batch of facial feature images is input into the neural network to be trained after the network parameters are updated, and the neural network to be trained is also retrained based on the first learning rate. That is, the second batch of facial feature images is input, and the neural network to be trained performs forward propagation on the input facial feature images again based on the first learning rate, and similarly obtains the corresponding output value and calculates the loss value, and then performs back propagation to update the network parameters again. Repeat the above steps for iterative training until the loss function converges. It can be understood that if the loss function has not converged, it means that the various network parameters of the neural network have not reached the optimal value, that is, training is still needed, and if the loss function converges, it means that the neural network has reached the optimal value, and the neural network can be put into use as an emotion recognition model. That is to say, after the training of the second batch of facial feature images is completed, if the loss function has not converged, the third batch of facial feature images can be input again after the network parameters are updated for the second time, until the loss function converges. The convergence of the loss function can be understood as the loss value calculated by the loss function tends to 0, and the tendency to 0 indicates that the predicted value of the neural network is closer to the expected value, indicating that the training of the neural network is completed. The preset network structure of the neural network to be trained is an optimized ResNet50 model. The difference from the traditional ResNet50 model is that the last fully connected layer is replaced with a fully connected layer with 12 output channels. The output value includes the predicted value and the true label, and the loss value is calculated based on the predicted value and the true label, as well as the loss function.
[0105] In this embodiment, the loss function is preferably a binary cross entropy loss function, and the optimizer used for training is the Adam optimizer.
[0106] In another embodiment, a training image set is input into a preset neural network to be trained, so as to train the neural network, and the trained neural network to be trained is used as an emotion recognition model, which specifically includes: initializing network parameters of the neural network to be trained; inputting the training image set into the neural network to be trained in batches, training the neural network to be trained based on preset first learning rate and second learning rate, and using the trained neural network to be trained as an emotion recognition model.
[0107] 410. Input the facial features of the face image into a preset emotion recognition model to perform emotion recognition, and obtain the emotion type of the target user in the current state;
[0108] 411. Obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0109] Steps 401 - 402 and 410 - 411 in this embodiment are similar to steps 101 - 102 and 103 - 104 in the first embodiment, and are not described again here.
[0110] In an embodiment of the present invention, a facial image of a target user is collected through a camera on a terminal installed with an application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the target user's emotion type in the current state; the corresponding background is obtained based on the target user's emotion type in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the application background based on the recognition of the user's facial emotions. It solves the technical problem that customer emotions cannot be used as customer attribute labels for page display, thereby improving the user experience.
[0111] See also Figure 5 The fifth embodiment of the background replacement method of the application program in the embodiment of the present invention includes:
[0112] 501. Collecting a facial image of a target user through a camera on a terminal on which an application is installed;
[0113] 502. Input the face image into a preset facial feature extraction model to extract features, and obtain facial features of the face image;
[0114] 503. Input the face image into a preset emotion recognition model for preprocessing to obtain a preset number of facial expression units of the face image;
[0115] In this embodiment, the face image is preprocessed by face key point detection technology, and the face area is subdivided into a number of facial expression unit trigger areas. The specific implementation process may include: detecting a preset number of key points on the face area according to the face anatomical structure and the face key point detection algorithm; cropping the image data according to the preset number of key points to obtain the target face area, scaling the target face area to a preset pixel size, and realizing normalization of the facial image; subdividing the target face area into three facial expression unit trigger areas, and the three facial expression unit trigger areas include an eye action unit trigger area, a T-zone action unit trigger area, and a lip action unit trigger area. For example, in the specific implementation process, 68 key points on the face can be detected and extracted based on facial anatomy and topological structure and facial key point (feature point) detection algorithm, and the face area is cropped from the face image according to the 68 key points, and then scaled to 250*250 pixels to achieve normalization of the facial image; the face area is further subdivided into three facial expression unit trigger areas: eye action unit trigger area, T zone action unit trigger area and lip action unit trigger area.
[0116] 504. Recognize the facial expression unit based on the emotion recognition model to obtain the features of the facial expression unit;
[0117] In this embodiment, the facial expression unit is identified based on the emotion recognition model to obtain the features of the facial expression unit. The specific implementation process may include: selecting a facial expression unit that has an associated relationship with the expression, and constructing a correspondence between the facial expression unit and the triggering areas of the three facial expression units; using the emotion recognition model to extract the local features of the facial expression unit in the corresponding facial expression unit triggering area to obtain the local features of the facial expression unit triggering area; inputting the local features of the facial expression unit triggering area into the softmax layer to identify the facial expression unit, and obtaining the features of the facial expression unit. For example, in the specific implementation process, 68 feature points on the face are extracted according to the facial anatomy and topological structure, and then 13 facial expression units (Action Unit, AU) with strong correlation with expressions are selected from 41 expression-related facial expression units (AU1-AU41) according to the correlation between facial expression units and expressions, and then the face is divided into three action unit triggering areas based on the triggering areas of these 13 AUs, namely, the eye action unit triggering area, the T-zone action unit triggering area, and the lip action unit triggering area, and the corresponding relationship between the 13 facial expression units and the three facial expression unit triggering areas is constructed. Correspondingly, the local features of the 13 facial expression units in the corresponding facial expression unit triggering areas are extracted using the 13 emotion recognition models to obtain the local features of the 13 action unit triggering areas; the local features of the 13 action unit triggering areas are passed into the softmax layer to identify the 13 facial expression features, and the recognition results of the 13 facial expression features are obtained, that is, the features of the facial expression units are obtained, which are not specifically limited here. The emotion recognition model can be divided into 13 parallel 3DCNN networks. Among them, 4 receive eye action unit trigger areas as input, and the recognition results of AU1 (corresponding feature is the inner corner of the eyebrow raised), AU2 (corresponding feature is the outer corner of the eyebrow raised), AU4 (corresponding feature is frowning), and AU7 (corresponding feature is the tightening of the orbicularis oculi) are output; 2 receive T zone action unit trigger areas as input, and the recognition results of AU9 (corresponding feature is the inner corner of the eyebrow raised) and AU17 (corresponding feature is the inner corner of the eyebrow raised) are output; 7 lip action unit trigger areas are input, and the recognition results of AU10 (corresponding feature is pulling the corner of the mouth upward), AU12 (corresponding feature is pulling the corner of the mouth tilted upward), AU15 (corresponding feature is pulling the corner of the mouth downward), AU20 (corresponding feature is pushing the lower lip upward), AU24 (corresponding feature is stretching the corner of the mouth), AU25 (corresponding feature is pressing the corners of the mouth against each other), and AU26 (corresponding feature is opening the mouth) are output.
[0118] 505. Segment the face image, and input the segmented face image into a preset emotion recognition model to extract features of the front face, thereby obtaining facial features of the face image;
[0119] In this embodiment, the target face region is cut into blocks and input into a preset emotion recognition model to extract features of the front face and obtain global facial features; the features of the facial expression units and the global facial features are fused at the feature level to obtain facial expression fusion features. Specifically, the obtained normalized face region blocks can be input into another preset emotion recognition model (3D CNN) to extract features of the front face.
[0120] 506. Fusing the features of the facial expression unit and the facial features at the feature level to obtain facial emotion fusion features;
[0121] In this embodiment, the features of the 13 local action unit triggering areas and the whole face features are fused at the feature level. In the specific implementation process, the normalized face area can be input into an independent 3DCNN network to extract the whole face features; then the extracted whole face features are fused with the local features of the previous 13 AUs at the feature level to obtain the fused features of the whole face and the local action unit triggering areas.
[0122] 507. Input the facial emotion fusion feature into a preset Gaussian classifier, use the Gaussian classifier to perform emotion recognition on the face image, and obtain the emotion type of the target user in the current state;
[0123] In this embodiment, the Gaussian classifier is based on the association constraint between the facial expression unit and the expression. Therefore, the use of the Gaussian classifier to recognize the facial expression of a human face and output the facial expression recognition result may include: inputting the facial expression fusion feature into the Gaussian classifier to obtain a preliminary recognition result of the facial expression of the human face; using the features of the facial expression unit, using the association between the facial expression unit and the expression to further constrain the preliminary recognition result of the facial expression of the human face, and outputting the facial expression recognition result.
[0124] 508. Obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0125] Steps 501 - 502 and 508 in this embodiment are similar to steps 101 - 102 and 104 in the first embodiment, and are not described again here.
[0126] In an embodiment of the present invention, a facial image of a target user is collected through a camera on a terminal installed with an application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the target user's emotion type in the current state; the corresponding background is obtained based on the target user's emotion type in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the application background based on the recognition of the user's facial emotions. It solves the technical problem that customer emotions cannot be used as customer attribute labels for page display, thereby improving the user experience.
[0127] The above describes the background replacement method of the application program in the embodiment of the present invention. The following describes the background replacement device of the application program in the embodiment of the present invention. Figure 6 The first embodiment of the background replacement device of the application program in the embodiment of the present invention includes:
[0128] The acquisition module 601 is used to acquire a face image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal;
[0129] A feature extraction module 602 is used to input the face image into a preset facial feature extraction model to extract features and obtain facial features of the face image;
[0130] The emotion recognition module 603 is used to input the facial features of the face image into a preset emotion recognition model for emotion recognition, and obtain the emotion type of the target user in the current state;
[0131] The replacement module 604 is used to obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0132] In an embodiment of the present invention, a facial image of a target user is collected by a camera on a terminal installed with the application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; the corresponding background is obtained based on the emotion type of the target user in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the background of the application based on the recognition of the user's facial emotions. The technical problem that customer emotions cannot be used as customer attribute labels for page display is solved, thereby improving the user experience.
[0133] See also Figure 7 In the second embodiment of the background replacement device of the application program in the embodiment of the present invention, the background replacement device of the application program specifically comprises:
[0134] The acquisition module 601 is used to acquire a face image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal;
[0135] A feature extraction module 602 is used to input the face image into a preset facial feature extraction model to extract features and obtain facial features of the face image;
[0136] The emotion recognition module 603 is used to input the facial features of the face image into a preset emotion recognition model for emotion recognition, and obtain the emotion type of the target user in the current state;
[0137] The replacement module 604 is used to obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background.
[0138] In this embodiment, the feature extraction module 602 includes:
[0139] The feature extraction unit 6021 is used to input the face image into the face feature extraction layer of the preset face feature extraction model, extract the features of the face image through the face feature extraction layer, and obtain the facial features of the face image;
[0140] A determination unit 6022, configured to determine a facial feature relationship between the facial features based on a time point corresponding to the facial image and the facial feature relationship processing layer;
[0141] A first feature fusion unit 6023 is used to perform feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain a target facial feature;
[0142] The recognition unit 6024 is used to perform recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain the facial features of the facial image.
[0143] In this embodiment, the determining unit 6022 is specifically used for:
[0144] Sorting facial features of the facial image through the facial feature relationship processing layer and the video time point corresponding to the facial image to obtain a facial feature queue;
[0145] A facial feature relationship between the facial features is determined based on the facial feature queue.
[0146] In this embodiment, the background replacement device of the application program further includes:
[0147] An acquisition module 605 is used to acquire a facial emotion recognition data set, wherein the facial expression image recognition data set includes a variety of facial expression images;
[0148] The detection module 606 is used to input each facial expression image in the facial emotion recognition data set into a preset multi-task convolutional neural network, perform facial detection on the facial expression image through the multi-task convolutional neural network, and obtain a plurality of corresponding facial feature images; based on preset rules, black blocks are added to the facial feature images respectively, and the obtained images are used as training image sets;
[0149] The training module 607 is used to input the training image set into a preset neural network to be trained, so as to train the neural network to be trained, and use the trained neural network to be trained as an emotion recognition model.
[0150] In this embodiment, the training module 607 is specifically used for:
[0151] Initializing network parameters of the neural network to be trained;
[0152] Inputting the training image set into the neural network to be trained in batches, training the neural network to be trained by a preset learning rate, and obtaining the gradient value of the network parameter of the neural network to be trained;
[0153] Update the network parameters of the neural network to be trained according to the gradient value to obtain a neural network with updated network parameters;
[0154] The neural network with updated network parameters is used as the neural network to be trained, and the training image set is returned and sequentially input into the neural network to be trained until the loss function of the neural network to be trained converges, thereby obtaining a target emotion recognition model.
[0155] In this embodiment, the emotion recognition module 603 includes:
[0156] A preprocessing unit 6031 is used to input the face image of the target user into a preset emotion recognition model for preprocessing, and to convert the face image into a preset number of facial expression units;
[0157] An emotion recognition unit 6032, used to recognize the facial expression unit based on the emotion recognition model to obtain the features of the facial expression unit;
[0158] A second feature fusion unit 6033 is used to fuse the facial features and the features of the facial expression unit to obtain facial emotion fusion features;
[0159] The classification unit 6034 is used to input the facial emotion fusion feature into a preset Gaussian classifier, and use the Gaussian classifier to perform emotion classification on the face image to obtain the emotion type of the target user in the current state.
[0160] In this embodiment, the second feature fusion unit 6033 is specifically used for:
[0161] Segmenting the face image, and inputting the segmented face image into a preset emotion recognition model to extract features of the front face, thereby obtaining facial features of the face image;
[0162] The features of the facial expression unit and the facial features are fused at a feature level to obtain facial emotion fusion features.
[0163] In an embodiment of the present invention, a facial image of a target user is collected through a camera on a terminal installed with an application, wherein the target user is a user who uses or operates the terminal; the facial image is input into a preset facial feature extraction model for feature extraction to obtain facial features of the facial image; the facial features of the facial image are input into a preset emotion recognition model for emotion recognition to obtain the target user's emotion type in the current state; the corresponding background is obtained based on the target user's emotion type in the current state, and the background in the application is replaced based on the background. The present invention combines the background replacement function of the application with face recognition technology to achieve the purpose of replacing the application background based on the recognition of the user's facial emotions. It solves the technical problem that customer emotions cannot be used as customer attribute labels for page display, thereby improving the user experience.
[0164] above Figure 6 and Figure 7 The background replacement device of the application in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The background replacement device of the application in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0165] Figure 8 800 of the application background replacement device provided in an embodiment of the present invention may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 810 (for example, one or more processors) and memory 820, and one or more storage media 830 (for example, one or more mass storage devices) storing application 833 or data 832. Among them, the memory 820 and the storage medium 830 may be temporary storage or permanent storage. The program stored in the storage medium 830 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the background replacement device 800 of the application. Furthermore, the processor 810 may be configured to communicate with the storage medium 830, and execute a series of instruction operations in the storage medium 830 on the background replacement device 800 of the application to implement the steps of the background replacement method of the application provided in the above-mentioned method embodiments.
[0166] The background replacement device 800 of the application program may also include one or more power supplies 840, one or more wired or wireless network interfaces 850, one or more input and output interfaces 860, and / or one or more operating systems 831, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Figure 8 The background replacement device structure of the application shown does not constitute a limitation on the background replacement device of the application provided in the present application, and may include more or fewer components than shown in the figure, or a combination of certain components, or a different arrangement of components.
[0167] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the background replacement method of the above-mentioned application.
[0168] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0169] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0170] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for replacing the background of an application, characterized in that: The background replacement method of the application program includes: Capturing a face image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal; Inputting the face image into a preset facial feature extraction model for feature extraction to obtain facial features of the face image; the facial feature extraction model includes a facial feature extraction layer, a facial feature relationship processing layer, a feature fusion layer and a facial recognition layer; Inputting the facial features of the face image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state; Obtaining a corresponding background based on the emotion type of the target user in the current state, and replacing the background in the application based on the background; The step of inputting the face image into a preset facial feature extraction model for feature extraction to obtain facial features of the face image comprises: inputting the face image into a facial feature extraction layer of a preset facial feature extraction model, extracting features of the face image through the facial feature extraction layer to obtain facial features of the face image; determining facial feature relationships between the facial features based on the time point corresponding to the face image and the facial feature relationship processing layer; performing feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain target facial features; performing recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain facial features of the face image; The method of determining the facial feature relationship between the facial features based on the time point corresponding to the facial image and the facial feature relationship processing layer includes: sorting the facial features of the facial image through the facial feature relationship processing layer and the video time point corresponding to the facial image to obtain a facial feature queue; the video time point is a moment point of each frame image in the facial image to be identified, and is used to represent the time sequence of each frame image; determining the facial feature relationship between the facial features according to the facial feature queue; the facial feature relationship includes an adjacent relationship and a non-adjacent relationship.
2. The background replacement method of an application according to claim 1, characterized in that: Before inputting the facial features of the face image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state, the method further includes: Acquire a facial emotion recognition dataset, wherein the facial emotion recognition dataset includes multiple facial expression images; Inputting each facial expression image in the facial emotion recognition data set into a preset multi-task convolutional neural network, performing face detection on the facial expression image through the multi-task convolutional neural network, and obtaining a plurality of corresponding facial feature images; Adding black blocks to the facial feature images respectively based on preset rules, and using the obtained images as a training image set; The training image set is input into a preset neural network to be trained to train the neural network, and the trained neural network to be trained is used as an emotion recognition model.
3. The background replacement method of an application according to claim 2, characterized in that: The step of inputting the training image set into a preset neural network to be trained to train the neural network to be trained, and using the trained neural network to be trained as an emotion recognition model comprises: Initializing network parameters of the neural network to be trained; Inputting the training image set into the neural network to be trained in batches, training the neural network to be trained by a preset learning rate, and obtaining the gradient value of the network parameter of the neural network to be trained; Update the network parameters of the neural network to be trained according to the gradient value to obtain a neural network with updated network parameters; The neural network with updated network parameters is used as the neural network to be trained, and the training image set is returned and sequentially input into the neural network to be trained until the loss function of the neural network to be trained converges, thereby obtaining a target emotion recognition model.
4. The background replacement method of an application according to claim 1, characterized in that: The step of inputting the facial features of the face image into a preset emotion recognition model for emotion recognition to obtain the emotion type of the target user in the current state includes: Inputting the facial image into a preset emotion recognition model for preprocessing to obtain a preset number of facial expression units; Recognize the facial expression unit based on the emotion recognition model to obtain the features of the facial expression unit; Performing feature fusion on the facial features and the features of the facial expression unit to obtain facial emotion fusion features; The facial emotion fusion feature is input into a preset Gaussian classifier, and the Gaussian classifier is used to perform emotion classification on the face image to obtain the emotion type of the target user in the current state.
5. The background replacement method of an application according to claim 4, characterized in that: The step of fusing the facial features with the features of the facial expression unit to obtain facial emotion fusion features comprises: Segmenting the face image, and inputting the segmented face image into a preset emotion recognition model to extract features of the front face, thereby obtaining facial features of the face image; The features of the facial expression unit and the facial features are fused at a feature level to obtain facial emotion fusion features.
6. A background replacement device for an application, characterized in that: The background replacement device of the application program includes: A collection module, used to collect a face image of a target user through a camera on a terminal on which the application is installed, wherein the target user is a user who uses or operates the terminal; A feature extraction module, used for inputting the face image into a preset facial feature extraction model for feature extraction to obtain facial features of the face image; the facial feature extraction model includes a facial feature extraction layer, a facial feature relationship processing layer, a feature fusion layer and a facial recognition layer; An emotion recognition module, used to input the facial features of the face image into a preset emotion recognition model for emotion recognition, and obtain the emotion type of the target user in the current state; A replacement module, used to obtain a corresponding background based on the emotion type of the target user in the current state, and replace the background in the application based on the background; The feature extraction module is further used to input the face image into the face feature extraction layer of the preset face feature extraction model, extract the features of the face image through the face feature extraction layer, and obtain the facial features of the face image; determine the facial feature relationship between the facial features based on the time point corresponding to the face image and the facial feature relationship processing layer; perform feature fusion on the facial features through the feature fusion layer of the facial feature extraction model and the facial feature relationship to obtain the target facial features; perform recognition processing on the target facial features through the facial recognition layer of the facial feature extraction model to obtain the facial features of the face image; The feature extraction module is also used to sort the facial features of the facial image through the facial feature relationship processing layer and the video time point corresponding to the facial image to obtain a facial feature queue; the video time point is the moment point of each frame image in the facial image to be identified, which is used to represent the time sequence of each frame image; based on the facial feature queue, the facial feature relationship between the facial features is determined; the facial feature relationship includes an adjacent relationship and a non-adjacent relationship.
7. A background replacement device for an application, characterized in that: The background replacement device of the application comprises: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instructions in the memory to enable the background replacement device of the application to perform the steps of the background replacement method of the application according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the background replacement method of an application program according to any one of claims 1 to 5 are implemented.
