Character relationship construction method and device and electronic equipment
By obtaining the character attribute information in the pending image and generating relationship voting results using pre-trained network models, the problem of inaccurate character relationship construction in the prior art is solved, and the accuracy of relationship construction is improved.
Patent Information
- Application Number
- CN202311257405.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2025-03-28
AI Technical Summary
In the prior art, character relationships are inaccurate, and it is difficult to effectively manage and identify the relationships between characters.
By obtaining the character attribute information (age, gender, and occurrence) in the pending image, combining the target image and a pre-trained network model, relationship voting results are generated, and accurate character relationships are selected based on this information.
Improve the accuracy of character relationship construction, allowing electronic devices to more effectively manage and identify relationships between characters.
Smart Images

Figure CN119723118A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a method, device and electronic device for establishing a character relationship. Background Art
[0002] With the continuous development of science and technology and the improvement of people's living standards, people are more and more fond of taking photos to record the beautiful moments of life, resulting in more and more photos stored in electronic devices (such as mobile phones, computers, tablets, etc.). As a result, various methods for managing a large number of photos in electronic devices have begun to emerge. For example, photos are classified and managed based on the year they were taken. Another example is management based on the relationship between people.
[0003] In the related method, the relationship between characters can be constructed through the knowledge graph. However, the related method still has the problem of inaccurate character relationship construction. Summary of the invention
[0004] In view of the above problems, the present application proposes a method, device and electronic device for establishing character relationships to improve the above problems.
[0005] In a first aspect, the present application provides a method for constructing character relationships, which is applied to an electronic device, and the method includes: obtaining attribute information of characters included in multiple images to be processed, the attribute information including age information, gender information and the number of occurrences of each character in the multiple images to be processed; obtaining a target image, the target image being an image containing multiple characters in the multiple images to be processed; obtaining a relationship voting result of a target character group based on the target image and a pre-trained network model, the network model being used to predict the relationship of the target character group, the relationship voting result being used to record the number of times the target character group is predicted to be a corresponding relationship, the target character group being obtained based on the multiple characters; obtaining the relationship of the target character group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target character group.
[0006] In a second aspect, the present application provides a device for constructing character relationships, which runs on an electronic device, and the device includes: obtaining attribute information of characters included in multiple images to be processed, the attribute information including age information, gender information and the number of occurrences of each character in the multiple images to be processed; obtaining a target image, which is an image containing multiple characters in the multiple images to be processed; obtaining a relationship voting result of a target character group based on the target image and a pre-trained network model, the network model being used to predict the relationship of the target character group, the relationship voting result representing the number of times the target character group is predicted to be a corresponding relationship, and the target character group is obtained based on the multiple characters; obtaining the relationship of the target character group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target character group.
[0007] In a third aspect, the present application provides an electronic device comprising one or more processors and a memory; one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.
[0008] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores program code, wherein the above method is executed when the program code is run.
[0009] The present application provides a method, device, electronic device and storage medium for constructing character relationships. After obtaining the attribute information of the characters included in a plurality of images to be processed, including the age information, gender information and the number of occurrences of each character in the images to be processed, an image containing a plurality of characters in the plurality of images to be processed is obtained. Based on the target image and a pre-trained network model for predicting the relationship of the target character group, a relationship voting result for recording the number of times the target character group is predicted to be a corresponding relationship is obtained for the target character group obtained based on the plurality of characters. Based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target character group, the relationship of the target character group is obtained. Through the above-mentioned method, after obtaining the relationship voting result of the target character group based on the target image and the pre-trained network model, the relationship voting result can be screened by the age information, gender information and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 A flowchart of a method for establishing a character relationship proposed in an embodiment of the present application is shown;
[0012] Figure 2 A schematic diagram of a plurality of images to be processed proposed in the present application is shown;
[0013] Figure 3 A schematic diagram showing a target person group in a target image proposed in the present application is shown;
[0014] Figure 4 A flowchart of a method for establishing a character relationship proposed in another embodiment of the present application is shown;
[0015] Figure 5 A flowchart of a method for establishing a character relationship proposed in another embodiment of the present application is shown;
[0016] Figure 6 A schematic diagram of a core character group proposed in the present application is shown;
[0017] Figure 7 A structural block diagram of a character relationship building device proposed in an embodiment of the present application is shown;
[0018] Figure 8 A structural block diagram of an electronic device proposed in this application is shown;
[0019] Fig. 9 It is a storage unit of an embodiment of the present application for storing or carrying program codes for implementing the method for establishing character relationships according to an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0021] As the shooting quality of cameras in electronic devices (such as mobile phones, computers, tablets, etc.) improves, people are increasingly fond of taking photos to record the beautiful moments of life, resulting in more and more photos stored in electronic devices. In order to enable users to quickly find the photos they need, a large number of photos can be associated through the relationship between characters. In some ways, the relationship between characters can be constructed through knowledge graphs.
[0022] The inventor discovered in related research that the related character relationship construction method still has the problem of inaccurate character relationship construction.
[0023] Therefore, the inventor proposes a method, device and electronic device for constructing character relationships in the present application. After obtaining the attribute information of the characters included in multiple images to be processed, including the age information, gender information and the number of occurrences of each character in the multiple images to be processed, an image containing multiple characters in the multiple images to be processed is obtained, and based on the target image and a pre-trained network model for predicting the relationship of the target character group, a relationship voting result for recording the number of times the target character group is predicted to be a corresponding relationship is obtained for the target character group obtained based on the multiple characters, and the relationship of the target character group is obtained based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target character group. Through the above method, after obtaining the relationship voting result of the target character group based on the target image and the pre-trained network model, the relationship voting result can be screened by the age information, gender information and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction.
[0024] See also Figure 1 , a method for establishing a character relationship provided in an embodiment of the present application is applied to an electronic device, and the method includes:
[0025] S110: Acquire attribute information of persons included in a plurality of images to be processed, wherein the attribute information includes age information, gender information, and the number of times each person appears in the plurality of images to be processed.
[0026] The image to be processed may refer to an image whose character relationship is to be confirmed. The image to be processed may be an image in an album in an electronic device.
[0027] As one approach, multiple images to be processed can be first input into a pre-trained face recognition model to obtain the identity and number of occurrences of each person in the multiple images to be processed; then the multiple images to be processed that contain people are input into a pre-trained multi-task model to obtain the age information and gender information of each person in the corresponding image.
[0028] Among them, the face recognition model can be used to extract the feature information of the face in the image to be processed, and assign different identity identifiers to the corresponding person based on different face feature information. The face recognition model can be a convolutional neural network model, etc. Each identity identifier can be used to represent a unique person, and the identity identifier can be an ID (Identity Document). A multi-task model can refer to a model that completes multiple tasks at the same time. In an embodiment of the present application, the multi-task model can be used to predict the age and gender of a person.
[0029] Optionally, after the face recognition model extracts the feature information of a face, the feature information can be compared with pre-stored feature information. If there is pre-stored feature information that is the same as the feature information, the number of occurrences of the person corresponding to the feature information can be increased by 1. If the pre-stored feature information is different from the feature information, the person corresponding to the feature information can be assigned a new identity and the feature information can be stored.
[0030] Optionally, all persons in the multiple images to be processed can be represented by an identity set {id1, id2, ..., id m}, where m can be a positive integer, and m can represent the number of all characters in the multiple images to be processed. The number of occurrences of all characters in the multiple images to be processed can be represented by the list list_count = {num1, num2, ..., num m} means that m can be a positive integer, and num m Can represent character id m The number of occurrences of .
[0031] For example, multiple images to be processed may be Figure 2 As shown, by inputting multiple images to be processed into a pre-trained face recognition model, 6 different characters are identified, thereby obtaining an identity set {001, 002, 003, 004, 005, 006}. The number of occurrences of each character can be expressed as list_count = {1, 4, 1, 2, 1, 1}.
[0032] As another method, when storing the image to be processed, the electronic device can directly predict the age and gender of the person in the image to be processed based on the attribute information extraction algorithm of the electronic device, and associate the predicted age and gender with the image to be processed and store them in a specified location, so that the age information and gender information of each person in the image can be obtained from the specified location. In addition, multiple images to be processed can be input into a pre-trained face recognition model to obtain the identity and number of occurrences of each person in the multiple images to be processed.
[0033] It should be noted that the same person may appear in different images to be processed, and because each image to be processed has a different storage time, the same person may also be dressed differently. Therefore, the age information and gender information obtained for the same person in different images to be processed may also be different. For example, person 1 may be a 35-year-old woman. In image A to be processed, person 1 may have long hair and makeup, so the recognized age may be 28 and the gender may be female; in image B to be processed, person 1 may have short hair and no makeup, so the recognized age may be 35 and the gender may be male.
[0034] S120: Acquire a target image, where the target image is an image containing multiple persons among the multiple images to be processed.
[0035] As a method, after the face is recognized in step S110, each image to be processed can be associated with the person identification and the number of people recognized in the corresponding image to be processed to obtain a mapping relationship list, so that the target image can be obtained based on the mapping relationship list. Figure 2 The generated mapping relationship list can be {image 1: (001, 002, 2), ..., image 5: (005, 1), image 6: (002, 004, 006, 3)}, and the target images can be image 1, image 2, image 3, image 4, image 6.
[0036] S130: Based on the target image and a pre-trained network model, a relationship voting result of a target person group is obtained, wherein the network model is used to predict the relationship of the target person group, and the relationship voting result is used to record the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons.
[0037] Among them, the network model can refer to a model used to predict the relationship between the target person group, and the network model can be a convolutional network model, a transformer, a graph neural network, etc.
[0038] The target person group may include multiple persons whose relationships are to be determined. Optionally, the target person group may refer to any two persons in the same target image. For example, Figure 3 As shown, Figure 3 There are target image 1 and target image 2. The target person group in target image 1 can be (001, 002), and the target person group in target image 2 can be (002, 003), but 001 in target image 1 and 003 in target image 2 cannot form a target person group.
[0039] Optionally, the target person group may also refer to any two persons in the target image whose appearance times in the multiple images to be processed are greater than or equal to a preset number of times. The preset number of times may be obtained based on multiple test results.
[0040] Exemplarily, the characters in the target image may include character 1, character 2 and character 3, the preset number may be 5, the number of times character 1 appears in multiple images to be processed may be 6, the number of times character 2 appears in multiple images to be processed may be 4, and the number of times character 3 appears in multiple images to be processed may be 8, then the target character group of the target image may be (character 1, character 3).
[0041] In an embodiment of the present application, by determining the target person group by a preset number of times, the number of target person groups in the target image can be reduced, thereby eliminating the need to calculate the relationship between people who do not often appear in the life of the user corresponding to the electronic device and other people, thereby saving computing resources and improving the electronic device's management of multiple photos to be processed to be closer to the user's life, thereby improving the user experience.
[0042] The relationship of the target person group can be a lover relationship or a parent-child relationship or other relationships, and the parent-child relationship can be subdivided into a mother-daughter relationship or a mother-son relationship or a father-daughter relationship or a father-son relationship. Each relationship can be represented by a different number, for example, 0 can represent a lover relationship, 1 can represent a mother-daughter relationship, 2 can represent a mother-son relationship, 3 can represent a father-daughter relationship, 4 can represent a father-son relationship, and 5 can represent other relationships. The relationship voting result of the target person group can be expressed as {0:V0, 1:V1, 2:V2, 3:V3, 4:V4, 5:V5}, where V0 can represent the number of times the target person group is predicted to be a lover relationship, V1 can represent the number of times the target person group is predicted to be a mother-daughter relationship, ..., V5 can represent the number of times the target person group is predicted to be other relationships.
[0043] As a method, the target images can be input into a pre-trained network model respectively to obtain the predicted relationship of the target person group in each target image, and based on the predicted relationship of the target person group in the target image, the relationship voting result of the target person group is obtained.
[0044] For example, please refer again Figure 2 , the target person group in image 3 can be (002, 004), and there can be 3 target person groups in image 5, namely (002, 004), (002, 006), and (004, 006). The relationship of (002, 004) in image 3 is predicted as a lover relationship by the pre-trained network model, and the relationship of (002, 004) in image 5 is predicted as a lover relationship by the pre-trained network model, then the relationship voting result of (002, 004) can be {0:2, 1:0, 2:0, 3:0, 4:0, 5:0}. The relationship of (002, 006) in image 5 is predicted as a parent-child relationship by the pre-trained network model, then the relationship voting result of (002, 006) can be {0:0, 1:0, 2:0, 3:0, 4:1, 5:0}. The relationship (004, 006) in image 5 is predicted by the pre-trained network model to be a mother-child relationship, so the relationship voting result of (002, 006) can be {0:0, 1:0, 2:1, 3:0, 4:0, 5:0}.
[0045] S140: Obtaining the relationship of the target person group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target person group.
[0046] As one approach, you can first get the age difference of the target person group based on the age information corresponding to the target person group; get the updated relationship voting result based on the age difference of the target person group and the relationship voting result; then get the relationship of the target person group based on the gender information, number of occurrences and updated relationship voting result corresponding to the target person group.
[0047] As another method, the updated relationship voting results can be obtained based on the gender information, number of occurrences and relationship voting results corresponding to the target person group; then the age difference of the target person group can be obtained based on the age information corresponding to the target person group; and the relationship of the target person group can be obtained based on the age difference corresponding to the target person group and the updated relationship voting results.
[0048] The present embodiment provides a method for constructing character relationships. After obtaining attribute information of characters included in a plurality of images to be processed, including age information, gender information in the image where each character is located, and the number of occurrences of each character in the plurality of images to be processed, an image containing a plurality of characters in the plurality of images to be processed is obtained. Based on the target image and a pre-trained network model for predicting the relationship of the target character group, a relationship voting result for recording the number of times the target character group is predicted to be a corresponding relationship is obtained for the target character group obtained based on the plurality of characters. Based on the age information, gender information, number of occurrences corresponding to the target character group and the relationship voting result, the relationship of the target character group is obtained. Through the above-mentioned method, after obtaining the relationship voting result of the target character group based on the target image and the pre-trained network model, the relationship voting result can be screened by the age information, gender information, and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction.
[0049] See also Figure 4 , a method for establishing a character relationship provided in an embodiment of the present application is applied to an electronic device, and the method includes:
[0050] S210: Acquire attribute information of persons included in a plurality of images to be processed, wherein the attribute information includes age information, gender information, and the number of times each person appears in the plurality of images to be processed.
[0051] The attribute information may also include the shooting time of the image of each person. The shooting time may refer to the initial generation time of the image to be processed.
[0052] As a method, after completing the shooting of an image, the electronic device stores the image in association with the shooting time of the image, such as {img1:id1:October 1, 2009}, so that the shooting time of each image containing a person can be obtained based on the stored content.
[0053] It should be noted that since the multiple images to be processed may include images downloaded by users from the Internet or social networking sites, social applications, etc., and the initial generation time of these images downloaded from the Internet or social networking sites, social applications, etc. is uncertain, some of the multiple images to be processed may have no shooting time.
[0054] S220: Acquire a target image, where the target image is an image containing multiple persons among the multiple images to be processed.
[0055] S230: Based on the target image and a pre-trained network model, a relationship voting result of the target person group is obtained, wherein the network model is used to predict the relationship of the target person group, and the relationship voting result is used to record the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons.
[0056] S240: Obtaining the age difference of the target person group based on the age information corresponding to the target person group.
[0057] As a method, the shooting time of each image of multiple persons in the target person group can be obtained; based on the shooting time of each image of multiple persons in the target person group, the corresponding age correction value of each of the multiple persons in the target person group is obtained; based on the corresponding age correction value of each of the multiple persons in the target person group, the real age of each of the multiple persons in the target person group is obtained; based on the real age of each of the multiple persons in the target person group, the age difference of the target person group is obtained.
[0058] Optionally, the age compensation value of each corresponding image of the multiple characters in the target character group can be determined based on the shooting time and current time of each image of the multiple characters in the target character group; and the age correction value corresponding to each of the multiple characters in the target character group can be obtained based on the age information of each of the multiple characters in the target character group and the age compensation value of each corresponding image.
[0059] Optionally, the age compensation values of the images corresponding to the multiple characters in the target character group can be determined based on the year information in the shooting time of the images in which the multiple characters in the target character group are located and the year information of the current time. Exemplarily, the shooting time of the image A in which the character 001 is located can be October 1, 2009, and the current time can be March 8, 2013, then the age compensation value can be 4 (2013-2009); the shooting time of the image B in which the character 001 is located can be October 20, 2010, and the current time can be March 8, 2013, then the age compensation value can be 3 (2013-2010).
[0060] Optionally, the age information of each of the multiple characters and the age compensation values of the corresponding images may be added together to obtain the age correction values corresponding to each of the multiple characters. The calculation formula of the age correction value may be:
[0061] age ij2 =age ij1 +delta ij
[0062] Among them, age ij1 Can represent identity as id iThe age information of the person in the image when he appears for the jth time in multiple images to be processed, delta ij Can represent identity as id i The age compensation value in the image where the j-th occurrence occurs in the multiple images to be processed.
[0063] In an embodiment of the present application, an age compensation value is obtained by the shooting time of the image of the person and the current time, and then an age correction value is obtained based on the age compensation value and the age information, so that the current age information of the person can be obtained, thereby improving the accuracy of the person's real age.
[0064] It should be noted that before calculating the age compensation values of the images corresponding to the multiple persons respectively, the to-be-processed images without shooting time corresponding to the multiple persons in the target person group respectively can be filtered out.
[0065] For example, the identity is id i The character appears k times in multiple images to be processed. The age information of the character can be expressed as list_age i1 ={age i11 ,age i21 , ..., age ik1}, after filtering out the images without photo time, the age information corresponding to the person can be expressed as list_has_time_age i1 ={age i11 ,age i11 , ..., age ip1}, where (p ≦ k). Based on list_has_time_age i1 The age compensation value corresponding to each age in list_has_time_age i1 You can get the age correction value of the character by list_has_time_age i2 ={age i12 ,age i22 , ..., age ip2}.
[0066] Optionally, when there can be multiple age correction values, the age standard deviation corresponding to each of the multiple characters in the target character group can be obtained based on the multiple age correction values corresponding to each of the multiple characters in the target character group; if there is a first person among the multiple characters in the target character group, the average of the multiple age correction values of the first person is taken as the real age of the first person, and the first person may be a person whose age standard deviation is less than or equal to a first threshold value among the multiple characters; if there is a second person among the multiple characters in the target character group, the erroneous age correction value is removed from the multiple age correction values of the second person to obtain multiple age correction values of the second person after removing errors, and the erroneous age correction value may be the age correction value of the first designated position and the last designated position after sorting the multiple age correction values of the second person in order from small to large, and the second person may be a person whose age standard deviation is greater than the first threshold value among the multiple characters; based on the multiple age correction values after removing errors, the real age of the second person is obtained.
[0067] Optionally, the calculation formula for the age standard deviation can be:
[0068]
[0069] Among them, p can represent the participating identity as id i The number of images to be processed for calculating the standard deviation of the age of the characters, age ij2 Can represent identity as id i The age correction value of the person when he appears for the jth time in the image to be processed that participates in the calculation of the age standard deviation, Can represent character id i The average value of the age correction values of the corresponding p images to be processed.
[0070] Optionally, the first threshold may be based on the participant identity id i The number of images for calculating the standard deviation of the age of the character is determined, and the more the number of to-be-processed images involved in the calculation is, the smaller the first threshold can be.
[0071] Optionally, the first threshold may be a value predetermined based on multiple test results.
[0072] Optionally, the designated digit corresponding to the erroneous age correction value may be a positive integer obtained based on multiple test results. For example, the erroneous age correction value may be the age correction values ranked in the first 2 digits and the last 2 digits after sorting the multiple age correction values of the second character in ascending order.
[0073] Optionally, the designated position corresponding to the erroneous age correction value may be a preset proportion of the total age correction value of each character. For example, the erroneous age correction value may be the age correction value in the top 10% and the bottom 10% after sorting the multiple age correction values of the second character in ascending order.
[0074] It should be noted that, when the designated digit obtained based on the preset ratio is not a positive integer, the designated digit obtained based on the preset ratio may be rounded to obtain an integer.
[0075] For example, the first threshold may be 4, the preset ratio may be 10%, and the target person group may include person IDs i and character id m , character id i The corresponding age correction value can be list_has_time_age i2 ={22, 24, 25, 25, 24, 23, 23, 24, 26, 24}, then can be 24, age_σ i Can be 1.09, then the character id i Can be the first character, character id i The real age can be 24; character id m The corresponding age correction value can be list_has_time_age m2 ={27, 28, 29, 30, 32, 33, 35, 36, 40, 40}, then can be 33, age_σ m Can be 4.45, then the character id m Can be the second character, character id m The corrected values of multiple ages after removing errors can be list_has_time_age m2 ={28, 29, 30, 32, 33, 35, 36, 40}.
[0076] Optionally, the standard deviation of the age of the second character can be obtained based on multiple age-corrected values after removing errors; if the standard deviation of the age of the second character is greater than a first threshold, the erroneous age-corrected values of the second character continue to be removed from the multiple age-corrected values after removing errors obtained last time to obtain multiple age-corrected values after removing errors, until the standard deviation of the age of the second character is less than or equal to the first threshold; the average of the multiple age-corrected values of the second character after removing errors is taken as the true age of the second character.
[0077] For example, character id m The corrected values of multiple ages after removing errors can be list_has_time_age m2 ={28, 29, 30, 32, 33, 35, 36, 40}, then can be 32.87, age_σ m It can be 3.85, then the character id mIf the age standard deviation is less than or equal to the first threshold, the real age of the second character may be 32.87.
[0078] In the embodiment of the present application, by continuously screening the age standard deviation of the age correction value through the first threshold, the influence of the instability of the algorithm related to age recognition on the age information can be reduced, thereby improving the accuracy of the real age of the person.
[0079] S250: Obtaining updated relationship voting results based on the age difference of the target person group and the relationship voting results.
[0080] As a method, if the age difference is greater than the second threshold, or the real age of the first character is less than the third threshold, or the real age of the second character is less than the third threshold, the number of times corresponding to the lover relationship in the relationship voting result is updated to the target value, the second threshold can represent the maximum age difference between two people in a lover relationship, and the third threshold can represent the minimum age of people in a lover relationship; if the age difference is less than the fourth threshold or the age difference is greater than the fifth threshold, the number of times corresponding to the parent-child relationship in the relationship voting result is set to the target value, the fourth threshold is the minimum age difference between two people in a parent-child relationship, and the fifth threshold is the maximum age difference between two people in a parent-child relationship.
[0081] The second threshold, the third threshold, the fourth threshold, and the fifth threshold may all be obtained based on big data statistical results. The target value may be a predetermined value, for example, the target value may be 0.
[0082] For example, the second threshold, the third threshold, the fourth threshold, and the fifth threshold may be 10, 18, 21, and 30, respectively, the target value may be 0, and the target person group may include person IDs. i and character id m , the relationship voting result of the target person group can be expressed as {0:20, 1:15, 2:2, 3:1, 4:0, 5:18}, when the person id i The real age is 25, character id m When the real age is 28, the parent-child relationship in the updated relationship voting result can be {0:20, 1:0, 2:0, 3:0, 4:0, 5:18}; when the character id i The real age is 15, character id m When the real age is 38, the updated relationship voting result can be {0:0, 1:15, 2:2, 3:1, 4:0, 5:18}.
[0083] S260: Obtaining the relationship of the target person group based on the gender information, the number of occurrences and the updated relationship voting results corresponding to the target person group.
[0084] The target person group includes multiple persons whose relationships are to be determined, and each person may have multiple pieces of gender information.
[0085] As a method, based on the multiple gender information corresponding to the multiple characters in the target character group, the number information of each of the multiple characters in the target character group can be determined, and the number information can be the number of females for each of the multiple characters in the target character group, or the number of males for each of the multiple characters in the target character group; based on the number information and the number of appearances of each of the multiple characters in the target character group, the real gender of each of the multiple characters in the target character group is obtained; based on the real gender of each of the multiple characters in the target character group and the updated relationship voting results, the relationship of the target character group is obtained.
[0086] Optionally, the real gender of each of the multiple characters in the target character group can be obtained based on the ratio of the quantity information to the number of occurrences. When the quantity information is the number of male gender information of each of the multiple characters in the target character group, the calculation formula for the real gender is:
[0087]
[0088] Among them, k_per can represent the ratio of quantity information to the number of occurrences, k_per=k1 / k, k1 can represent quantity information, and k can represent the number of occurrences. When k_per≥0.8, it can be indicated that the gender of the character is male; when 0.2<k_per<0.8, it can be indicated that the gender of the character is unknown; when k_per≤0.2, it can be indicated that the gender of the character is female.
[0089] For example, character id i The gender information can be list_gender i ={male, male, unknown, male, male}, k_per = 4 / 5 = 0.8, then the character id i The real gender can be male.
[0090] In the embodiment of the present application, the real gender of a person is determined by the ratio of quantity information to the number of occurrences, which can avoid the influence of the instability of the algorithm related to gender recognition on the gender information, thereby improving the accuracy of the real gender of the person.
[0091] Optionally, if the updated relationship voting result indicates that the relationship of the target character group is a parent-child relationship, based on the real gender of each of the multiple characters in the target character group, the relationship of the target character group is determined to be a mother-daughter relationship, a mother-son relationship, a father-daughter relationship, or a father-son relationship; if the updated relationship voting result indicates that the relationship of the target character group is not a parent-child relationship, based on the real gender of each of the multiple characters in the target character group, the relationship of the target character group is determined to be a lover relationship or other relationship.
[0092] Optionally, the relationship with the largest number of votes in the updated relationship voting results can be used as the relationship of the target person group represented by the updated relationship voting results. Exemplarily, the updated relationship voting results can be {0:0, 1:15, 2:2, 3:1, 4:0, 5:0}, and the updated relationship voting results represent that the relationship of the target person group is a mother-daughter relationship.
[0093] Exemplarily, if the updated relationship voting result indicates that the relationship of the target person group is a parent-child relationship, and the real genders of the characters included in the target person group are male and female, respectively, then it can be determined that the relationship of the target person group may be a father-daughter relationship or a mother-son relationship, and then the relationship of the target person group is obtained based on the number of votes for the father-daughter relationship and the mother-daughter relationship in the updated relationship voting result. Among them, if the number of votes for the father-daughter relationship is greater than the number of votes for the mother-son relationship, the relationship of the target person group may be a father-daughter relationship; if the number of votes for the father-daughter relationship is less than the number of votes for the mother-son relationship, the relationship of the target person group may be a mother-son relationship; if the number of votes for the father-daughter relationship is equal to the number of votes for the mother-son relationship and the age of the man is greater than the age of the woman, the relationship of the target person group may be a father-daughter relationship; if the number of votes for the father-daughter relationship is equal to the number of votes for the mother-son relationship and the age of the man is less than the age of the woman, the relationship of the target person group may be a mother-son relationship.
[0094] Optionally, if the updated relationship voting results indicate that the relationship of the target person group is a parent-child relationship, and the true gender of a person in the target person group is unknown, the relationship of the target person group can be determined as a mother-daughter relationship, a mother-son relationship, a father-daughter relationship, or a father-son relationship based on the updated relationship voting results.
[0095] Exemplarily, the real genders of the characters included in the target character group are all unknown, and the father-daughter relationship has the largest number of votes in the updated relationship voting results, then the relationship of the target character group may be a father-daughter relationship.
[0096] Optionally, if the updated relationship voting results indicate that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are different, the relationship of the target person group can be determined to be a lover relationship or other relationship based on the corresponding number of lover relationships and other relationships in the updated relationship voting results; if the updated relationship voting results indicate that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are the same, the relationship of the target person group is determined to be other relationships.
[0097] Optionally, if the updated relationship voting results indicate that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are different, the number of times corresponding to the lover relationship in the updated relationship voting results can be compared with the number of times corresponding to other relationships. If the number of times corresponding to the lover relationship is greater than the number of times corresponding to other relationships, it can be determined that the relationship of the target person group is a lover relationship; if the number of times corresponding to the lover relationship is less than the number of times corresponding to other relationships, it can be determined that the relationship of the target person group is other relationships; if the number of times corresponding to the lover relationship is equal to the number of times corresponding to other relationships, a relationship can be randomly selected from the lover relationship and the other relationships as the relationship of the target person group.
[0098] Optionally, when the number of times corresponding to the lover relationship is equal to the number of times corresponding to other relationships, the relationship of the target person group can also be confirmed based on user feedback information. Exemplarily, the electronic device can pop up a relationship confirmation interface, which can include a relationship selection window, prompt information, and an image including the target person group. The prompt information can be used to prompt the user to select a relationship of the target person group. The relationship selection window can include lover relationships and other relationships. The electronic device can determine the relationship of the target person group based on the user's click operation on the relationship selection window.
[0099] It should be noted that, in the process of obtaining the relationship of the target person group by another method in step S140 (first obtaining the relationship of the target person group based on the gender information and the number of occurrences corresponding to the target person group), the method of obtaining the real age, real gender, etc. of the person can be the same as the method of the corresponding content in steps S210 to S260. Exemplarily, the relationship voting result of the target person group can be {0:20, 1:10, 2:15, 3:8, 4:2, 5:9}. When the real genders of the multiple characters in the target person group are obtained as men and women based on the ratio of the age information of the multiple characters in the target person group to the number of occurrences, the number of votes corresponding to the mother-daughter relationship and the father-son relationship can be updated to the target value, and the updated relationship voting result can be {0:20, 1:0, 2:15, 3:8, 4:0, 5:9}. Then, based on the real age of the multiple characters in the target person group, the age difference is greater than the first threshold, and it can be confirmed that the relationship of the target person group can be a lover relationship.
[0100] The method for constructing character relationships provided in this embodiment can, through the above-mentioned method, after obtaining the relationship voting results of the target character group based on the target image and the pre-trained network model, screen the relationship voting results by the age information, gender information, and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction. In addition, in this embodiment, the relationship of the target character group is gradually confirmed by the age difference and true gender between the characters in the target task group, which can improve the accuracy of the target character group relationship construction.
[0101] See also Figure 5 , a method for establishing a character relationship provided in an embodiment of the present application is applied to an electronic device, and the method includes:
[0102] S310: Acquire attribute information of persons included in a plurality of images to be processed, wherein the attribute information includes age information, gender information, and the number of times each person appears in the plurality of images to be processed.
[0103] S320: Acquire a target image, where the target image is an image containing multiple persons among the multiple images to be processed.
[0104] S330: Based on the target image and a pre-trained network model, a relationship voting result of the target person group is obtained, wherein the network model is used to predict the relationship of the target person group, and the relationship voting result is used to record the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons.
[0105] S340: Obtaining the relationship of the target person group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target person group.
[0106] There can be multiple target person groups.
[0107] S350: Obtain the core person in the plurality of images to be processed.
[0108] The core character may be the user of the electronic device, or may be a character selected by the user of the electronic device.
[0109] As a method, the electronic device can pop up a core character selection interface, which can include prompt information and multiple images. The prompt information can be used to prompt the user to select one of the characters as the core character and the core character can be used to build a relationship album; the content in each image can be a character, and the number of times the character appears in multiple images to be processed can be at least once. The user can click on the image where the core character is located, and the electronic device can respond to the user's click operation and use the character in the corresponding image as the core character.
[0110] As another way, when the electronic device stores the user's facial unlocking information (i.e., the user's face), the facial unlocking information can be directly matched with the facial features of all the characters in multiple images to be processed, and the successfully matched characters can be used as core characters.
[0111] S360: Obtaining a core person group from the multiple target person groups based on the core person, the core person group being a target person group including the core person.
[0112] As one approach, a core character group may be obtained based on the identity identifier of the core character and the identity identifiers of characters included in multiple target character groups.
[0113] S370: Based on the relationship between the core character group, obtain the relationship between the core character and other characters.
[0114] As a way, the relationship between the core character and other characters can be obtained based on the relationship between the core character group.
[0115] For example, see Figure 6 , the core character can be 002, the core character group and the relationship between the corresponding core character groups can be: (001, 002, 0), (002, 003, 0), (002, 004, 0), (002, 006, 4), which means that the core character has a lover relationship with 001, a lover relationship with 003, a lover relationship with 004, and a father-son relationship with 006.
[0116] Optionally, if it is determined that the core character has a romantic relationship with multiple characters based on the relationship between the core character and other characters, the multiple characters are used as multiple candidate lovers; based on the number of appearances of the multiple candidate lovers, the time discreteness in the multiple images to be processed and the relationship voting results of the corresponding core character group, the real lovers are determined, and the relationships between the remaining candidate lovers and the core character are updated to other relationships.
[0117] Among them, the temporal discreteness of the character in multiple images to be processed can represent the intimacy of the relationship between the character and the core character. The smaller the temporal discreteness, the higher the frequency of meeting between the character and the core character, and the closer the relationship.
[0118] Optionally, the standard deviation of the shooting time of each candidate lover's image can be used as the time dispersion of the candidate lover. The shooting time can be accurate to natural days, and the standard deviation can be calculated by the timestamp corresponding to the shooting time to obtain the time dispersion.
[0119] Optionally, the lover scores of the multiple candidate lovers can be obtained based on the number of appearances of the multiple candidate lovers, the time dispersion in the multiple images to be processed, and the relationship voting results of the corresponding core character group, and the candidate lover with the largest lover score is taken as the real lover. The calculation formula of the lover score can be:
[0120] w i =V0 i *s1+num i *s2+σ i *s3
[0121] Among them, V0 i Can represent identity as id i The candidate lover's corresponding relationship voting result is the candidate lover's id i The number of times the core character is predicted to be in a romantic relationship, num i Can represent identity as id i The number of candidate lovers, σ i Can represent identity as id i The temporal discreteness of the candidate lovers in multiple images to be processed, s1, s2, s3 can represent the corresponding weight coefficients respectively, and the sum of s1, s2, s3 is 1.
[0122] For example, please refer again Figure 2 , the core character can be 002 and 001, 003, 004 are all lovers, w 001 、w 003 、w 004 They can be 10, 12, and 60 respectively, then 004 is the real lover of 002, and the relationship between 002 and 001 and 003 is updated to other relationships.
[0123] Optionally, the parents and candidate children of the core character can be obtained based on the relationship between the core character and other characters; if it is determined from the relationships of multiple target character groups that the relationship between the real lover and the candidate child is not a parent-child relationship, the relationship between the candidate child and the core character is updated to other relationships; if it is determined from the relationships of multiple target character groups that the relationship between the real lover and the candidate child is a parent-child relationship, the candidate child is determined to be the real child of the core character and the real lover.
[0124] The present embodiment provides a method for constructing character relationships. Through the above-mentioned method, after obtaining the relationship voting results of the target character group based on the target image and the pre-trained network model, the relationship voting results can be screened by the age information, gender information, and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction. In addition, in the present embodiment, by obtaining the relationship between the core character and other characters, basic information can be provided for the electronic device to manage the album based on the relationship between the core character and other characters, thereby improving the efficiency and accuracy of the electronic device album management. In addition, after obtaining the relationship between the core character and other characters, when it is determined that the core character has the same relationship with different characters, the relationship can be sorted out again based on the pre-set rules, so that the obtained relationship is more in line with the current actual situation, thereby improving the accuracy of the relationship between the core character and other characters.
[0125] See also Figure 7 The present application provides a character relationship building device 600, which runs on an electronic device, and the device 600 includes:
[0126] The attribute information acquisition unit 610 is used to acquire the attribute information of the persons included in the multiple images to be processed, wherein the attribute information includes the age information, gender information and the number of times each person appears in the multiple images to be processed.
[0127] The target image acquisition unit 620 is used to acquire a target image, where the target image is an image containing multiple persons among the multiple images to be processed.
[0128] The relationship voting result acquisition unit 630 is used to obtain the relationship voting results of the target person group based on the target image and a pre-trained network model, the network model is used to predict the relationship of the target person group, the relationship voting results represent the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons.
[0129] The relationship acquisition unit 640 is used to obtain the relationship of the target person group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target person group.
[0130] As a method, the relationship acquisition unit 640 is specifically used to obtain the age difference of the target person group based on the age information corresponding to the target person group; obtain the updated relationship voting result based on the age difference of the target person group and the relationship voting result; and obtain the relationship of the target person group based on the gender information, number of occurrences and the updated relationship voting result corresponding to the target person group.
[0131] Optionally, the attribute information also includes the shooting time of the image in which each of the characters is located, and the target character group includes multiple characters whose relationships are to be determined. The relationship acquisition unit 640 is specifically used to obtain the shooting time of the images in which the multiple characters in the target character group are located; based on the shooting time of the images in which the multiple characters in the target character group are located, obtain the corresponding age correction value of the multiple characters in the target character group; based on the corresponding age correction value of the multiple characters in the target character group, obtain the real age of the multiple characters in the target character group; based on the real age of the multiple characters in the target character group, obtain the age difference of the target character group.
[0132] Optionally, the relationship acquisition unit 640 is specifically used to determine the age compensation value of each corresponding image of the multiple characters in the target character group based on the shooting time and current time of the images of the multiple characters in the target character group; and obtain the age correction value corresponding to each of the multiple characters in the target character group based on the age information of each of the multiple characters in the target character group and the age compensation value of each corresponding image.
[0133] Optionally, there are multiple age correction values, and the relationship acquisition unit 640 is specifically used to obtain the age standard deviation corresponding to each of the multiple characters in the target character group based on the multiple age correction values corresponding to each of the multiple characters in the target character group; if there is a first person in the target character group, the average of the multiple age correction values of the first person is used as the real age of the first person, and the first person is a person whose age standard deviation is less than or equal to a first threshold among the multiple characters; if there is a second person in the target character group, the erroneous age correction value is removed from the multiple age correction values of the second person to obtain multiple age correction values of the second person after removing errors, and the erroneous age correction value is the age correction value of the first and last designated positions after sorting the multiple age correction values of the second person in order from small to large, and the second person is a person whose age standard deviation is greater than the first threshold among the multiple characters; based on the multiple age correction values after removing errors, the real age of the second person is obtained.
[0134] Optionally, the relationship acquisition unit 640 is specifically used to obtain the standard deviation of the age of the second person based on the multiple age-corrected values after removing errors; if the standard deviation of the age of the second person is greater than the first threshold, continue to remove the erroneous age-corrected values of the second person from the multiple age-corrected values after removing errors obtained last time to obtain multiple age-corrected values after removing errors, until the standard deviation of the age of the second person is less than or equal to the first threshold; and take the average of the multiple age-corrected values of the second person after removing errors as the true age of the second person.
[0135] Optionally, the relationship acquisition unit 640 is specifically used to update the number of times corresponding to the lover relationship in the relationship voting result to the target value if the age difference is greater than a second threshold, or the real age of the first character is less than a third threshold, or the real age of the second character is less than the third threshold; if the age difference is less than a fourth threshold or the age difference is greater than a fifth threshold, set the number of times corresponding to the parent-child relationship in the relationship voting result to the target value.
[0136] Optionally, the target person group includes multiple persons whose relationships are to be determined, and each of the persons has multiple gender information. The relationship acquisition unit 640 is specifically used to determine the quantity information of each of the multiple persons in the target person group based on the multiple gender information corresponding to each of the multiple persons in the target person group, wherein the quantity information is the number of females for each of the multiple persons in the target person group, or the number of males for each of the multiple persons in the target person group; based on the quantity information and the number of occurrences of each of the multiple persons in the target person group, the real gender of each of the multiple persons in the target person group is obtained; based on the real gender of each of the multiple persons in the target person group and the updated relationship voting results, the relationship of the target person group is obtained.
[0137] Optionally, the relationship acquisition unit 640 is specifically used to determine whether the relationship of the target person group is a mother-daughter relationship, a mother-son relationship, a father-daughter relationship, or a father-son relationship if the updated relationship voting result indicates that the relationship of the target person group is a parent-child relationship, based on the real gender of each of the multiple characters in the target person group; if the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, based on the real gender of each of the multiple characters in the target person group, determine whether the relationship of the target person group is a lover relationship or other relationship.
[0138] Optionally, the relationship acquisition unit 640 is specifically used to determine that the relationship of the target person group is a lover relationship if the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are different; if the updated relationship voting result indicates that the relationship between the first person and the second person is not a parent-child relationship, and the real genders of multiple characters in the target person group are the same, determine that the relationship of the target person group is other relationship.
[0139] As a method, the relationship acquisition unit 640 is specifically used to obtain the core character in the multiple images to be processed; based on the core character, a core character group is obtained from the multiple target character groups, and the core character group is a target character group including the core character; based on the relationship of the core character group, the relationship between the core character and other characters is obtained.
[0140] Optionally, the relationship acquisition unit 640 is specifically used to, if it is determined that the core character has a lover relationship with multiple characters based on the relationship between the core character and other characters, use the multiple characters as multiple candidate lovers; determine the real lovers based on the number of appearances of the multiple candidate lovers, the relationship voting results of the corresponding core character group and the time discreteness in the multiple images to be processed, and update the relationship between the remaining candidate lovers and the core character to other relationships.
[0141] Optionally, the relationship acquisition unit 640 is specifically used to obtain the parents and candidate children of the core character based on the relationship between the core character and other characters; if it is determined from the relationships between the multiple target character groups that the relationship between the real lover and the candidate child is not a parent-child relationship, the relationship between the candidate child and the core character is updated to other relationships; if it is determined from the relationships between the multiple target character groups that the relationship between the real lover and the candidate child is a parent-child relationship, the candidate child is determined to be the real child of the core character and the real lover.
[0142] The following will be combined Figure 8 An electronic device provided by the present application is described.
[0143] See also Figure 8 Based on the above-mentioned character relationship construction method and device, the embodiment of the present application also provides another electronic device 100 that can execute the above-mentioned character relationship construction method. The electronic device 100 includes a processor 102, a memory 104, and an image acquisition module 106, wherein the memory 104 stores a program that can execute the content of the above-mentioned embodiment, and the processor 102 can execute the program stored in the memory 104.
[0144] Among them, the processor 102 may include one or more processing cores. The processor 102 uses various interfaces and lines to connect various parts within the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 104, and calling data stored in the memory 104. Optionally, the processor 102 can be implemented in at least one hardware form of a network processor (Neural network Processing Unit, NPU), a digital signal processing (Digital Signal Processing, DSP), a field programmable gate array (Field-Programmable Gate Array, FPGA), and a programmable logic array (Programmable Logic Array, PLA). The processor 102 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processor (Graphics Processing Unit, GPU), a network processor (Neural network Processing Unit, NPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing display content; the NPU is responsible for processing multimedia data such as video and images; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 102, but may be implemented separately through a communication chip.
[0145] The memory 104 may include a random access memory (RAM), and may also include a read-only memory (RAM) and a double data rate synchronous dynamic random access memory (DDR). The memory 104 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.
[0146] The image acquisition module 106 can be used to acquire images. The image acquisition module 106 can be a camera or the like.
[0147] Please refer to Fig. 9, which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable storage medium 800 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0148] The computer readable storage medium 800 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer readable storage medium 800 has storage space for program code 810 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in an appropriate form.
[0149] In summary, the present application provides a method, device and electronic device for constructing character relationships. After obtaining the attribute information of the characters included in multiple images to be processed, including the age information, gender information and the number of occurrences of each character in the multiple images to be processed, an image containing multiple characters in the multiple images to be processed is obtained, and based on the target image and a pre-trained network model for predicting the relationship of the target character group, a relationship voting result for recording the number of times the target character group is predicted to be a corresponding relationship is obtained for the target character group obtained based on the multiple characters, and the relationship of the target character group is obtained based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target character group. Through the above method, after obtaining the relationship voting result of the target character group based on the target image and the pre-trained network model, the relationship voting result can be screened by the age information, gender information and number of occurrences corresponding to the target character group to obtain the relationship of the target character group, thereby improving the accuracy of the target character group relationship construction.
[0150] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A method for constructing character relationships, characterized in that: Applied to electronic equipment, the method comprises: Acquire attribute information of persons included in a plurality of images to be processed, wherein the attribute information includes age information, gender information, and the number of times each person appears in the plurality of images to be processed; Acquire a target image, where the target image is an image containing multiple persons among the multiple images to be processed; Based on the target image and a pre-trained network model, a relationship voting result of a target person group is obtained, wherein the network model is used to predict the relationship of the target person group, and the relationship voting result is used to record the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons; Based on the age information, gender information, number of occurrences and the relationship voting results corresponding to the target person group, the relationship of the target person group is obtained.
2. The method according to claim 1, characterized in that The obtaining of the relationship of the target person based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target person group includes: Based on the age information corresponding to the target person group, obtaining the age difference of the target person group; Based on the age difference of the target person group and the relationship voting result, obtaining an updated relationship voting result; Based on the gender information, the number of occurrences and the updated relationship voting results corresponding to the target person group, the relationship of the target person group is obtained.
3. The method according to claim 2, characterized in that The attribute information also includes the shooting time of the image of each person, the target person group includes a plurality of persons whose relationship is to be determined, and obtaining the age difference of the target person group based on the age information corresponding to the target person group includes: Obtaining the shooting time of each image of multiple persons in the target person group; Based on the shooting time of the images of the multiple persons in the target person group, obtaining the corresponding age correction value of the multiple persons in the target person group; Based on the age correction values corresponding to the multiple characters in the target character group, obtaining the real ages of the multiple characters in the target character group; Based on the real ages of the multiple persons in the target person group, the age difference of the target person group is obtained.
4. The method according to claim 3, characterized in that The step of obtaining age correction values corresponding to the plurality of persons in the target person group based on the shooting time of the images of the plurality of persons in the target person group comprises: Determining age compensation values of images corresponding to the multiple persons in the target person group based on the shooting time and current time of the images of the multiple persons in the target person group; Based on the age information of each of the multiple persons in the target person group and the age compensation values of the respective corresponding images, the age correction values corresponding to each of the multiple persons in the target person group are obtained.
5. The method according to claim 3, characterized in that: There are multiple age correction values, and obtaining the real ages of the multiple characters in the target character group based on the age correction values corresponding to the multiple characters in the target character group includes: Based on a plurality of age correction values respectively corresponding to a plurality of persons in the target person group, obtaining a standard deviation of the age respectively corresponding to a plurality of persons in the target person group; If there is a first person among the multiple persons in the target person group, taking the average of the multiple age correction values of the first person as the real age of the first person, the first person being a person whose age standard deviation among the multiple persons is less than or equal to a first threshold; If there is a second person in the target person group, remove the wrong age correction value from the second person's multiple age correction values to obtain the second person's multiple age correction values without errors, the wrong age correction value being the age correction value of the first and last designated positions after sorting the multiple age correction values of the second person in ascending order, and the second person is the person whose age standard deviation is greater than the first threshold value among the multiple persons; Based on the multiple age correction values after removing errors, the real age of the second person is obtained.
6. The method according to claim 5, characterized in that The obtaining the real age of the second person based on the plurality of age correction values after removing errors comprises: Obtaining a standard deviation of the age of the second person based on the plurality of age correction values after removing errors; If the age standard deviation of the second person is greater than the first threshold, continue to remove the erroneous age correction value of the second person from the multiple age correction values obtained previously to obtain multiple age correction values, until the age standard deviation of the second person is less than or equal to the first threshold; The average of the multiple age correction values of the second person after removing errors is used as the real age of the second person.
7. The method according to claim 2, characterized in that The updating of the relationship voting result based on the age difference of the target person group and the relationship voting result includes: If the age difference is greater than a second threshold, or the real age of the first person is less than a third threshold, or the real age of the second person is less than the third threshold, the number of times corresponding to the lover relationship in the relationship voting result is updated to a target value, wherein the second threshold represents the maximum age difference between two people in a lover relationship, and the third threshold represents the minimum age of people in a lover relationship; If the age difference is less than a fourth threshold or the age difference is greater than a fifth threshold, the number of times corresponding to the parent-child relationship in the relationship voting result is set to the target value, the fourth threshold is the minimum age difference between two people in a parent-child relationship, and the fifth threshold is the maximum age difference between two people in a parent-child relationship.
8. The method according to claim 2, characterized in that: The target person group includes a plurality of persons whose relationships are to be determined, each of the persons has multiple pieces of gender information, and obtaining the relationships of the target person group based on the gender information corresponding to the target person group, the number of occurrences, and the updated relationship voting results includes: Based on the multiple gender information corresponding to the multiple characters in the target character group, determine the number information of the multiple characters in the target character group, wherein the number information is the number of the multiple characters in the target character group whose gender information is female, or the number of the multiple characters in the target character group whose gender information is male; Based on the quantity information and the number of occurrences of each of the multiple characters in the target character group, obtaining the real gender of each of the multiple characters in the target character group; Based on the real genders of the multiple characters in the target character group and the updated relationship voting results, the relationship of the target character group is obtained.
9. The method according to claim 8, characterized in that The step of obtaining the relationship of the target person group based on the real genders of the multiple persons in the target person group and the updated relationship voting results includes: If the updated relationship voting result indicates that the relationship of the target person group is a parent-child relationship, based on the real genders of the multiple characters in the target person group, determine that the relationship of the target person group is a mother-daughter relationship, a mother-son relationship, a father-daughter relationship, or a father-son relationship; If the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, based on the real genders of the multiple characters in the target person group, it is determined that the relationship of the target person group is a lover relationship or other relationship.
10. The method according to claim 9, characterized in that If the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, determining that the relationship of the target person group is a lover relationship or other relationship based on the real genders of the multiple characters in the target person group includes: If the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are different, based on the number of times corresponding to the lover relationship and other relationships in the updated relationship voting result, determine that the relationship of the target person group is a lover relationship or other relationship; If the updated relationship voting result indicates that the relationship of the target person group is not a parent-child relationship, and the real genders of multiple characters in the target person group are the same, it is determined that the relationship of the target person group is other relationships.
11. The method according to any one of claims 1 to 10, characterized in that: There are multiple target person groups, and the method further includes: Acquire the core figures in the plurality of images to be processed; Obtaining a core person group from the plurality of target person groups based on the core person, the core person group being a target person group including the core person; Based on the relationship between the core character group, the relationship between the core character and other characters is obtained.
12. The method according to claim 11, characterized in that After obtaining the relationship between the core character and other characters based on the core character group, the method further includes: If it is determined that the core character has a lover relationship with multiple characters based on the relationship between the core character and other characters, the multiple characters are regarded as multiple candidate lovers; Based on the number of appearances of each of the multiple candidate lovers, the relationship voting results of the corresponding core character group and the time dispersion in the multiple images to be processed, the real lover is determined, and the relationship between the remaining candidate lovers and the core character is updated to other relationships.
13. The method according to claim 11, characterized in that The method further comprises: Based on the relationship between the core character and other characters, obtaining the parents and candidate children of the core character; If it is determined from the relationships of the multiple target person groups that the relationship between the real lover and the candidate child is not a parent-child relationship, the relationship between the candidate child and the core person is updated to other relationships; If it is determined from the relationships among the multiple target person groups that the relationship between the real lover and the candidate child is a parent-child relationship, the candidate child is determined to be the real child of the core person and the real lover.
14. A character relationship building device, characterized in that: Running on an electronic device, the device comprises: An attribute information acquisition unit, used to acquire attribute information of characters included in a plurality of images to be processed, wherein the attribute information includes age information, gender information, and the number of times each character appears in the plurality of images to be processed; A target image acquisition unit, used for acquiring a target image, wherein the target image is an image containing multiple persons among the multiple images to be processed; a relationship voting result acquisition unit, configured to obtain a relationship voting result of a target person group based on the target image and a pre-trained network model, wherein the network model is used to predict the relationship of the target person group, the relationship voting result represents the number of times the target person group is predicted to be a corresponding relationship, and the target person group is obtained based on the multiple persons; The relationship acquisition unit is used to obtain the relationship of the target person group based on the age information, gender information, number of occurrences and the relationship voting result corresponding to the target person group.
15. An electronic device, characterized in that: comprising one or more processors and memory; One or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program code, wherein when the program code is run, the method according to any one of claims 1 to 13 is executed.