A portrait clustering method, device, equipment and medium
By receiving the position information and image features of the acquisition device, building an input map and using vector determination models for adaptive clustering, the clustering inaccuracy problem caused by excessive images in the prior art is solved, and the accuracy of portrait clustering is improved.
Patent Information
- Application Number
- CN202210281674.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-21
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-03-21
AI Technical Summary
In the prior art, due to excessive images, the existing methods tend to classify images of different people into the same category.
By receiving the position information of each acquisition device and the images within unit time, an input diagram is constructed and the target acquisition device is determined, and the pre-trained vector determination model is used for adaptive clustering, and classification is performed according to the position and image characteristics of the acquisition device.
It effectively reduces the number of images during classification, improves the accuracy of clustering, and avoids the problem of clustering inaccuracy caused by excessive images.
Smart Images

Figure CN114611623B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a portrait clustering method, device, equipment and medium. Background Art
[0002] With the widespread popularity of intelligent video surveillance equipment, a large number of images containing facial features are accumulated every day. In the existing technology, clustering methods are usually used to cluster and archive the large number of images containing facial features in units of people.
[0003] The commonly used method in the prior art is to classify images based on the facial features in the images after acquiring images captured by the acquisition device within a unit time. Specifically, images with high similarity in facial features are grouped into the same category. After classifying the images, the facial features of the images in each category are used to determine which person the images in each category correspond to. However, although the prior art classifies images collected within a unit time, there are still a large number of images, and the probability of similar images in such a large number of images is higher. Therefore, the prior art can easily result in the images in each classified category not being images of the same person, resulting in inaccurate clustering results. Summary of the Invention
[0004] Embodiments of the present invention provide a portrait clustering method, apparatus, device, and medium, which are used to solve the problem of inaccurate clustering caused by too many images in the prior art.
[0005] In a first aspect, an embodiment of the present invention provides a portrait clustering method, the method comprising:
[0006] Receiving images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time;
[0007] For each pre-divided first category, the target acquisition device included in each pre-saved first category is determined, the target image captured by the target acquisition device in the image to be clustered is determined, and the target image is classified according to the facial features contained in the target image.
[0008] Furthermore, the acquisition devices included in each first category are determined by:
[0009] receiving the location information of each acquisition device and the segmented images acquired within a unit time sent by each acquisition device, and classifying the segmented images;
[0010] For each divided second category, sort the acquisition devices according to the time sequence in which the divided images contained in the second category were acquired; for each acquisition device, determine the target related device of the acquisition device based on each acquisition device and adjacent acquisition devices in the sorting result corresponding to each second category;
[0011] Constructing an input graph including nodes corresponding to each acquisition device determined according to the position information of each acquisition device, and determining a first eigenvector corresponding to each node in the input graph;
[0012] Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining a target vector corresponding to each node output by the vector determination model;
[0013] Adaptively cluster the target vectors corresponding to each node to determine the target vectors included in each category, and treat the acquisition devices corresponding to the target vectors included in each category as the same category.
[0014] Furthermore, for each of the acquisition devices, determining the target related device of the acquisition device according to each acquisition device and adjacent acquisition devices in the sorting results corresponding to each second category includes:
[0015] For each of the acquisition devices, according to the sorting results corresponding to each second category, a first preset number of candidate acquisition devices adjacent to the acquisition device are determined in each sorting result; according to the determined number of occurrences of the candidate acquisition devices of the acquisition device, a second preset number of candidate acquisition devices are determined as target-related devices of the acquisition device.
[0016] Furthermore, the constructing of an input graph including nodes corresponding to each collection device determined according to the location information of each collection device includes:
[0017] Determine the distance between any two acquisition devices based on the location information of each acquisition device;
[0018] Build the node corresponding to each acquisition device;
[0019] For each collection device, a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold is obtained. If there is no connection relationship between the target node and the node corresponding to the collection device, a corresponding connection relationship is established.
[0020] Furthermore, inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model to obtain each target vector output by the vector determination model includes:
[0021] The input graph and the first eigenvector corresponding to each node are input into the vector determination model. The vector determination model uses any preset aggregation function on the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0022] Furthermore, the method further comprises:
[0023] The vector determination model uses any preset aggregation function for each node in the input graph on the target vector corresponding to each node connected to the node to determine a second aggregate vector, and updates and outputs the target vector based on the second aggregate vector, the target vector corresponding to the node, and the pre-stored second weight corresponding to each vector.
[0024] Furthermore, the vector determination model is trained in the following manner:
[0025] Obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node and the number of images sent by the acquisition device corresponding to the node; randomly shuffle the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph;
[0026] Inputting the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and inputting the sample damage graph and the fourth eigenvector corresponding to each node in the sample damage graph into the original model to obtain the damage output vector corresponding to each node in the sample damage graph output by the original model; wherein the sample output vector corresponding to each node and the damage output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node;
[0027] Determine a loss value corresponding to the sample input graph according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damage output vector corresponding to each node in the sample damage graph, and the loss function;
[0028] The original neural network model is trained according to the loss value corresponding to each sample input graph in the sample set to obtain a trained vector determination model.
[0029] In a second aspect, an embodiment of the present invention further provides a portrait clustering device, comprising:
[0030] A receiving module, configured to receive the images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time;
[0031] The processing module is used to determine, for each pre-divided first category, the target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category, determine the target image acquired by the target acquisition device in the image to be clustered, and classify the target image based on the facial features contained in the target image.
[0032] Furthermore, the processing module is also used to receive the location information of each acquisition device and the divided images collected within a unit time sent by each acquisition device, and classify the divided images; for each second category after division, sort the acquisition devices according to the time sequence in which the divided images contained in the second category are collected; for each acquisition device, determine the target-related devices of the acquisition device according to each acquisition device and adjacent acquisition devices in the sorting results corresponding to each second category; construct an input graph containing nodes corresponding to each acquisition device determined according to the location information of each acquisition device, and determine the first eigenvector corresponding to each node in the input graph; input the input graph and the first eigenvector corresponding to each node into a pre-trained vector determination model to obtain the target vector corresponding to each node output by the vector determination model; adaptively cluster the target vectors corresponding to each node, determine the target vectors contained in each category, and regard the acquisition devices corresponding to the target vectors contained in each category as the same category.
[0033] Furthermore, the processing module is specifically used to determine, for each of the acquisition devices, a first preset number of candidate acquisition devices adjacent to the acquisition device in each sorting result according to the sorting result corresponding to each second category; and determine a second preset number of candidate acquisition devices as target-related devices of the acquisition device according to the determined number of occurrences of the candidate acquisition devices of the acquisition device.
[0034] Furthermore, the processing module is specifically used to determine the distance between any two collection devices based on the location information of each collection device; construct a node corresponding to each collection device; for each collection device, obtain a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold, and if there is no connection relationship between the target node and the node corresponding to the collection device, establish a corresponding connection relationship.
[0035] Furthermore, the processing module is specifically used to input the input graph and the first eigenvector corresponding to each node into the vector determination model. The vector determination model uses any preset aggregation function for the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0036] Furthermore, the processing module is also used for the vector determination model to use any preset aggregation function for the target vector corresponding to each node connected to each node in the input graph to determine a second aggregation vector, and update and output the target vector based on the second aggregation vector, the target vector corresponding to the node and the second weight corresponding to each pre-saved vector.
[0037] Furthermore, the processing module is also used to obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node; randomly scramble the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph; input the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and input the sample damage graph and the third eigenvector corresponding to each node in the sample damage graph into the original model to obtain the sample output vector corresponding to each node; Four eigenvectors are input into the original model to obtain the damaged output vector corresponding to each node in the sample damage graph output by the original model; wherein, the sample output vector corresponding to each node and the damaged output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node; according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damaged output vector corresponding to each node in the sample damage graph and the loss function, the loss value corresponding to the sample input graph is determined; according to the loss value determined for each sample input graph in the sample set, the original neural network model is trained to obtain a trained vector determination model.
[0038] In a third aspect, an embodiment of the present invention further provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of the portrait clustering method as described in any one of the above items when executing a computer program stored in the memory.
[0039] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, which implements the steps of any of the above-mentioned portrait clustering methods when executed by a processor.
[0040] In an embodiment of the present invention, after receiving the image to be clustered sent by each acquisition device, the electronic device determines, for each pre-divided first category, the target acquisition device included in the category based on the acquisition devices included in each pre-saved first category, determines the target image captured by the target acquisition device in the image to be clustered, and classifies the target image based on the facial features included in the target image. Since in an embodiment of the present invention, the electronic device determines, for each pre-divided first category, the target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category, and classifies the target image captured by the target acquisition device, that is, the electronic device classifies part of the images in the image to be clustered respectively. Since there are fewer images during classification, the problem of inaccurate clustering due to too many images can be effectively avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solution of the present invention, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0042] Figure 1 A schematic diagram of a portrait clustering process provided by an embodiment of the present invention;
[0043] Figure 2 A schematic diagram of a process for determining the collection devices included in each category provided by an embodiment of the present invention;
[0044] Figure 3 A schematic diagram of a process for determining a target vector for each acquisition device according to an embodiment of the present invention;
[0045] Figure 4 A schematic structural diagram of a portrait clustering device provided by an embodiment of the present invention;
[0046] Figure 5 This is a structural schematic diagram of an electronic device provided by the present invention. DETAILED DESCRIPTION
[0047] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.
[0048] In an embodiment of the present invention, after receiving the image to be clustered sent by each acquisition device, the electronic device determines, for each pre-divided first category, the target acquisition device included in the category based on the acquisition devices included in each pre-saved first category, determines the target image captured by the target acquisition device in the image to be clustered, and classifies the target image based on the facial features contained in the target image.
[0049] In order to accurately classify the collected images, embodiments of the present invention provide a portrait clustering method, apparatus, device, and medium.
[0050] Example 1:
[0051] Figure 1 A schematic diagram of a portrait clustering process provided by an embodiment of the present invention includes the following steps:
[0052] S101: receiving images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time.
[0053] The portrait clustering method provided by the embodiment of the present invention is applied to an electronic device, which may be an intelligent device such as a PC or a server.
[0054] In an embodiment of the present invention, in order to cluster images, the electronic device can first receive the images to be clustered sent by each acquisition device, and the images to be clustered are acquired by the corresponding acquisition device within a unit time, and the unit time can be any preset shorter time, for example, 1 day, 1 hour, 1 minute, etc.
[0055] In this case, each acquisition device may acquire an image to be clustered containing a user within a unit time and then send the acquired image to be clustered to the electronic device. Alternatively, each acquisition device may acquire an image to be clustered containing a user and then send the acquired image to be clustered to the electronic device. The electronic device then performs subsequent classification operations based on the facial features contained in the image to be clustered received from each acquisition device within a unit time.
[0056] S102: For each pre-divided first category, determine the target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category, determine the target image acquired by the target acquisition device in the image to be clustered, and classify the target image based on the facial features included in the target image.
[0057] In order to avoid the problem of inaccurate clustering due to a large number of images during classification, in an embodiment of the present invention, the electronic device divides the images to be clustered into multiple categories, and classifies the target images contained in each category according to the facial features in the target images contained in each category, thereby reducing the number of images during clustering and improving the accuracy of clustering.
[0058] The electronic device pre-stores the collection devices included in each first category. For each collection device, if a user typically passes by another collection device after walking or driving past the collection device, the other collection device is typically included in the same first category as the collection device. For example, each collection device in the fresh food section of a supermarket or each collection device in the cosmetics section of a shopping mall. Specifically, the collection devices included in the first category can be determined based on the location information of each collection device. The closer the distance between two collection devices, the greater the likelihood that the two collection devices are included in the same first category. Therefore, the electronic device can determine the collection devices included in each first category by pre-saving each piece of basic location information and, for each first category, storing one piece of basic location information, wherein one piece of basic location information corresponds to only one first category. For each collection device, the electronic device determines the distance between each piece of pre-stored basic location information and the location information of the collection device, determines the basic location information with the closest distance as the target basic location information corresponding to the collection device, and determines that the collection device is included in the first category corresponding to the target basic location information.
[0059] Specifically, the electronic device determines, for each pre-divided first category, each target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category. After determining each target acquisition device included in the first category, the electronic device determines that the image captured by each target acquisition device in the image to be clustered is the target image corresponding to the first category, thereby dividing the image to be clustered into target images corresponding to multiple categories.
[0060] After determining target images corresponding to each first category in the images to be clustered, the electronic device classifies the target images based on the facial features contained in each target image corresponding to the first category. Specifically, how to classify images based on the facial features contained in the images is a known technique and will not be further described here.
[0061] In the embodiment of the present invention, the electronic device determines the target acquisition device included in each pre-divided first category according to the acquisition devices included in each pre-saved first category, and classifies the target images acquired by the target acquisition device. That is to say, the electronic device classifies part of the images to be clustered respectively. Since there are fewer images during classification, the problem of inaccurate clustering due to too many images can be effectively avoided.
[0062] Example 2:
[0063] In order to accurately determine the acquisition devices included in each first category, based on the above embodiment, in an embodiment of the present invention, the acquisition devices included in each first category are determined by:
[0064] receiving the location information of each acquisition device and the segmented images acquired within a unit time sent by each acquisition device, and classifying the segmented images;
[0065] For each divided second category, sort the acquisition devices according to the time sequence in which the divided images contained in the second category were acquired; for each acquisition device, determine the target related device of the acquisition device based on each acquisition device and adjacent acquisition devices in the sorting result corresponding to each second category;
[0066] Constructing an input graph including nodes corresponding to each acquisition device determined according to the position information of each acquisition device, and determining a first eigenvector corresponding to each node in the input graph;
[0067] Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining a target vector corresponding to each node output by the vector determination model;
[0068] Adaptively cluster the target vectors corresponding to each node to determine the target vectors included in each category, and treat the acquisition devices corresponding to the target vectors included in each category as the same category.
[0069] In embodiments of the present invention, the closer the distance between two acquisition devices, the more likely a user is to pass by them within a given timeframe, and the greater the likelihood that the two acquisition devices are from the same category. The electronic device can determine the distance between the acquisition devices based on the location information between the acquisition devices. Therefore, when determining the acquisition devices included in each first category, the electronic device can first obtain the location information of each acquisition device and receive the segmented images sent by each acquisition device. The segmented images are those captured by the corresponding acquisition device within a given timeframe. Specifically, each acquisition device can transmit its target identifier when transmitting the segmented images. The electronic device can obtain the location information of the acquisition device based on the stored correspondence between the identifier and the location information and the target identifier of the acquisition device, thereby obtaining the location information of each acquisition device. The location information of each acquisition device can also be transmitted to the electronic device when the acquisition device transmits the segmented images. The location information of the acquisition device is the longitude and latitude information of the location where the acquisition device is installed. This longitude and latitude information can be preconfigured in the acquisition device and can be transmitted when the image is transmitted.
[0070] After the electronic device obtains the location information of each acquisition device and receives the segmented images captured within a unit time from each acquisition device, it can first classify the segmented images based on the facial features contained in the segmented images to determine each classified second category. Typically, each category contains images captured by a user within a unit time. The greater the probability that images captured by multiple acquisition devices fall into the same category, the greater the probability that these acquisition devices belong to the same category. Therefore, for each classified second category, the electronic device can sort the acquisition devices that captured the segmented images within that second category based on the time order in which the segmented images within that second category were captured. If two adjacent acquisition devices in a ranking result are the same, only one of the duplicate acquisition devices can be retained. If only one acquisition device is found in a ranking result, the ranking result is of no use in determining the target-related device of the acquisition device and can therefore be deleted. In embodiments of the present invention, each ranking result can be referred to as trajectory information for the capture of the segmented images.
[0071] Suppose the segmented images are classified, and the resulting second categories are C1, C2, and C3. Category C1 contains three segmented images, which were acquired by acquisition devices A1, A2, and A3, respectively. Therefore, the order of acquisition devices corresponding to category C1 is [A1, A2, A3]. Category C2 contains four segmented images, which were acquired by acquisition devices A1, A1, A3, and A4, respectively. Therefore, the order of acquisition devices corresponding to category C2 is [A1, A3, A4]. Category C3 contains one segmented image, which was acquired by acquisition device A1. Therefore, the order of acquisition devices corresponding to category C3 is [A1]. In particular, since the order corresponding to category C3 only contains one acquisition device, this order can be deleted based on actual application requirements.
[0072] For each collection device, the collection devices adjacent to the collection device in the sorting results corresponding to each second category are more relevant to the collection device. Therefore, the electronic device can determine the target-related device of each collection device based on each collection device and the adjacent collection devices in the sorting results corresponding to each second category.
[0073] Specifically, the method for the electronic device to determine the target-related devices of each collection device can be: the electronic device determines, for each collection device, the collection devices adjacent to the collection device in each second category, and determines the probability of occurrence of each adjacent collection device based on the number of occurrences of each adjacent collection device and the total number of occurrences of each adjacent collection device, and determines that the adjacent collection device whose probability of occurrence exceeds a preset probability threshold is the target-related device of the collection device.
[0074] For example, a certain acquisition device appears in three second categories, where the adjacent acquisition devices of this acquisition device in the three second categories are A1, A2, A1, A3, and A1, A4 respectively. Then the number of occurrences of A1 is 3, the number of occurrences of A2, A3, and A4 are respectively 1, and the total number of occurrences of each adjacent acquisition device is 6. Therefore, the probability of A1 appearing is 50%, and the probability of A2, A3, and A4 appearing is respectively 16.7%. Among them, if the preset probability threshold is 40%, the target-related device of the acquisition device is A1.
[0075] After determining the target-related device of each acquisition device, the electronic device can determine the target vector of each acquisition device through a pre-trained vector determination model, wherein the distance between target vectors of the same category in the target vectors determined by the vector determination model is relatively close. Specifically, in order to determine the target vector of each acquisition device, the electronic device can construct an input graph based on the location information of each acquisition device, wherein the input graph includes a node corresponding to each acquisition device, and the electronic device also determines the first eigenvector corresponding to each node in the input graph. The first eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node, and the number of divided images sent by the acquisition device corresponding to the node. The first eigenvector corresponding to each node of the electronic device can be saved in the corresponding node, or a correspondence between each node and the corresponding first eigenvector can be constructed.
[0076] In addition, the first feature vector may also include the maximum value, minimum value, mean value, variance, etc. of the number of divided images sent by the acquisition device corresponding to the node in the previously preset number of unit times. The first feature vector may also include an identifier of the area type of the area where the acquisition device corresponding to the node is located. Among them, area types include schools, shopping malls, hospitals, etc. And because the location information of each acquisition device is the corresponding longitude and latitude information, the area type of a certain acquisition device is to obtain a detailed address by inverse address normalization of the location information of the acquisition device. The detailed address is specifically which road and which building, etc., and the area type of the detailed address is determined accordingly. Specifically, the method for the electronic device to determine the area type of the detailed address can be: determine the area where the detailed address is located, and determine the area type corresponding to the area where the detailed address is located based on the correspondence between the saved area and the area type.
[0077] After determining the input graph and the first eigenvector corresponding to each node in the input graph, the electronic device can input the input graph and the first eigenvector corresponding to each node in the input graph into a pre-trained vector determination model to obtain the output of the vector determination model, and the output of the vector determination model is the target vector corresponding to each node in the input graph. Among them, the electronic device can construct an adjacency matrix corresponding to the input graph based on the connection relationship between the input graph and the nodes in the input graph. When constructing the adjacency matrix, the rows of the adjacency matrix correspond to each node, and the columns also correspond to each node. The value corresponding to each element in the adjacency matrix identifies whether the node corresponding to the row where the element is located is connected to the node corresponding to the column where the element is located. If the first node in the input graph has a connection relationship with the second node, the value corresponding to the element in the first row and second column of the adjacency matrix is recorded as a first preset identifier, for example, it can be 1. If the first node in the input graph does not have a connection relationship with the second node, the value corresponding to the element in the first row and second column of the adjacency matrix can be recorded as a second preset identifier, for example, it can be 0. Specifically, how to construct an adjacency matrix corresponding to a certain input graph is a prior art and will not be repeated here.
[0078] The value is explained as follows: if the connection relationship corresponding to a certain node is reflected by each value recorded in the first row of the adjacency matrix, then the first first eigenvector in each first eigenvector input by the electronic device to the vector determination model is the first eigenvector corresponding to the node, that is, the order of the nodes corresponding to each row in the adjacency matrix is the same as the order of the nodes corresponding to each first eigenvector input to the vector determination model. In an embodiment of the present invention, the electronic device inputs the adjacency matrix and the first eigenvector corresponding to each node into the vector determination model, so the vector determination model can determine the connection relationship between each node in the input graph through the adjacency matrix, and can determine the correspondence between each row and column and each first eigenvector based on each row and column in the adjacency matrix, that is, determine the correspondence between the node and the first eigenvector.
[0079] When the electronic device determines the first eigenvector corresponding to each node in the input graph, it does so based on information such as the location information of each acquisition device, and when the electronic device inputs the first eigenvector corresponding to each node into the vector determination model, it knows the order of the input first eigenvectors, and knows which node each first eigenvector corresponds to, and which node corresponds to which acquisition device. The vector determination model does not disrupt the order of the vectors, that is, the order of the nodes corresponding to each output target vector is consistent with the order of the nodes corresponding to each input first eigenvector. Therefore, after the electronic device obtains each target vector output by the vector determination model, it can determine which acquisition device each target vector corresponds to, that is, it can determine the target vector corresponding to each acquisition device.
[0080] Among them, the vector determination model determines the first eigenvector corresponding to each row in the adjacency matrix according to the order of each first eigenvector, obtains the identifier of the target-related device of the acquisition device corresponding to the node in the first eigenvector, which can be called the first identifier, and obtains the column in the row of the adjacency matrix identified as the first preset identifier according to the identifier of the acquisition device corresponding to each row and each column in the pre-stored adjacency matrix, wherein there is an association between the node corresponding to the column and the node corresponding to the row, obtains the first eigenvector corresponding to the column identified as the target identifier according to the order of each first eigenvector, obtains the identifier of the target-related device in the first eigenvector, which can be called the second identifier, and the vector determination model processes the first identifier and the first eigenvector corresponding to the second identifier. The target vector corresponding to the node output by the vector determination model includes the result of processing the first eigenvector corresponding to the first identifier and the second identifier. In addition, the vector determination model also processes the number of divided images sent by the acquisition device corresponding to the statistical node in the above manner for each row in the adjacency matrix.
[0081] If the first eigenvector also includes the maximum value, minimum value, mean value, variance, etc. of the number of divided images sent by the acquisition device corresponding to each node in the previous preset number of unit times, the vector determination model also processes the maximum value, minimum value, mean value, variance, etc. of the number of divided images sent by the acquisition device corresponding to the node in the previous preset number of unit times for each row in the adjacency matrix in the above-mentioned manner. If the first eigenvector also includes the identification of the area type of the acquisition device corresponding to each node, the vector determination model also processes the identification of the area type of the acquisition device corresponding to the node in the above-mentioned manner for each row in the adjacency matrix. Among them, for each node, the number of other nodes connected to the node is different, which does not affect the number of components in the target vector corresponding to the node.
[0082] Since in an embodiment of the present invention, the smaller the distance between target vectors, the greater the probability that the acquisition devices corresponding to the target vectors are acquisition devices of the same category, after determining the target vector corresponding to each node, the electronic device adaptively clusters the target vectors corresponding to each node, determines the target vectors included in each category, and regards the acquisition devices corresponding to the target vectors included in each category as the same category.
[0083] Among them, the electronic device can cluster the target vector corresponding to each node obtained using a clustering method such as K-means or DBSCANE according to the numerical values corresponding to the preset number of categories. After clustering the target vector corresponding to each node using the numerical value corresponding to the pre-stored number of categories, the clustering result corresponding to the numerical value of the category number can be obtained. In this way, the clustering result corresponding to the numerical value corresponding to each pre-stored number of categories can be obtained. After obtaining each clustering result, each clustering result can be clustered using profile evaluation. The closer the profile evaluation value determined by a clustering result is to 1, the more accurate the clustering result is. Therefore, after determining the clustering results using different numerical values corresponding to clustering, the clustering result with the profile evaluation value closest to 1 can be obtained, and the clustering result is determined to be the target clustering result. The numerical value of the target clustering result classification is the optimal classification number for the current scene, and the acquisition devices corresponding to the target vectors contained in each category of the target clustering result are regarded as the same category.
[0084] Figure 2 A schematic diagram of a process for determining the collection devices included in each category provided by an embodiment of the present invention includes the following steps:
[0085] S201: Receive the location information of each acquisition device and the divided images acquired within a unit time sent by each acquisition device.
[0086] S202: Classifying the segmented images according to facial features contained in the segmented images, and determining the segmented images contained in each second category after classification.
[0087] S203: For each acquisition device, determine a target-related device of the acquisition device according to the order in which the divided images included in each second category are acquired.
[0088] S204: Construct an input graph, and determine a first eigenvector corresponding to a node corresponding to each acquisition device in the input graph according to the target-related device of each acquisition device.
[0089] S205: Determine the model, the input graph, and the first eigenvector corresponding to the node corresponding to each acquisition device in the input graph according to the trained vector, and determine the target vector corresponding to each node in the input graph.
[0090] S206: Adaptively cluster each target vector, and classify the acquisition devices corresponding to the target vectors included in each category after clustering as the same category.
[0091] Example 3:
[0092] In order to accurately determine the target related devices of each acquisition device, based on the above embodiments, in an embodiment of the present invention, for each acquisition device, determining the target related devices of the acquisition device according to each acquisition device and adjacent acquisition devices in the sorting results corresponding to each second category includes:
[0093] For each of the acquisition devices, according to the sorting results corresponding to each second category, a first preset number of candidate acquisition devices adjacent to the acquisition device are determined in each sorting result; according to the determined number of occurrences of the candidate acquisition devices of the acquisition device, a second preset number of candidate acquisition devices are determined as target-related devices of the acquisition device.
[0094] In the embodiment of the present invention, when determining the target related device for each collection device, the electronic device may determine the target related device based on the collection devices adjacent to each collection device in the sorting results corresponding to each second category.
[0095] Specifically, the electronic device may determine, for each collection device, a first preset number of candidate collection devices adjacent to the collection device in each sorting result corresponding to the second category based on the sorting result corresponding to each second category. When determining the candidate collection devices, the electronic device may determine, for each sorting result corresponding to the second category, a first preset number of candidate collection devices that are adjacent to and after the collection device in the sorting result corresponding to the second category; or a first preset number of candidate collection devices that are adjacent to and before the collection device in the sorting result corresponding to the second category; or a third preset number of candidate collection devices that are adjacent to and before the collection device in the sorting result corresponding to the second category, and a fourth preset number of candidate collection devices that are adjacent to and after the collection device in the sorting result corresponding to the second category, wherein the sum of the third preset number and the fourth preset number is the first preset number. Furthermore, the first preset number may be any positive integer, such as 2. The first preset number is typically any positive integer between 1 and 5.
[0096] For each acquisition device, after determining each candidate acquisition device of the acquisition device in each second category according to the sorting results corresponding to each second category, the electronic device can determine the number of occurrences of each candidate acquisition device of the acquisition device, and sort the number of occurrences of each candidate acquisition device from large to small, and according to the sorting results corresponding to the number of occurrences, determine a second preset number of candidate acquisition devices with a larger number of occurrences as the target-related devices of the acquisition device.
[0097] Assume that there are 5 collection devices, represented by A1, A2, A3, A4 and A5. There are 3 sorting results, namely [A1, A2, A3, A4], [A1, A3, A4, A5], and [A2, A1, A5, A3]. When determining the candidate collection device, the two adjacent collection devices after the collection device are determined as candidate collection devices. Taking the target-related devices of A1 as an example, according to the first sorting result, the corresponding candidate collection devices determined are A2 and A3, according to the second sorting result, the corresponding candidate collection devices determined are A3 and A4, and according to the third sorting result, the corresponding candidate collection devices determined are A5 and A3. The number of occurrences of candidate collection device A2 of A1 is 1, the number of occurrences of candidate collection device A3 of A1 is 2, the number of occurrences of candidate collection device A4 of A1 is 1, and the number of occurrences of candidate collection device A5 of A1 is 1. If the second preset number is 1, the target-related device of A1 is A3.
[0098] Example 4:
[0099] In order to accurately construct an input graph, based on the above embodiments, in an embodiment of the present invention, constructing an input graph including nodes corresponding to each collection device determined according to the location information of each collection device includes:
[0100] Determine the distance between any two acquisition devices based on the location information of each acquisition device;
[0101] Build the node corresponding to each acquisition device;
[0102] For each collection device, a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold is obtained. If there is no connection relationship between the target node and the node corresponding to the collection device, a corresponding connection relationship is established.
[0103] In this embodiment of the present invention, the greater the distance between two collection devices, the less likely it is that a user will be collected by both collection devices within a given timeframe, and the lower the probability that the two collection devices belong to the same category. Therefore, when classifying collection devices, the distance between any two collection devices can be considered. Specifically, the electronic device determines the distance between any two collection devices based on the location information of each collection device. The distance determined between any two collection devices is the driving distance or walking distance obtained by searching a map path based on the location information of the two collection devices, rather than the straight-line distance between the location information of the two collection devices.
[0104] The electronic device constructs a node corresponding to each collection device in the input graph, obtains, for each collection device, a collection device whose distance to the collection device is less than a preset distance threshold, determines a target node corresponding to the collection device whose distance is less than the preset distance threshold, and establishes a connection relationship between the target node and the node of the collection device. The distance threshold is less than the distance that a user can reach by walking or driving within a unit time.
[0105] In order to avoid the connection relationship between two collection devices being established repeatedly, in an embodiment of the present invention, when establishing a connection relationship between nodes, the electronic device can, for each collection device, obtain a target node corresponding to a collection device whose distance from the collection device is less than a preset distance threshold, and determine whether there is a connection relationship between the target node and the node corresponding to the collection device. If there is a connection relationship, the corresponding connection relationship is no longer established. If there is no connection relationship, a connection relationship is established between the target node and the node corresponding to the collection device.
[0106] In the embodiment of the present invention, the constructed input graph can be Indicates that is a node on the input graph, representing each acquisition device, and ε is an edge on the input graph, that is, the connection relationship described in the above embodiment. Two nodes with a connection relationship represent that the distance between the acquisition devices corresponding to the two nodes is less than the preset distance threshold.
[0107] Example 5:
[0108] In order to accurately determine the target vector corresponding to each acquisition device, based on the above embodiments, in an embodiment of the present invention, inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining each target vector output by the vector determination model includes:
[0109] The input graph and the first eigenvector corresponding to each node are input into the vector determination model. The vector determination model uses any preset aggregation function on the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0110] In an embodiment of the present invention, after constructing the input graph and determining the first feature vector corresponding to each node on the input graph, the node features can be iterated through the pre-trained vector determination model to determine the target vector corresponding to each node.
[0111] Specifically, when determining the target vector corresponding to each node, the electronic device inputs the input graph and the first eigenvector corresponding to each node into the vector determination model. The vector determination model uses any preset aggregation function for the first eigenvector corresponding to each node connected to the node for each node in the input graph to determine the first aggregation vector. Wherein, using any preset aggregation function for the first eigenvector corresponding to each node connected to the node can be to calculate the sum of the first eigenvectors corresponding to each node connected to the node, or to calculate the average value of the first eigenvectors corresponding to each node connected to the node. How to specifically use the aggregation function to aggregate several vectors is an existing technology and will not be repeated here.
[0112] For each node, after determining the first aggregation vector corresponding to the node, the electronic device determines the target vector corresponding to the node based on the first eigenvector corresponding to the node, the determined first aggregation vector, and the first weight of each vector saved in advance. Specifically, the product of the first eigenvector corresponding to the node and the corresponding first weight is determined, and the product is determined to be the first vector, and the product of the first aggregation vector corresponding to the node and the corresponding first weight is determined to be the second vector, and the sum vector of the first vector and the second vector is determined to be the target vector corresponding to the node. And usually the network layer of the vector determination model performs the above-mentioned operation of determining the target vector, and the network layer can be called the first network layer. Specifically, the electronic device inputs the adjacency matrix corresponding to the input graph and the first eigenvector corresponding to each node into the vector determination model. How to construct the adjacency matrix corresponding to the input graph has been described in the above embodiment and will not be repeated here.
[0113] The vector determination model can determine the target vector corresponding to each node through the following formula:
[0114]
[0115] in, is the target vector corresponding to the u-th node determined by the vector determination model, is the first aggregation vector corresponding to the u-th node determined by the vector determination model, is the first eigenvector corresponding to the node v that has a connection relationship with the u-th node, For each node that has a connection relationship with the u-th node, is the first eigenvector corresponding to the u-th node, UPDATE is an update function, and the update function is applied to the first eigenvector corresponding to the u-th node and the aggregation vector corresponding to the u-th node to determine the target vector corresponding to the u-th node, that is, the target vector corresponding to the u-th node is determined according to the first aggregation vector corresponding to the u-th node, the first eigenvector corresponding to the u-th node, and the first weight corresponding to each pre-saved vector as described in the above embodiment.
[0116] In an embodiment of the present invention, the vector determination model is a graph neural network based on the spatial domain. In addition, the vector determination model can also be a graph neural network based on the spectral domain.
[0117] In this embodiment of the present invention, the vector determination model can aggregate the first feature vectors corresponding to nodes connected to each node to generate a new feature vector, which is the first aggregated vector. Furthermore, the first aggregated vector generated by aggregating surrounding nodes and the first feature vector corresponding to the node itself can be used to update the node, thereby generating a new node feature. This feature vector is the target vector corresponding to the node.
[0118] In order to accurately determine the target vector corresponding to each node, based on the above embodiments, in an embodiment of the present invention, if the vector determination model includes at least two network layers, the method further includes:
[0119] The vector determination model uses any preset aggregation function for each node in the input graph on the target vector corresponding to each node connected to the node to determine a second aggregate vector, and updates and outputs the target vector based on the second aggregate vector, the target vector corresponding to the node, and the pre-stored second weight corresponding to each vector.
[0120] In an embodiment of the present invention, if the vector determination model includes at least two network layers, the first network layer performs the operations of the above embodiment, and the other network layers of the vector determination model further iterate the first eigenvector corresponding to each node in the input graph. The other network layer can be referred to as the second network layer. Specifically, after the first network layer determines the target vector corresponding to each node, the first network layer inputs the input graph and the target vector corresponding to each node into the second network layer. The second network layer uses any preset aggregation function for the target vector corresponding to each node connected to the node for each node in the input graph to determine the second aggregate vector corresponding to the node. Wherein, any preset aggregation function is used for the target vector corresponding to each node connected to the node, which can be the sum of the target vectors corresponding to each node connected to the node, or the average value of the target vectors corresponding to each node connected to the node. How to use the aggregation function to aggregate several vectors is a prior art and will not be described in detail here. After determining the second aggregate vector corresponding to each node for the node, the electronic device determines the fourth eigenvector corresponding to the node based on the target vector corresponding to the node, the determined second aggregate vector, and the pre-stored second weight of each vector, and uses the fourth eigenvector to update the target vector corresponding to the node. Specifically, the product of the target vector corresponding to the node and the corresponding second weight is determined, and the product is determined as a third vector. The product of the second aggregation vector corresponding to the node and the corresponding second weight is determined, and the product is determined as a fourth vector. The sum of the third vector and the fourth vector is determined as the eigenvector corresponding to the node. After using the fourth eigenvector corresponding to each node to update the corresponding target vector, the second network layer outputs the determined target vector corresponding to each node.
[0121] In the embodiment of the present invention, in order to avoid the over-smoothing problem, the number of network layers is generally set to no more than 3 layers.
[0122] Figure 3 A schematic diagram of a process for determining a target vector for each acquisition device provided by an embodiment of the present invention includes the following steps:
[0123] S301: Construct an input graph and determine the first eigenvector corresponding to each node in the input graph.
[0124] S302: Input the input graph and the first eigenvector corresponding to each node into a vector determination model.
[0125] S303: The vector determines the target vector corresponding to each node of the output of the model.
[0126] Among them, the vector determination model iterates the features of each node.
[0127] Example 6:
[0128] In order to generate a vector determination model, based on the above embodiments, in an embodiment of the present invention, the vector determination model is trained in the following manner:
[0129] Obtain any sample input graph in the sample set and the second eigenvector corresponding to each node in the sample input graph, wherein the second eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node and the number of images sent by the acquisition device corresponding to the node; randomly shuffle the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the second eigenvector corresponding to the node in the sample input graph as the third eigenvector corresponding to the node in the sample damage graph;
[0130] Inputting the sample input graph and the second eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and inputting the sample damage graph and the third eigenvector corresponding to each node in the sample damage graph into the original model to obtain the damage output vector corresponding to each node in the sample damage graph output by the original model; wherein the sample output vector corresponding to each node and the damage output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node;
[0131] Determine a loss value corresponding to the sample input graph according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damage output vector corresponding to each node in the sample damage graph, and the loss function;
[0132] The original neural network model is trained according to the loss value corresponding to each sample input graph in the sample set to obtain a trained vector determination model.
[0133] In order to realize the training of the vector determination model, a sample set for training is saved in an embodiment of the present invention, and the sample input graphs in the sample set include input graphs with different numbers of nodes and different connection relationships, and for each sample input graph, a second feature vector corresponding to each node in the sample input graph is also saved, wherein the second feature vector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node.
[0134] In order to facilitate the training of the vector determination model, the electronic device obtains any sample input graph in the sample set and randomly scrambles the sample input graph to obtain a sample damage graph, wherein the method of scrambling the sample input graph is: randomly removing a node, randomly increasing the connection relationship between two nodes that do not have a connection relationship in the sample input graph, randomly removing the connection relationship between two nodes that have a connection relationship in the sample input graph, or randomly changing the eigenvector corresponding to a node in the sample input graph. The specific method of scrambling the input graph is an existing technology and will not be described in detail here. And for each node in the sample damage graph, the second eigenvector corresponding to the node in the sample input graph is determined as the third eigenvector corresponding to the node in the sample damage graph; thereby determining the third eigenvector corresponding to each node in the sample damage graph.
[0135] In an embodiment of the present invention, after obtaining any sample input graph in a sample set, the second eigenvector corresponding to each node in the sample input graph, the sample damage graph corresponding to the sample input graph, and the third eigenvector corresponding to each node in the sample damage graph, the electronic device inputs the sample input graph and the second eigenvector corresponding to each node in the sample input graph into an original model to obtain a sample output vector corresponding to each node output by the original model. The sample output vector corresponding to each node includes the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node. Furthermore, the electronic device inputs the sample damage graph corresponding to the sample input graph and the third eigenvector corresponding to each node in the sample damage graph into the original model to obtain a damage output vector corresponding to each node in the sample damage graph output by the original model. The damage output vector corresponding to each node in the sample damage graph includes the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node.
[0136] After obtaining the sample output vector corresponding to each node in the sample input graph output by the original model and the damaged output vector corresponding to each node in the sample damaged graph corresponding to the sample input graph, the electronic device determines the loss value corresponding to the sample input graph based on the sample output vector corresponding to each node in the sample input graph, the sample input graph, the sample damaged graph, the damaged output vector corresponding to each node in the sample damaged graph, and the loss function; the electronic device trains the original model based on the loss value determined for each sample input graph in the sample set, and obtains a trained vector determination model when a preset condition is met. The preset condition may be that the number of sample images in the sample set whose loss values are determined to be less than a preset threshold is greater than a set number.
[0137] The loss function It can be:
[0138]
[0139] Among them, N represents the sample input graph The number of nodes, M represents the sample damage graph corresponding to the sample input graph The number of nodes, Indicates the expectation. i represents the i-th node of the sample input graph, is the matrix composed of the first eigenvectors corresponding to each node in the sample output graph, A is the first adjacency matrix determined according to the connection relationship between the nodes in the sample input graph, and h i is the sample output vector corresponding to the i-th node of the sample input graph, s is the sum or average of each sample output vector, j represents the j-th node of the sample damage graph, is the matrix composed of the first eigenvectors corresponding to each node in the sample damage graph, is the second adjacency matrix determined based on the connections between nodes on the sample damage graph. Using s, we can consider the eigenvectors of the entire sample input graph when training the model. This means that we can implement both node-level and graph-level training methods based on different loss functions. Can be used Represents, where d is the dimension of the feature vector corresponding to the node, R d Represents the feature vector corresponding to a node, is the number of nodes, that is, the number of all acquisition devices.
[0140] Where D represents the judgment model, which is used to calculate the mutual information between the target vector corresponding to the node and the vector s of the entire graph. One implementation of the judgment model D is as follows:
[0141]
[0142] Among them, W is the preset weight matrix and σ is the nonlinear activation function.
[0143] Example 7:
[0144] Figure 4 A schematic diagram of the structure of a portrait clustering device provided in an embodiment of the present invention, the device comprising:
[0145] The receiving module 401 is configured to receive the image to be clustered sent by each acquisition device; wherein the image to be clustered is acquired by the corresponding acquisition device within a unit time;
[0146] The processing module 402 is used to determine, for each pre-divided first category, the target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category, determine the target image acquired by the target acquisition device in the image to be clustered, and classify the target image based on the facial features contained in the target image.
[0147] Furthermore, the processing module 402 is also used to receive the position information of each acquisition device and the divided images collected within a unit time sent by each acquisition device, and classify the divided images; for each second category after division, sort the acquisition devices according to the time sequence in which the divided images contained in the second category are collected; for each acquisition device, determine the target-related device of the acquisition device according to each acquisition device and adjacent acquisition devices in the sorting results corresponding to each second category; construct an input graph containing nodes corresponding to each acquisition device determined according to the position information of each acquisition device, and determine the first eigenvector corresponding to each node in the input graph; input the input graph and the first eigenvector corresponding to each node into a pre-trained vector determination model to obtain the target vector corresponding to each node output by the vector determination model; adaptively cluster the target vector corresponding to each node, determine the target vector contained in each category, and regard the acquisition devices corresponding to the target vector contained in each category as the same category.
[0148] Furthermore, the processing module 402 is specifically used to determine, for each of the acquisition devices, a first preset number of candidate acquisition devices adjacent to the acquisition device in each sorting result according to the sorting result corresponding to each second category; and determine a second preset number of candidate acquisition devices as target-related devices of the acquisition device according to the determined number of occurrences of the candidate acquisition devices of the acquisition device.
[0149] Furthermore, the processing module 402 is specifically used to determine the distance between any two collection devices based on the location information of each collection device; construct a node corresponding to each collection device; for each collection device, obtain a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold, and if there is no connection relationship between the target node and the node corresponding to the collection device, establish a corresponding connection relationship.
[0150] Furthermore, the processing module 402 is specifically used to input the input graph and the first eigenvector corresponding to each node into the vector determination model. The vector determination model uses any preset aggregation function for the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0151] Furthermore, the processing module 402 is also used for the vector determination model to use any preset aggregation function for the target vector corresponding to each node connected to each node in the input graph to determine a second aggregation vector, and update and output the target vector based on the second aggregation vector, the target vector corresponding to the node and the second weight corresponding to each pre-saved vector.
[0152] Furthermore, the processing module 402 is also used to obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node; randomly scramble the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph; input the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and input the sample damage graph and the third eigenvector corresponding to each node in the sample damage graph into the original model to obtain the sample output vector corresponding to each node; The fourth eigenvector is input into the original model to obtain the damaged output vector corresponding to each node in the sample damage graph output by the original model; wherein, the sample output vector corresponding to each node and the damaged output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the number of images sent by the acquisition device corresponding to the node; according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damaged output vector corresponding to each node in the sample damage graph and the loss function, the loss value corresponding to the sample input graph is determined; according to the loss value determined for each sample input graph in the sample set, the original neural network model is trained to obtain a trained vector determination model.
[0153] Example 8:
[0154] Figure 5This is a schematic diagram of the structure of an electronic device provided by the present invention. Based on the above embodiments, the embodiment of the present invention further provides an electronic device, such as Figure 5 As shown, it includes: a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504;
[0155] The memory 503 stores a computer program. When the program is executed by the processor 501, the processor 501 performs the following steps:
[0156] Receiving images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time;
[0157] For each pre-divided first category, the target acquisition device included in each pre-saved first category is determined, the target image captured by the target acquisition device in the image to be clustered is determined, and the target image is classified according to the facial features contained in the target image.
[0158] In a possible implementation, the acquisition devices included in each first category are determined in the following manner:
[0159] receiving the location information of each acquisition device and the segmented images acquired within a unit time sent by each acquisition device, and classifying the segmented images;
[0160] For each divided second category, sort the acquisition devices according to the time sequence in which the divided images contained in the second category were acquired; for each acquisition device, determine the target related device of the acquisition device based on each acquisition device and adjacent acquisition devices in the sorting result corresponding to each second category;
[0161] Constructing an input graph including nodes corresponding to each acquisition device determined according to the position information of each acquisition device, and determining a first eigenvector corresponding to each node in the input graph;
[0162] Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining a target vector corresponding to each node output by the vector determination model;
[0163] Adaptively cluster the target vectors corresponding to each node to determine the target vectors included in each category, and treat the acquisition devices corresponding to the target vectors included in each category as the same category.
[0164] In a possible implementation, for each collection device, determining the target related device of the collection device according to each collection device and adjacent collection devices in the sorting results corresponding to each second category includes:
[0165] For each of the acquisition devices, according to the sorting results corresponding to each second category, a first preset number of candidate acquisition devices adjacent to the acquisition device are determined in each sorting result; according to the determined number of occurrences of the candidate acquisition devices of the acquisition device, a second preset number of candidate acquisition devices are determined as target-related devices of the acquisition device.
[0166] In a possible implementation, constructing an input graph including nodes corresponding to each collection device determined according to the location information of each collection device includes:
[0167] Determine the distance between any two acquisition devices based on the location information of each acquisition device;
[0168] Build the node corresponding to each acquisition device;
[0169] For each collection device, a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold is obtained. If there is no connection relationship between the target node and the node corresponding to the collection device, a corresponding connection relationship is established.
[0170] In a possible implementation, inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining each target vector output by the vector determination model includes:
[0171] The input graph and the first eigenvector corresponding to each node are input into the vector determination model. The vector determination model uses any preset aggregation function on the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0172] In one possible implementation, the method further includes:
[0173] The vector determination model uses any preset aggregation function for each node in the input graph on the target vector corresponding to each node connected to the node to determine a second aggregate vector, and updates and outputs the target vector based on the second aggregate vector, the target vector corresponding to the node, and the pre-stored second weight corresponding to each vector.
[0174] In one possible implementation, the vector determination model is trained in the following manner:
[0175] Obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node and the number of images sent by the acquisition device corresponding to the node; randomly shuffle the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph;
[0176] Inputting the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and inputting the sample damage graph and the fourth eigenvector corresponding to each node in the sample damage graph into the original model to obtain the damage output vector corresponding to each node in the sample damage graph output by the original model; wherein the sample output vector corresponding to each node and the damage output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node;
[0177] Determine a loss value corresponding to the sample input graph according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damage output vector corresponding to each node in the sample damage graph, and the loss function;
[0178] The original neural network model is trained according to the loss value corresponding to each sample input graph in the sample set to obtain a trained vector determination model.
[0179] The communication bus mentioned in the server above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0180] The communication interface is used for communication between the above electronic device and other devices.
[0181] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk memory. Alternatively, the memory may be at least one storage device located away from the processor.
[0182] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it can also be a digital signal processing processor (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0183] Example 9:
[0184] Based on the above embodiments, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device. When the program is executed on the electronic device, the electronic device implements the following steps:
[0185] The memory stores a computer program, which, when executed by the processor, causes the processor to perform the following steps:
[0186] Receiving images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time;
[0187] For each pre-divided first category, the target acquisition device included in each pre-saved first category is determined, the target image captured by the target acquisition device in the image to be clustered is determined, and the target image is classified according to the facial features contained in the target image.
[0188] In a possible implementation, the acquisition devices included in each first category are determined in the following manner:
[0189] receiving the location information of each acquisition device and the segmented images acquired within a unit time sent by each acquisition device, and classifying the segmented images;
[0190] For each divided second category, sort the acquisition devices according to the time sequence in which the divided images contained in the second category were acquired; for each acquisition device, determine the target related device of the acquisition device based on each acquisition device and adjacent acquisition devices in the sorting result corresponding to each second category;
[0191] Constructing an input graph including nodes corresponding to each acquisition device determined according to the position information of each acquisition device, and determining a first eigenvector corresponding to each node in the input graph;
[0192] Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining a target vector corresponding to each node output by the vector determination model;
[0193] Adaptively cluster the target vectors corresponding to each node to determine the target vectors included in each category, and treat the acquisition devices corresponding to the target vectors included in each category as the same category.
[0194] In a possible implementation, for each collection device, determining the target related device of the collection device according to each collection device and adjacent collection devices in the sorting results corresponding to each second category includes:
[0195] For each of the acquisition devices, according to the sorting results corresponding to each second category, a first preset number of candidate acquisition devices adjacent to the acquisition device are determined in each sorting result; according to the determined number of occurrences of the candidate acquisition devices of the acquisition device, a second preset number of candidate acquisition devices are determined as target-related devices of the acquisition device.
[0196] In a possible implementation, constructing an input graph including nodes corresponding to each collection device determined according to the location information of each collection device includes:
[0197] Determine the distance between any two acquisition devices based on the location information of each acquisition device;
[0198] Build the node corresponding to each acquisition device;
[0199] For each collection device, a target node corresponding to a collection device whose distance to the collection device is less than a preset distance threshold is obtained. If there is no connection relationship between the target node and the node corresponding to the collection device, a corresponding connection relationship is established.
[0200] In a possible implementation, inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining each target vector output by the vector determination model includes:
[0201] The input graph and the first eigenvector corresponding to each node are input into the vector determination model. The vector determination model uses any preset aggregation function on the first eigenvector corresponding to each node connected to each node in the input graph to determine the first aggregation vector. Based on the first aggregation vector, the first eigenvector corresponding to the node and the first weight corresponding to each pre-saved vector, the target vector corresponding to the node is determined and output.
[0202] In one possible implementation, the method further includes:
[0203] The vector determination model uses any preset aggregation function for each node in the input graph on the target vector corresponding to each node connected to the node to determine a second aggregate vector, and updates and outputs the target vector based on the second aggregate vector, the target vector corresponding to the node, and the pre-stored second weight corresponding to each vector.
[0204] In one possible implementation, the vector determination model is trained in the following manner:
[0205] Obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node and the number of images sent by the acquisition device corresponding to the node; randomly shuffle the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph;
[0206] Inputting the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and inputting the sample damage graph and the fourth eigenvector corresponding to each node in the sample damage graph into the original model to obtain the damage output vector corresponding to each node in the sample damage graph output by the original model; wherein the sample output vector corresponding to each node and the damage output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node;
[0207] Determine a loss value corresponding to the sample input graph according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damage output vector corresponding to each node in the sample damage graph, and the loss function;
[0208] The original neural network model is trained according to the loss value corresponding to each sample input graph in the sample set to obtain a trained vector determination model.
[0209] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0210] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0211] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0212] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0213] Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if such changes and modifications fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A portrait clustering method, characterized in that: The method comprises: Receiving images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time; For each pre-divided first category, determining a target acquisition device included in the first category based on the acquisition devices included in each pre-saved first category, determining a target image acquired by the target acquisition device in the images to be clustered, and classifying the target image based on facial features included in the target image; The acquisition devices included in each first category are determined in the following manner: receiving the location information of each acquisition device and the segmented images acquired within a unit time sent by each acquisition device, and classifying the segmented images; For each second category after classification, the collection devices are sorted according to the time sequence in which the divided images contained in the second category are collected; for each collection device, according to the sorting results corresponding to each second category, a first preset number of candidate collection devices adjacent to the collection device are determined in each sorting result; according to the determined number of occurrences of the candidate collection devices of the collection device, a second preset number of candidate collection devices are determined as target related devices of the collection device; Determine the distance between any two collection devices according to the position information of each collection device; construct a node corresponding to each collection device; for each collection device, obtain the target node corresponding to the collection device whose distance from the collection device is less than the preset distance threshold; if there is no connection relationship between the target node and the node corresponding to the collection device, establish a corresponding connection relationship to obtain an input graph containing the node corresponding to each collection device; determine the first feature vector corresponding to each node in the input graph; Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model, and obtaining a target vector corresponding to each node output by the vector determination model; Adaptively cluster the target vectors corresponding to each node to determine the target vectors included in each category, and treat the acquisition devices corresponding to the target vectors included in each category as the same category.
2. The method according to claim 1, characterized in that Inputting the input graph and the first feature vector corresponding to each node into a pre-trained vector determination model to obtain each target vector output by the vector determination model includes: The input graph and the first feature vector corresponding to each node are input into the vector determination model. For each node in the input graph, the vector determination model uses any preset aggregation function for the first feature vector corresponding to each node connected to the node to determine the first aggregation vector. According to the first aggregation vector, the first feature vector corresponding to the node and the first weight corresponding to each vector saved in advance, the target vector corresponding to the node is determined and output.
3. The method according to claim 2, characterized in that The method further comprises: The vector determination model uses any preset aggregation function for each node in the input graph on the target vector corresponding to each node connected to the node to determine a second aggregate vector, and updates and outputs the target vector based on the second aggregate vector, the target vector corresponding to the node, and the pre-stored second weight corresponding to each vector.
4. The method according to claim 1, wherein The vector determination model is trained in the following way: Obtain any sample input graph in the sample set and the third eigenvector corresponding to each node in the sample input graph, wherein the third eigenvector corresponding to each node includes the identifier of the target-related device of the acquisition device corresponding to the node and the number of images sent by the acquisition device corresponding to the node; randomly shuffle the sample input graph to obtain a sample damage graph, and for each node in the sample damage graph, determine the third eigenvector corresponding to the node in the sample input graph as the fourth eigenvector corresponding to the node in the sample damage graph; Inputting the sample input graph and the third eigenvector corresponding to each node into the original model to obtain the sample output vector corresponding to each node output by the original model; and inputting the sample damage graph and the fourth eigenvector corresponding to each node in the sample damage graph into the original model to obtain the damage output vector corresponding to each node in the sample damage graph output by the original model; wherein the sample output vector corresponding to each node and the damage output vector corresponding to each node in the sample damage graph include the identifiers of other nodes connected to the node, the identifier of the target-related device of the acquisition device corresponding to the node, and the counted number of images sent by the acquisition device corresponding to the node; Determine a loss value corresponding to the sample input graph according to the sample output vector corresponding to each node, the sample input graph, the sample damage graph, the damage output vector corresponding to each node in the sample damage graph, and the loss function; The original model is trained according to the loss value corresponding to each sample input graph in the sample set to obtain a trained vector determination model.
5. A portrait clustering device, characterized in that: The device comprises: A receiving module, configured to receive the images to be clustered sent by each acquisition device; wherein the images to be clustered are acquired by the corresponding acquisition device within a unit time; a processing module configured to determine, for each pre-classified first category, a target acquisition device included in the first category based on the acquisition devices included in each pre-stored first category, determine a target image acquired by the target acquisition device in the images to be clustered, and classify the target image based on facial features included in the target image; Wherein, the processing module is also configured to receive the location information of each collection device and the divided images collected per unit time sent by each collection device, and classify the divided images; for each second category after division, sort the collection devices according to the time order in which the divided images contained in the second category are collected; for each collection device, according to each second category Corresponding sorting results, determine a first preset number of candidate collection devices adjacent to the collection device in each sorting result; determine a second preset number of candidate collection devices according to the determined occurrence times of candidate collection devices of the collection device; determine the distance between any two collection devices based on the location information of each collection device; construct each collection device The node corresponding to the device; for each collection device, obtain the target node corresponding to the collection device whose distance from the collection device is less than the preset distance threshold. If there is no connection relationship between the target node and the node corresponding to the collection device, establish a corresponding connection relationship and obtain an input graph containing the node corresponding to each collection device; determine the first feature direction corresponding to each node in the input graph quantity; input the input graph and the first feature vector corresponding to each node into the vector determination model that has been trained in advance, and obtain the target vector corresponding to each node output by the vector determination model; perform adaptive clustering on the target vector corresponding to each node, determine the target vector contained in each category, and use the collection device corresponding to the target vector contained in each category as the same category.
6. An electronic device, characterized in that: The electronic device includes at least a processor and a memory, and the processor is configured to implement the steps of the portrait clustering method according to any one of claims 1 to 4 when executing a computer program stored in the memory.
7. A computer-readable storage medium, characterized in that It stores a computer program, which, when executed by a processor, implements the steps of the portrait clustering method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Identity information confirmation method and device, storage medium and electronic device
CN112258363A