Image clustering methods, apparatus and electronic devices
By constructing and analyzing target subgraph pairs containing first-order and second-order neighbor nodes, the problem of low accuracy of connection weights in graph convolutional neural network clustering algorithms is solved, and more accurate image clustering results are achieved.
Patent Information
- Application Number
- CN202111109089.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-22
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-09-22
AI Technical Summary
Existing clustering algorithms based on graph convolutional neural networks have low accuracy in predicting the connection weights between the center node and its first-order neighbors because the subgraphs do not contain the second-order neighbors of the first-order neighbors, which in turn affects the accuracy of the clustering results.
During the clustering process, the first-order and second-order neighborhood images of the image set to be clustered are obtained, a target subgraph set is constructed, and target subgraph pairs are selected from it for predictive analysis to obtain the target weights between the central nodes. Clustering is then performed using the second-order neighborhood node information of the first and second target subgraphs included in the target subgraph pairs.
By referencing the relationship between the central node and its first-order and second-order neighbors, the accuracy of the clustering results is improved, ensuring the accuracy of clustering based on the target weights.
Smart Images

Figure CN115862082B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to an image clustering method, apparatus, and electronic device. Background Technology
[0002] With the development of science and technology, facial recognition is being used more and more widely. Facial clustering is one of the technologies used in facial recognition. Currently, facial clustering algorithms mainly include k-means algorithm, adjacency-based clustering algorithm, hierarchical clustering algorithm, conditional random field-based facial clustering algorithm, graph convolutional neural network-based clustering algorithm, and clustering algorithms based on confidence and connectivity, etc.
[0003] In one clustering algorithm based on graph convolutional neural networks, a subgraph is first constructed. Then, the subgraph is input into the graph convolutional network to predict the connection weights between the center node of the subgraph and its first-order neighboring nodes. Finally, clustering is performed based on these connection weights. However, this method has low clustering accuracy. Summary of the Invention
[0004] This application provides an image clustering method, apparatus, and electronic device that can improve the accuracy of image clustering.
[0005] An image clustering method, comprising:
[0006] Obtain the set of images to be clustered, and determine the first-order neighborhood images and the second-order neighborhood images of each image in the set.
[0007] Based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered, a set of target subgraphs is constructed.
[0008] Select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0009] Predictive analysis is performed on the above target subgraphs to obtain the target weights between the center nodes of the first target subgraph and the second target subgraph.
[0010] Cluster the images to be clustered based on the aforementioned target weights.
[0011] Accordingly, embodiments of this application provide an image clustering apparatus, including:
[0012] The determination module is used to acquire the set of images to be clustered, and to determine the first-order neighborhood images and the second-order neighborhood images of each image to be clustered in the set of images to be clustered.
[0013] The construction module is used to construct a set of target subgraphs based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered.
[0014] The selection module is used to select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0015] The analysis module is used to perform predictive analysis on the above target subgraph pairs to obtain the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph.
[0016] The clustering module clusters the images to be clustered according to the aforementioned target weights.
[0017] Furthermore, this application also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the image clustering method provided in this application.
[0018] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a computer program adapted for loading by a processor to execute steps in any of the image clustering methods provided in embodiments of this application.
[0019] Furthermore, this application also provides a computer program product, including a computer program that, when executed by a processor, implements any of the image clustering methods provided in this application.
[0020] In this embodiment, a set of images to be clustered is first obtained, and the first-order and second-order neighboring images to be clustered for each image in the set are determined. Then, a target subgraph set is constructed based on these first-order and second-order neighboring images. Next, target subgraph pairs are selected from the target subgraph set. Each target subgraph pair includes a first target subgraph and a second target subgraph, where the center node of the second target subgraph is a first-order neighbor of the center node of the first target subgraph. Predictive analysis is then performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs. Finally, the images to be clustered are clustered according to these target weights.
[0021] Since the center node of the second target subgraph is a first-order neighbor of the center node of the first target subgraph, the target weight between the center nodes of the first and second target subgraphs is equivalent to the target weight between the center node of the first target subgraph and its first-order neighbor. Because the target subgraph pair includes both the first and second target subgraphs, and both include second-order neighbor nodes, when predicting the target weight between the center node of the first target subgraph and its first-order neighbor through the target subgraph pair, the information of the second-order neighbor nodes in both the first and second target subgraphs can be referenced simultaneously. This allows for a more accurate determination of the target weight between the center node of the first target subgraph and its first-order neighbor, leading to more accurate clustering results for the images to be clustered based on the target weight. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a schematic diagram of a scenario illustrating the image clustering method provided in an embodiment of this application;
[0024] Figure 2 This is a schematic diagram of sub-diagram N provided in the embodiments of this application;
[0025] Figure 3 This is a schematic diagram of the target sub-graph pair provided in the embodiments of this application;
[0026] Figure 4 This is a flowchart illustrating the image clustering method provided in an embodiment of this application;
[0027] Figure 5 This is a schematic diagram of the first-order neighborhood image to be clustered and the second-order neighborhood image to be clustered, provided in the embodiments of this application;
[0028] Figure 6 This is a schematic diagram of the structure of a trained graph network model provided in an embodiment of this application;
[0029] Figure 7 This is another schematic diagram of the structure of the trained graph network model provided in the embodiments of this application;
[0030] Figure 8This is a schematic diagram showing that the first-order neighboring nodes of the center node of the first target subgraph and the first-order neighboring nodes of the center node of the second target subgraph are the same.
[0031] Figure 9 This is a flowchart illustrating the training method for a trained graph network model provided in an embodiment of this application.
[0032] Figure 10 This is a flowchart illustrating the application method of the trained graph network model provided in the embodiments of this application;
[0033] Figure 11 This is a schematic diagram of the image clustering device provided in the embodiments of this application;
[0034] Figure 12 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0035] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0036] This application provides an image clustering method, apparatus, and electronic device. The image clustering apparatus can be integrated into an electronic device, which may be a server or a terminal, etc.
[0037] The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms.
[0038] The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and the server can be connected directly or indirectly through wired or wireless communication, which is not limited herein.
[0039] For example, see Figure 1Taking the image clustering device integrated into a terminal as an example, the terminal first acquires the set of images to be clustered and determines the first-order and second-order neighboring images of each image in the set. Then, based on these first-order and second-order neighboring images, the terminal constructs a target subgraph set. Next, the terminal selects a target subgraph pair from the target subgraph set. Each target subgraph pair includes a first target subgraph and a second target subgraph, where the center node of the second target subgraph is a first-order neighbor of the center node of the first target subgraph. The terminal then performs predictive analysis on the target subgraph pair to obtain the target weights between the center nodes of the first and second target subgraphs. Finally, the terminal clusters the images to be clustered according to these target weights.
[0040] Furthermore, in the embodiments of this application, "multiple" refers to two or more. The terms "first" and "second," etc., in the embodiments of this application are used for distinguishing descriptions and should not be construed as implying relative importance.
[0041] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the preferred order of the embodiments.
[0042] In graph convolutional neural network-based clustering algorithms, a subgraph is first constructed based on the first and second-order neighbors of the center node. This subgraph is then input into the graph convolutional network to predict the connection weights between the center node and its first-order neighbors. Finally, clustering is performed based on these connection weights. However, in this method, because the subgraph does not include the second-order neighbors of the first-order neighbors, when predicting the connection weights between the center node and its first-order neighbors, the information of the second-order neighbors of the center node can be referenced, but not the information of the second-order neighbors of the first-order neighbors. This results in low accuracy of the final connection weights, and consequently, low accuracy of the clustering results.
[0043] For example, such as Figure 2 As shown, in subgraph N, when calculating the connection weight between the center node n0 and the first-order node n1 of the center node n0, the relationship between the center node n0 and the second-order neighbor node n2 and the second-order neighbor node n3 of the center node n0 can be referenced.
[0044] However, since the subgraph N does not include the second-order neighbor nodes n4 and n5 of the first-order neighbor node n1, the relationship between the first-order neighbor node n1 and the second-order neighbor nodes n4 and n5 cannot be referenced. As a result, the accuracy of the connection weight between the center node n0 and the first-order node n1 of the center node n0 is not high.
[0045] To address this technical problem, embodiments of this application provide an image clustering method. In this method, a set of images to be clustered is first acquired, and the first-order and second-order neighboring images of each image in the set are determined. Then, a target subgraph set is constructed based on the first-order and second-order neighboring images. Next, a target subgraph pair is selected from the target subgraph set. The target subgraph pair includes a first target subgraph and a second target subgraph, where the center node of the second target subgraph is a first-order neighbor node of the center node of the first target subgraph.
[0046] For example, the target subgraph is as follows Figure 3 As shown, the center node n1 of the second target subgraph is the first-order neighbor node n1 of the center node n0 of the first target subgraph.
[0047] Next, predictive analysis is performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs. Finally, the images to be clustered are clustered based on the target weights.
[0048] Since the center node n1 of the second target subgraph is the first-order neighbor node n1 of the center node n0 of the first target subgraph, the target weight between the center node n0 of the first target subgraph and the center node n1 of the second target subgraph is equivalent to the target weight between the center node n0 of the first target subgraph and the first-order neighbor node n1 of the center node n0 of the first target subgraph.
[0049] Because the target subgraph pair includes a first target subgraph and a second target subgraph, and both the first and second target subgraphs include second-order neighbor nodes, when predicting the target weight between the center node n0 of the first target subgraph and the first-order neighbor node n1 of the center node n0 through the target subgraph pair, we can refer to the relationship between the center node n0 and the second-order neighbor nodes n2 and n3 of the center node n0, the relationship between the first-order neighbor node n1 of the center node n0 and the second-order neighbor nodes n2 and n3 of the center node n0, and the relationship between the first-order neighbor node n1 of the center node n0 and the second-order neighbor nodes n4 and n5 of the first-order neighbor node n1 of the center node n0.
[0050] That is, while referring to the relationship between the center node n0 and its second-order neighbor nodes n2 and n3, the relationship between the first-order neighbor node n1 and its second-order neighbor nodes n4 and n5 can also be referenced. This allows for a more accurate determination of the target weight between the center node n0 of the first target subgraph and its first-order neighbor node n1, thus making the clustering results of the image to be clustered based on the target weight more accurate.
[0051] In this embodiment, the description will focus on an image clustering device, which can be integrated into an electronic device, such as a server or a terminal. For ease of explanation of the image processing method of this application, the following detailed description will focus on the integration of the image clustering device into a terminal, i.e., the terminal will be used as the execution subject.
[0052] Please see Figure 4 , Figure 4 This is a schematic flowchart of an image clustering method provided in an embodiment of this application. The image clustering method may include:
[0053] S401. Obtain the set of images to be clustered, and determine the first-order neighborhood images and the second-order neighborhood images of each image in the set.
[0054] The image set to be clustered includes multiple images. These images can be human face images or animal images; users can choose the specific type of images based on their actual needs, and this application does not impose any restrictions on this.
[0055] The first-order neighborhood of each image to be clustered refers to the k1 nearest neighbor images of each image to be clustered. The value of k1 can be set according to the actual situation, and this application does not limit it.
[0056] For example, such as Figure 5 As shown, when k1 is 3, the three nearest neighbor images to be clustered for the image n0 are n1, n7 and n8, respectively. Then the first-order neighborhood images to be clustered for the image n0 are n1, n7 and n8, respectively.
[0057] The second-order neighborhood of the image to be clustered refers to the k2 nearest neighbor images of the first-order neighborhood of the image to be clustered. For example, such as Figure 5As shown, when k1 is 3 and k2 is 2, the first-order neighborhood images to be clustered for the image n0 are n1, n7, and n8, respectively; the first-order neighborhood images to be clustered for the image n1 are n2 and n3, respectively; and the first-order neighborhood images to be clustered for the image n7 are n9 and n8, respectively. 10 The first-order neighborhood of the image n8 to be clustered is the image n to be clustered. 11 and the image n to be clustered 12 Then, the second-order neighborhood images to be clustered of the image n0 are the images to be clustered n2, n3, n9, and n1, respectively. 10 n images to be clustered 11 and the image n to be clustered 12 .
[0058] The user can choose the method for determining the first-order and second-order neighborhood images of each image in the image set to be clustered, according to the actual situation. For example, in this application, the first-order and second-order neighborhood images of each image in the image set to be clustered are determined by a trained convolutional network model or an autoencoder network model. This application does not limit the method.
[0059] The terminal can acquire the image set to be clustered by capturing it with its own camera. Alternatively, another terminal can capture the image set to be clustered and then send it to this terminal, which then acquires the image set. Users can choose the method by which the terminal acquires the image set according to their actual needs; this application does not impose any restrictions on this method.
[0060] S402. Based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered, construct a set of target subgraphs.
[0061] After obtaining the first-order and second-order neighborhood images to be clustered, the terminal constructs a target subgraph by using the image to be clustered as the center node of the target subgraph, the first-order neighborhood images of the image to be clustered as the first-order neighborhood nodes of the target subgraph, and the second-order neighborhood images of the image to be clustered as the second-order neighborhood nodes of the target subgraph. Since each image to be clustered corresponds to one target subgraph, multiple target subgraphs can be obtained, and these multiple target subgraphs form a target subgraph set.
[0062] S403. Select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0063] After obtaining the target subgraph set, the terminal selects a target subgraph pair from the target subgraph set. The target subgraph pair includes a first target subgraph and a second target subgraph, and the center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0064] For example, the target subgraph is as follows Figure 3 As shown, the center node n1 of the second target subgraph is the first neighbor node n1 of the center node n0 of the first target subgraph.
[0065] When the first-order neighbor nodes of the central node of the first target subgraph include multiple nodes, then multiple pairs of target subgraphs can be selected from the set of target subgraphs for the first target subgraph. For example, the first target subgraph is as follows: Figure 3 As shown, the first-order neighbor nodes of the center node n0 of the first target subgraph include three nodes: n1, n7, and n8. Therefore, for the first target subgraph, three target subgraph pairs can be selected from the target subgraph set. These three target subgraph pairs are target subgraph pair 1, target subgraph pair 2, and target subgraph pair 3. Target subgraph pair 1 includes the first target subgraph and the second target subgraph with center node n1; target subgraph pair 2 includes the first target subgraph and the second target subgraph with center node n7; and target subgraph pair 3 includes the first target subgraph and the second target subgraph with center node n8.
[0066] S404. Perform predictive analysis on the target subgraph pair to obtain the target weight between the center node of the first target subgraph and the center node of the second target subgraph.
[0067] Since the center node of the second target subgraph is the first neighbor node of the center node of the first target subgraph, the target weight between the center node of the first target subgraph and the center node of the second target subgraph is equivalent to the target weight between the center node of the first target subgraph and the first neighbor node of the center node of the first target subgraph.
[0068] When the first-order neighboring nodes of the central node of the first target subgraph include multiple nodes, the target weights between the central node of the first target subgraph and each first-order neighboring node can be obtained after performing predictive analysis on multiple target subgraph pairs related to the first target subgraph.
[0069] For example, such as Figure 3 As shown, regarding the first target subgraph, three target subgraph pairs can be selected from the target subgraph set. After performing predictive analysis on the three target subgraph pairs, the target weights between the central node n0 of the first target subgraph and the first-order neighbor node n1, the target weights between the central node n0 and the first-order neighbor node n7, and the target weights between the central node n0 and the first-order neighbor node n8 can be obtained.
[0070] In this embodiment, since the target subgraph pair includes a first target subgraph and a second target subgraph, and both the first and second target subgraphs include second-order neighbor nodes, when predicting and analyzing the target weight between the center node of the first target subgraph and the first-order neighbor nodes of the center node of the first target subgraph through the target subgraph pair, the information of the second-order neighbor nodes in the first target subgraph and the second target subgraph can be referenced simultaneously, thereby enabling a more accurate determination of the target weight between the center node of the first target subgraph and the first-order neighbor nodes of the center node of the first target subgraph.
[0071] In some embodiments, predictive analysis is performed on the target subgraph pairs to obtain the target weight between the center nodes of the first target subgraph and the center nodes of the second target subgraph, including:
[0072] The target subgraph is input into the trained graph network model for prediction analysis to obtain the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph.
[0073] The trained graph network model can include trained graph convolutional networks and trained fully connected layers. For example, such as... Figure 6 As shown. The process of inputting the target sub-graph pair into the trained graph network model for prediction analysis can be as follows: First, input the first target sub-graph in the target sub-graph pair into the trained graph convolutional network for feature extraction to obtain the first feature vector. Then, within a preset time, input the second target sub-graph in the target sub-graph pair into the trained graph convolutional network for feature extraction to obtain the second feature vector. The first and second feature vectors are concatenated to obtain the target feature vector. Finally, the target feature vector is input into the trained fully connected layer for recognition, thereby obtaining the target weights of the center nodes of the first and second target sub-graphs.
[0074] In this embodiment, the trained graph convolutional network model determines that the second target subgraph and the first target subgraph belong to the same target subgraph pair at a preset time. Alternatively, an identifier for the target subgraph pair can be set, and the first target subgraph carries the identifier and the second target subgraph carries the identifier, so that the terminal can determine that the first target subgraph and the second target subgraph belong to the same target subgraph pair through the identifier carried by the first target subgraph and the identifier carried by the second target subgraph.
[0075] Alternatively, the trained graph network model includes a trained first graph convolutional network, a trained second graph convolutional network, and trained fully connected layers. For example, such as... Figure 7As shown. At this point, the process of inputting the target subgraph into the trained graph network model for prediction analysis can be as follows:
[0076] The terminal inputs the first target sub-image from the target sub-image pair into a pre-trained first-graph convolutional network for feature extraction, obtaining a first feature vector. Simultaneously, it inputs the second target sub-image from the target sub-image pair into a pre-trained second-graph convolutional network for feature extraction, obtaining a second feature vector. The terminal then concatenates the first and second feature vectors to obtain the target vector. Finally, the terminal inputs the target vector into a pre-trained fully connected layer to obtain the target weights of the center nodes of the first and second target sub-images.
[0077] In this embodiment, the first target subgraph and the second target subgraph are determined to belong to the same target subgraph pair by inputting the first target subgraph and the second target subgraph side by side.
[0078] S405. Cluster the images to be clustered according to the target weights.
[0079] Because the target weights are more accurate, clustering the images with these target weights will also be more accurate.
[0080] Optionally, the process of clustering the images to be clustered according to the target weights can be as follows: construct a target adjacency matrix according to the target weights, and then use the Disjoint Set Union (DSU) algorithm or the minimum spanning tree algorithm to divide the elements in the target adjacency matrix to obtain the clustering results of the images to be clustered.
[0081] When there are some false positive or false negative images to be clustered, the false positive image to be clustered (or the false negative image to be clustered) may be the first-order neighbor of the center node of the first target subgraph and the first-order neighbor of the center node of the second target subgraph at the same time. That is, at this time, the first-order neighbor of the center node of the first target subgraph and the first-order neighbor of the center node of the second target subgraph have the same node.
[0082] For example, such as Figure 8 As shown, the first-order neighbor nodes of the center node n0 in the first target subgraph include the first-order neighbor node n9 and the first-order neighbor node n. 10 The first-order neighbor nodes of the center node n1 in the second target subgraph also include the first-order neighbor nodes n9 and n1. 10 Then, the first-order neighbor nodes of the center node n0 of the first target subgraph and the second-order neighbor nodes of the center node n1 of the second target have the same nodes n9 and n1. 10 .
[0083] The presence of false positive clustering images (actually negative, predicted as positive) or false negative clustering images (actually positive, predicted as negative) reduces the accuracy of the clustering results. Therefore, to further improve the accuracy of the clustering results, this embodiment, after obtaining the target weights, calculates the target confidence based on the first target weight of the first target subgraph and the second target weight of the second target subgraph if the first-order neighbor nodes of the center node of the first target subgraph and the first-order neighbor nodes of the center node of the second target subgraph are identical. Specifically, the initial confidence of the center node of the first target subgraph relative to the center node of the second target subgraph can be calculated by substituting the first target weight of the first target subgraph and the second target weight of the second target subgraph into the following formula:
[0084]
[0085] Wherein, C(n) i ,n j ) represents the center node n of the first target subgraph. i Relative to the center node n of the second target subgraph j The initial confidence level, N shared Represents the central node n i First-order neighbor nodes and center node n j The set of nodes that are identical to the first-order neighbor nodes, n k N represents the same node. neighbors Represents the central node n i The set of first-order neighbor nodes, n p Represents the central node n i The first-order neighbor node, prob() represents the target weight.
[0086] For example, such as Figure 8 As shown, the initial confidence level of the center node n0 of the first target subgraph relative to the center node n1 of the second target subgraph is:
[0087]
[0088] Similarly, the initial confidence level C(n) of the center node of the second target subgraph relative to the center node of the first target subgraph can be calculated. j ,n i Finally, the initial confidence level C(n) is calculated. i ,n j ) and initial confidence level C(n) j ,n i Substituting into the following formula, the target confidence level C(n) i ,n j )':
[0089] C(ni ,n j )'=max(C(n i ,n j ),C(n j ,n i ))
[0090] The first target weight of the first target subgraph refers to the target weight between the center node of the first target subgraph and each of the first-order neighboring nodes of the center node of the first target subgraph. The second target weight of the second target subgraph refers to the target weight between the center node of the second target subgraph and each of the first-order neighboring nodes of the center node of the second target subgraph.
[0091] After obtaining the target confidence score, the terminal updates the initial adjacency matrix based on the target confidence score to obtain the target adjacency matrix. Finally, it clusters the images to be clustered based on the target adjacency matrix. Specifically, the process of updating the initial adjacency matrix based on the target confidence score can be as follows: if the target confidence score is higher than a preset threshold, the target weight between the center node of the first target subgraph and the center node of the second target subgraph in the initial adjacency matrix is updated to 1; otherwise, it is updated to 0.
[0092] In this embodiment, after obtaining the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph, if the first-order neighbor nodes of the center node of the first target subgraph and the first-order neighbor nodes of the center node of the second target subgraph have the same nodes, the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph are updated, thereby reducing the impact of false positive or false negative images to be clustered and improving the accuracy of the clustering results.
[0093] In some embodiments, before inputting the target subgraph pair into a trained graph network model for predictive analysis, the method further includes:
[0094] The terminal acquires a training sample set and determines the first-order and second-order neighborhood training samples for each training sample in the set. Then, using the training samples as the center nodes of the initial subgraphs, the first-order neighborhood training samples as the first-order neighbors of the initial subgraphs, and the second-order neighborhood training samples as the second-order neighbors of the initial subgraphs, an initial subgraph set is constructed. Next, initial subgraph pairs are selected from the initial subgraph set, including a first initial subgraph and a second initial subgraph, where the center node of the second initial subgraph is the first-order neighbor of the center node of the first initial subgraph. The terminal then inputs the initial subgraph pairs into the graph network model to be trained for identification, obtaining the initial weights between the center nodes of the first and second initial subgraphs. Finally, the terminal trains the graph network model to be trained based on the initial weights and the labels corresponding to the training samples, obtaining the trained graph network model.
[0095] Optionally, the specific process of training the graph network model to be trained based on the initial weights and the labels corresponding to the training samples to obtain the trained graph network model can be as follows:
[0096] The target loss value is determined based on the initial weights and the labels corresponding to the training samples, and the number of training iterations is recorded. If the target loss value is less than or equal to the threshold and the number of training iterations is equal to the preset number, training stops, and the trained graph network model is obtained. If the target loss value is greater than the threshold or the number of training iterations is less than the preset number, the network parameters of the graph network model to be trained are updated according to the target loss value, and the process returns to retrieve the training sample set.
[0097] In some possible implementations, the graph network model to be trained includes a first graph convolutional network to be trained, a second graph convolutional network to be trained, and a fully connected layer to be trained.
[0098] Accordingly, the initial subgraphs are input into the graph network model to be trained for identification, resulting in the initial weights of the center nodes of the first and second initial subgraphs, including:
[0099] The first initial subgraph from the initial subgraph pair is input into the first graph convolutional network to be trained for feature extraction, resulting in the third feature vector. The second initial subgraph from the initial subgraph pair is input into the second graph convolutional network to be trained for feature extraction, resulting in the fourth feature vector. The third and fourth feature vectors are concatenated to obtain the initial feature vector. The initial vector is then input into the fully connected layer to be trained for recognition, obtaining the initial weights of the center nodes of the first and second initial subgraphs.
[0100] In some other possible implementations, the graph network model to be trained includes a graph convolutional network to be trained and fully connected layers to be trained.
[0101] Accordingly, the initial subgraphs are input into the graph network model to be trained for identification, resulting in the initial weights of the center nodes of the first and second initial subgraphs, including:
[0102] First, the first initial subgraph in the initial subgraph pair is input into the graph convolutional network to be trained for feature extraction to obtain the third feature vector. Then, within a preset time, the second initial subgraph in the initial subgraph pair is input into the graph convolutional network to be trained for feature extraction to obtain the fourth feature vector. The third and fourth feature vectors are concatenated to obtain the initial feature vector. The initial feature vector is then input into the fully connected layer to be trained for recognition, thereby obtaining the initial weights of the center nodes of the first and second initial subgraphs.
[0103] To improve training speed, before determining the first-order and second-order neighborhood training samples of each training sample in the training sample set, the training samples in the training sample set can be mined to find target samples with inconsistency. Target samples with inconsistency can be training sample A, training sample B, and training sample C (training sample A, training sample B, and training sample C can form a triplet, i.e., when three target training samples have a relationship with training sample A, training sample B, and training sample C, the three target training samples can form a triplet). The relationship between training sample A, training sample B, and training sample C is as follows:
[0104] Training sample A is similar to its first-order neighbor training sample B, and training sample A is similar to its first-order neighbor training sample C, but training sample B is not similar to training sample C. Alternatively, training sample A is not similar to its first-order neighbor training sample B, and training sample A is not similar to its first-order neighbor training sample C, but training sample B is similar to training sample C.
[0105] Optionally, the detailed process of mining the training samples in the training sample set to find target samples with inconsistencies can be as follows:
[0106] Feature extraction is performed on each training sample in the training sample set to obtain the feature values of each training sample. Based on the feature values of each training sample, the first-order neighborhood training samples are determined. Next, a second feature similarity is determined between the training sample and the first-order neighborhood training samples based on their feature values, and a third feature similarity is determined between the first-order neighborhood training samples based on their feature values. Training samples and first-order neighborhood training samples whose second and third feature similarities are both greater than a second threshold are used as the initial training samples.
[0107] For example, the first-order neighborhood training samples of training sample 1 include training sample 2 and training sample 3. The second feature similarity between training sample 1 and training sample 2 is greater than the second threshold. The second feature similarity between training sample 1 and training sample 3 is greater than the second threshold. Furthermore, the third feature similarity between training sample 2 and training sample 3 is greater than the second threshold. Therefore, training sample 1, training sample 2, and training sample 3 are used as the initial training samples.
[0108] If both the second and third feature similarities are greater than the second threshold, it indicates that the training samples with the second and third feature similarities, along with the first-order neighborhood training samples, are self-consistent training samples. Therefore, the training samples in the training sample set other than the initial training samples are non-consistent target training samples.
[0109] It should be noted that a trained convolutional network model can be used to extract features from each training sample in the training sample set, thereby obtaining the feature values of each training sample.
[0110] Accordingly, the first-order neighborhood training samples and the second-order neighborhood training samples of each training sample in the training sample set are determined. Using the training sample as the center node, the first-order neighborhood training samples as first-order neighborhood nodes, and the second-order neighborhood training samples as second-order neighborhood nodes, an initial subgraph is constructed, resulting in an initial subgraph set, including:
[0111] Determine the second-order neighborhood training samples of the target training sample. Then, construct an initial subgraph using the target training sample as the center node, the first-order neighborhood training samples of the target training sample as first-order neighborhood nodes, and the second-order neighborhood training samples of the target training sample as second-order neighborhood nodes, thus obtaining the initial subgraph set.
[0112] In this embodiment, instead of using all training samples in the training sample set as central nodes to construct the initial subgraph, the training samples in the training sample set are first mined to filter out redundant training samples, resulting in target samples with inconsistency. Then, only the target samples are used as central nodes to construct the initial subgraph, thereby improving the training speed of the graph network model to be trained.
[0113] In related technologies, labeled training samples are generally used to train the graph network model. However, labeling the training samples is a significant workload. To reduce this workload, in some embodiments, a subset of labeled samples and a subset of unlabeled samples can be obtained first. Then, the feature similarity between each unlabeled sample in the subset of unlabeled samples is calculated, and soft labels are assigned to each unlabeled sample based on the feature similarity, resulting in a subset of soft-labeled samples. The subset of labeled samples and the subset of soft-labeled samples are then combined to form a training sample set. Finally, the graph network model is trained using this training sample set in a semi-supervised manner.
[0114] One approach is to assign soft labels to each unlabeled sample using label smoothing. When mining the unlabeled samples to obtain the target samples, the label smoothing parameter is calculated using the following formula when assigning soft labels to each unlabeled sample using label smoothing:
[0115]
[0116] Where sim() represents similarity, T() represents label smoothing parameter, n represents the center node of the first target subgraph, l represents the center node of the second target subgraph (n and m are both target samples), and m represents other target samples in the triplet containing n and l.
[0117] Soft labels are used to represent the similarity probability between unlabeled samples. For example, if the feature similarity between the first and second unlabeled samples is higher than a first preset value, it can be determined that the first and second unlabeled samples belong to the same person, and the soft label for both samples can be assigned as 1. Alternatively, if the feature similarity between the first and second unlabeled samples is lower than a second preset value, it can be determined that the first and second unlabeled samples do not belong to the same person, and the soft label for both samples can be assigned as 0.
[0118] In this embodiment, a training sample set consisting of a subset of labeled samples and a subset of soft-labeled samples is used to train the graph network model to be trained, thereby reducing the workload of annotation. However, if the identity information corresponding to unlabeled samples in the subset of unlabeled samples overlaps with the identity information corresponding to labeled samples in the subset of labeled samples, the utilization rate of training samples will be reduced.
[0119] Therefore, in order to improve the utilization rate of training samples, the identity information corresponding to the unlabeled samples in this unlabeled sample subset does not overlap with the identity information corresponding to the labeled samples in the labeled sample subset.
[0120] It should be noted that a trained convolutional network model can be used to extract features from each unlabeled sample in the unlabeled sample subset, thus obtaining the features of each unlabeled sample. Then, the feature similarity between the unlabeled samples can be calculated based on their features.
[0121] It should be understood that when the training sample set includes a subset of labeled samples and a subset of soft-labeled samples, the initial subgraph pair is constructed based on the subset of labeled samples and the initial subgraph pair is constructed based on the subset of soft-labeled samples. That is, the samples of the first initial subgraph and the second initial subgraph included in the initial subgraph pair are both labeled samples, or the samples of the first initial subgraph and the second initial subgraph included in the initial subgraph pair are both soft-labeled samples.
[0122] Although the identity information corresponding to unlabeled samples and labeled samples does not overlap, there are still some false positive samples, meaning that unlabeled samples and labeled samples may appear similar. Therefore, in order to improve the recognition accuracy of the trained graph network model, false positive samples are input into the graph network model to be trained during training.
[0123] Optionally, the detailed process of inputting false positive samples into the graph network model to be trained can be as follows:
[0124] Calculate the first feature similarity between labeled samples in the labeled sample set and unlabeled samples in the unlabeled sample set. If the similarity is greater than a first threshold, it indicates that the target labeled sample and the target unlabeled sample are similar. Then, the labeled sample and the target unlabeled sample are used as the two center nodes in the initial sub-graph pair of false positives.
[0125] That is, the target labeled sample with a first feature similarity greater than the first threshold is used as the center node, the first-order neighbor labeled sample of the target labeled sample is used as the first-order neighbor node of the third initial subgraph, and the second-order neighbor labeled sample of the target labeled sample is used as the second-order neighbor node of the third initial subgraph to construct the third initial subgraph.
[0126] The fourth initial subgraph is constructed by taking the target unlabeled sample whose first feature similarity is greater than the first threshold as the center node, taking the first-order neighbor unlabeled sample of the target unlabeled sample as the first-order neighbor node of the fourth initial subgraph, and taking the second-order neighbor unlabeled sample of the target unlabeled sample as the second-order neighbor node of the fourth initial subgraph.
[0127] Then, a pair of false positive initial subgraphs is constructed based on the third and fourth initial subgraphs. Finally, the graph network model to be trained is trained based on the pair of false positive initial subgraphs.
[0128] As described above, in this embodiment, a set of images to be clustered is first obtained, and the first-order neighboring images and second-order neighboring images of each image in the set are determined. Then, a target subgraph set is constructed based on these first-order and second-order neighboring images. Next, target subgraph pairs are selected from the target subgraph set. Each target subgraph pair includes a first target subgraph and a second target subgraph, where the center node of the second target subgraph is a first-order neighboring node of the center node of the first target subgraph. Predictive analysis is then performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs. Finally, the images to be clustered are clustered according to these target weights.
[0129] Since the center node of the second target subgraph is a first-order neighbor of the center node of the first target subgraph, the target weight between the center nodes of the first and second target subgraphs is equivalent to the target weight between the center node of the first target subgraph and its first-order neighbor. Because the target subgraph pair includes both the first and second target subgraphs, and both include second-order neighbor nodes, when predicting the target weight between the center node of the first target subgraph and its first-order neighbor through the target subgraph pair, the information of the second-order neighbor nodes in both the first and second target subgraphs can be referenced simultaneously. This allows for a more accurate determination of the target weight between the center node of the first target subgraph and its first-order neighbor, leading to more accurate clustering results for the images to be clustered based on the target weight.
[0130] Based on the methods described in the above embodiments, the following examples will provide further detailed explanations.
[0131] This embodiment uses an image clustering device integrated into a terminal as an example. The image clustering method can include methods for applying a trained graph network model and methods for training the trained graph network model. Specifically, Figure 9This is a flowchart illustrating the training method for a trained graph network model. Figure 10 This is a flowchart illustrating the application method of a trained graph network model.
[0132] Reference Figure 9 Training methods for trained graph network models include:
[0133] S901, The terminal collects a subset of labeled face images and a subset of unlabeled face images. The identity information corresponding to the unlabeled face images in the subset of unlabeled face images does not overlap with the identity information corresponding to the labeled face images in the subset of labeled face images.
[0134] In related technologies, labeled face images are typically used to train the graph network model. However, labeling face images is a significant undertaking. To reduce this workload, both labeled and unlabeled subsets of face images are used to train the graph network model.
[0135] Furthermore, if the identity information corresponding to unlabeled face images overlaps with the identity information corresponding to labeled face images, the utilization rate of unlabeled face images will be reduced. Therefore, in order to improve the utilization rate of unlabeled face images, the identity information corresponding to unlabeled face images in this subset of unlabeled face images should not overlap with the identity information corresponding to labeled face images in the subset of labeled face images.
[0136] S902, The terminal calculates the first feature similarity between the labeled face image and the unlabeled face image.
[0137] Although the identity information corresponding to unlabeled face images and labeled face images do not overlap, there are still some false positive face images, meaning that there may be cases where unlabeled face images and labeled face images are similar.
[0138] Therefore, after obtaining labeled and unlabeled face images, the terminal can calculate the first feature similarity between the labeled and unlabeled face images using a trained convolutional network model.
[0139] S903. The terminal constructs a third initial subgraph using a target labeled face image whose first feature similarity is greater than a first threshold as the center node, a target labeled face image whose first-order neighbor labeled face image is used as the first-order neighbor node of the third initial subgraph, and a target labeled face image whose second-order neighbor labeled face image is used as the second-order neighbor node of the third initial subgraph. The terminal also constructs a fourth initial subgraph using a target unlabeled face image whose first feature similarity is greater than a first threshold as the center node, a target unlabeled face image whose first-order neighbor unlabeled face image is used as the first-order neighbor node of the fourth initial subgraph, and a target unlabeled face image whose second-order neighbor unlabeled face image is used as the second-order neighbor node of the fourth initial subgraph.
[0140] After obtaining the first feature similarity between the labeled and unlabeled face images, if the similarity is greater than a first threshold, it indicates that the target labeled sample and the target unlabeled sample are similar. Then, the labeled sample and the target unlabeled sample are respectively used as the two center nodes in the initial sub-image pair for false positives.
[0141] S904. The terminal constructs a false positive initial subgraph pair based on the third initial subgraph and the fourth initial subgraph.
[0142] S905. The terminal extracts features from each labeled face image in the subset of labeled face images to obtain the feature values of each labeled face image, and determines the first-order neighborhood labeled face images of the labeled face images based on the feature values of each labeled face image.
[0143] Before constructing the initial sub-image pairs, we can first mine the labeled face images in the subset of labeled face images to find target labeled face images with inconsistency. The target labeled face images with inconsistency can be labeled face image A, labeled face image B, and labeled face image C. The relationship between labeled face image A, labeled face image B, and labeled face image C is as follows:
[0144] Labeled face image A is similar to labeled face image B, which is its first-order neighbor. Labeled face image A is also similar to labeled face image C, which is its first-order neighbor. However, labeled face image B is not similar to labeled face image C. Alternatively, labeled face image A is not similar to labeled face image B, which is its first-order neighbor. Labeled face image A is not similar to labeled face image C, which is its first-order neighbor. However, labeled face image B is similar to labeled face image C.
[0145] A trained convolutional network model can be used to extract features from each labeled face image, thereby obtaining the feature values of each labeled face image.
[0146] S906. The terminal determines the second feature similarity between the labeled face image and the first-order neighbor labeled face image based on the feature values of the labeled face image and the feature values of the first-order neighbor labeled face image, and determines the third feature similarity between the first-order neighbor labeled face images based on the feature values of each first-order neighbor labeled face image.
[0147] S907. The terminal takes the labeled face image with both the second feature similarity and the third feature similarity greater than the second threshold and the labeled face image in the first-order neighborhood as the initial labeled face image, and takes the labeled face images in the subset of labeled face images other than the initial labeled face image as the target labeled face image.
[0148] If both the second and third feature similarities are greater than the second threshold, it indicates that the labeled face image with the second and third feature similarities and the first-order neighborhood labeled face image are self-consistent labeled face images. Then, the labeled face images in the subset of labeled face images other than the initial labeled face image are non-self-consistent target labeled face images.
[0149] S908. The terminal determines the second-order neighboring labeled face images of the target labeled face image, and constructs an initial subgraph using the target labeled face image as the center node, the first-order neighboring labeled face images of the target labeled face image as the first-order neighboring nodes, and the second-order neighboring labeled face images of the target labeled face image as the second-order neighboring nodes, thus obtaining an initial subgraph set.
[0150] S909. The terminal selects an initial subgraph pair from the initial subgraph set. The initial subgraph pair includes a first initial subgraph and a second initial subgraph. The center node of the second initial subgraph is the first-order neighbor node of the center node of the first initial subgraph.
[0151] S9010. The terminal extracts features from each unlabeled face image in the subset of unlabeled face images to obtain the feature values of each unlabeled face image, and determines the first-order neighborhood unlabeled face images of the unlabeled face images based on the feature values of each unlabeled face image.
[0152] Before constructing the initial sub-image pairs, we can first mine the unlabeled face images in the subset of unlabeled face images to find target unlabeled face images with inconsistency. The target unlabeled face images with inconsistency can be unlabeled face image A, unlabeled face image B, and unlabeled face image C. The relationship between unlabeled face image A, unlabeled face image B, and unlabeled face image C is as follows:
[0153] Unlabeled face image A is similar to its first-order neighbor unlabeled face image B, and unlabeled face image A is similar to its first-order neighbor unlabeled face image C, but unlabeled face images B and C are not similar. Alternatively, unlabeled face image A is not similar to its first-order neighbor unlabeled face image B, and unlabeled face image A is not similar to its first-order neighbor unlabeled face image C, but unlabeled face images B and C are similar.
[0154] A trained convolutional network model can be used to extract features from each unlabeled face image, thereby obtaining the feature values of each unlabeled face image.
[0155] S9011, The terminal determines the second feature similarity between the unlabeled face image and the first-order neighbor unlabeled face image based on the feature values of the unlabeled face image and the feature values of the first-order neighbor unlabeled face image, and determines the third feature similarity between each first-order neighbor unlabeled face image based on the feature values of each first-order neighbor unlabeled face image.
[0156] S9012, The terminal takes the unlabeled face image with the second feature similarity and the third feature similarity both greater than the second threshold and the unlabeled face image in the first-order neighborhood as the initial unlabeled face image, and takes the unlabeled face images in the subset of unlabeled face images other than the initial unlabeled face image as the target unlabeled face image.
[0157] If both the second and third feature similarities are greater than the second threshold, it indicates that the unlabeled face image with the second and third feature similarities, along with the unlabeled face image in the first-order neighborhood, are self-consistent unlabeled face images. Then, the unlabeled face images in the subset of unlabeled face images other than the initial unlabeled face image are non-consistent target unlabeled face images.
[0158] S9013. The terminal determines the second-order neighborhood unlabeled face images of the target unlabeled face image, and constructs an initial subgraph using the target unlabeled face image as the center node, the first-order neighborhood unlabeled face images of the target unlabeled face image as the first-order neighborhood nodes, and the second-order neighborhood unlabeled face images of the target unlabeled face image as the second-order neighborhood nodes, thus obtaining an initial subgraph set.
[0159] S9014. The terminal selects an initial subgraph pair from the initial subgraph set. The initial subgraph pair includes a first initial subgraph and a second initial subgraph. The center node of the second initial subgraph is the first-order neighbor node of the center node of the first initial subgraph.
[0160] S9015, The terminal assigns soft labels to the center nodes of the first and second initial subgraphs in the initial subgraph pair.
[0161] S9016. The terminal inputs the initial subgraph pair and the false positive initial subgraph pair into the graph network model to be trained for training, and obtains the trained graph network model.
[0162] The graph network model to be trained includes a first graph convolutional network to be trained, a second graph convolutional network to be trained, and a fully connected layer to be trained.
[0163] The detailed process by which the terminal inputs the initial subgraph pairs and false positive initial subgraph pairs into the graph network model to be trained can be described as follows:
[0164] The first initial subgraph (third initial subgraph) in the initial subgraph pair (false positive initial subgraph pair) is input into the first graph convolutional network to be trained for feature extraction, resulting in a 256-dimensional floating-point type first vector;
[0165] The second initial subgraph (fourth initial subgraph) from the initial subgraph pair (false positive initial subgraph pair) is input into the second graph convolutional network to be trained for feature extraction, resulting in a 256-dimensional floating-point type second vector;
[0166] By concatenating the first 256-dimensional floating-point vector and the second 256-dimensional floating-point vector, a 512-dimensional vector is obtained.
[0167] The 512-dimensional vector is input into the fully connected layer to be trained for recognition, and the initial weights of the center nodes of the first initial subgraph (third initial subgraph) and the second initial subgraph (fourth initial subgraph) are obtained.
[0168] The target loss value is determined based on the initial weights and labels, and the number of training iterations is recorded. If the target loss value is less than or equal to the threshold and the number of training iterations is equal to the preset number, training stops, and a trained graph network model is obtained. If the target loss value is greater than the threshold or the number of training iterations is less than the preset number, the network parameters of the graph network model to be trained are updated according to the target loss value, and the process returns to inputting the first initial subgraph from the initial subgraph pair into the first graph convolutional network to be trained for feature extraction.
[0169] In this embodiment, the graph network model to be trained is trained using subsets of labeled and unlabeled face images, thereby reducing the workload of labeling unlabeled face images. Furthermore, the identity information corresponding to labeled and unlabeled face images does not overlap, which improves the utilization rate of the unlabeled face image subset.
[0170] Furthermore, by mining subsets of labeled and unlabeled face images, target labeled and unlabeled face images with inconsistency are identified. Then, only initial sub-graph sets centered on target labeled face images and unlabeled face images are constructed, thereby improving the training speed of the graph network model to be trained.
[0171] Reference Figure 10 Applications of trained graph network models include:
[0172] S1001. The terminal collects a set of face images to be clustered and determines the first-order neighborhood face images and the second-order neighborhood face images of each face image in the set.
[0173] The set of face images to be clustered includes multiple face images, which can be a set of face images of customers in a store. The first-order neighborhood face images of each face image to be clustered refer to the k1 nearest neighbor face images of each face image to be clustered. The value of k1 can be set according to the actual situation, and this application does not limit it.
[0174] For example, such as Figure 5 As shown, when k1 is 3, the three nearest neighbor face images to be clustered for face image n0 are face image n1, face image n7, and face image n8, respectively. Then, the first-order neighborhood face images to be clustered for face image n0 are face image n1, face image n7, and face image n8, respectively.
[0175] The second-order neighborhood of the face image to be clustered refers to the k2 nearest neighbor face images of the first-order neighborhood of the face image to be clustered. For example, such as Figure 5 As shown, when k1 is 3 and k2 is 2, the first-order neighborhood face images to be clustered for the face image n0 are face images n1, n7, and n8, respectively. The first-order neighborhood face images to be clustered for the face image n1 are face images n2 and n3, respectively. The first-order neighborhood face images to be clustered for the face image n7 are face images n9 and n8, respectively. 10 The first-order neighborhood of the face image n8 to be clustered is the face image n to be clustered. 11 and n face images to be clustered 12 Then, the second-order neighborhood face images to be clustered for the face image n0 are face image n2, face image n3, face image n9, and face image n1, respectively. 10 n face images to be clustered 11 and n face images to be clustered 12 .
[0176] The terminal can determine the first-order and second-order neighborhood face images of each face image in the set of face images to be clustered by using a trained convolutional network model.
[0177] S1002. The terminal constructs a target subgraph set based on the face images to be clustered in the first-order neighborhood and the face images to be clustered in the second-order neighborhood.
[0178] After obtaining the first-order neighborhood and second-order neighborhood face images to be clustered, the terminal constructs a target subgraph by using the face image to be clustered as the center node, the first-order neighborhood face images of the face image to be clustered as the first-order neighborhood nodes of the target subgraph, and the second-order neighborhood face images of the face image to be clustered as the second-order neighborhood nodes of the target subgraph. Since each face image to be clustered corresponds to one target subgraph, multiple target subgraphs can be obtained, and these multiple target subgraphs form a target subgraph set.
[0179] S1003. The terminal selects a target subgraph pair from the target subgraph set. The target subgraph pair includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0180] After obtaining the target subgraph set, the terminal selects a target subgraph pair from the target subgraph set. The target subgraph pair includes a first target subgraph and a second target subgraph, and the center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0181] For example, the target subgraph is as follows Figure 3 As shown, the center node n1 of the second target subgraph is the first neighbor node n1 of the center node n0 of the first target subgraph.
[0182] When the first-order neighbor nodes of the central node of the first target subgraph include multiple nodes, then multiple pairs of target subgraphs can be selected from the set of target subgraphs for the first target subgraph. For example, the first target subgraph is as follows: Figure 3 As shown, the first-order neighbor nodes of the center node n0 of the first target subgraph include three nodes: n1, n7, and n8. Therefore, for the first target subgraph, three target subgraph pairs can be selected from the target subgraph set. These three target subgraph pairs are target subgraph pair 1, target subgraph pair 2, and target subgraph pair 3. Target subgraph pair 1 includes the first target subgraph and the second target subgraph with center node n1; target subgraph pair 2 includes the first target subgraph and the second target subgraph with center node n7; and target subgraph pair 3 includes the first target subgraph and the second target subgraph with center node n8.
[0183] S1004. The terminal inputs the target subgraph pair into the trained graph network model for prediction analysis to obtain the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph.
[0184] Since the center node of the second target subgraph is the first neighbor node of the center node of the first target subgraph, the target weight between the center node of the first target subgraph and the center node of the second target subgraph is equivalent to the target weight between the center node of the first target subgraph and the first neighbor node of the center node of the first target subgraph.
[0185] When the first-order neighboring nodes of the central node of the first target subgraph include multiple nodes, the target weights between the central node of the first target subgraph and each first-order neighboring node can be obtained after performing predictive analysis on multiple target subgraph pairs related to the first target subgraph.
[0186] For example, such as Figure 3As shown, regarding the first target subgraph, three target subgraph pairs can be selected from the target subgraph set. After performing predictive analysis on the three target subgraph pairs, the target weights between the central node n0 of the first target subgraph and the first-order neighbor node n1, the target weights between the central node n0 and the first-order neighbor node n7, and the target weights between the central node n0 and the first-order neighbor node n8 can be obtained.
[0187] In this embodiment, since the target subgraph pair includes a first target subgraph and a second target subgraph, and both the first and second target subgraphs include second-order neighbor nodes, when predicting and analyzing the target weight between the center node of the first target subgraph and the first-order neighbor nodes of the center node of the first target subgraph through the target subgraph pair, the information of the second-order neighbor nodes in the first target subgraph and the second target subgraph can be referenced simultaneously, thereby enabling a more accurate determination of the target weight between the center node of the first target subgraph and the first-order neighbor nodes of the center node of the first target subgraph.
[0188] Optionally, the detailed process of inputting the target subgraph pair into the trained graph network model for predictive analysis can be as follows:
[0189] The terminal inputs the first target sub-image from the target sub-image pair into a pre-trained first-graph convolutional network for feature extraction, obtaining a first feature vector. It then inputs the second target sub-image from the target sub-image pair into a pre-trained second-graph convolutional network for feature extraction, obtaining a second feature vector. The terminal then concatenates the first and second feature vectors to obtain the target vector. Finally, the terminal inputs the target vector into a pre-trained fully connected layer to obtain the target weights of the center nodes of the first and second target sub-images.
[0190] S1005. The terminal constructs an initial adjacency matrix based on the target weight.
[0191] S1006. If the first-order neighboring node of the center node of the first target subgraph and the first-order neighboring node of the center node of the second target subgraph have the same node, the terminal calculates the target confidence based on the first target weight of the first target subgraph and the second target weight of the second target subgraph.
[0192] When there are some false positive or false negative face images to be clustered, the false positive face image (or false negative face image) may be the first-order neighbor node of the center node of the first target subgraph and the first-order neighbor node of the center node of the second target subgraph at the same time. That is, at this time, the first-order neighbor node of the center node of the first target subgraph and the first-order neighbor node of the center node of the second target subgraph have the same node.
[0193] For example, such as Figure 8 As shown, the first-order neighbor nodes of the center node n0 in the first target subgraph include the first-order neighbor node n9 and the first-order neighbor node n. 10 The first-order neighbor nodes of the center node n1 in the second target subgraph also include the first-order neighbor nodes n9 and n1. 10 Then, the first-order neighbor nodes of the center node n0 of the first target subgraph and the second-order neighbor nodes of the center node n1 of the second target have the same nodes n9 and n1. 10 .
[0194] The presence of false positive or false negative face images to be clustered reduces the accuracy of the clustering results. Therefore, to further improve the accuracy of the clustering results, this embodiment, after obtaining the weights of each target, calculates the target confidence based on the first target weight of the first target subgraph and the second target weight of the second target subgraph if the first-order neighboring nodes of the center node of the first target subgraph and the first-order neighboring nodes of the center node of the second target subgraph are identical.
[0195] The first target weight of the first target subgraph refers to the target weight between the center node of the first target subgraph and each of the first-order neighboring nodes of the center node of the first target subgraph. The second target weight of the second target subgraph refers to the target weight between the center node of the second target subgraph and each of the first-order neighboring nodes of the center node of the second target subgraph.
[0196] S1007. The terminal updates the initial adjacency matrix according to the target confidence level to obtain the target adjacency matrix, and then clusters the face images to be clustered according to the target adjacency matrix.
[0197] The process of updating the initial adjacency matrix based on the target confidence can be as follows: if the target confidence is higher than a preset threshold, the target weight between the center node of the first target subgraph and the center node of the second target subgraph in the initial adjacency matrix is updated to 1; otherwise, it is updated to 0.
[0198] After obtaining the target adjacency matrix, the Disjoint Set Union (DSU) algorithm is used to partition the elements in the target adjacency matrix, thereby obtaining the clustering results of the face images to be clustered.
[0199] After obtaining the clustering results of the face images to be clustered, information such as the number of customers visiting the store and the patterns of customer visits can be determined based on the clustering results, thereby providing a reference for the store's operational decisions.
[0200] In this embodiment, after obtaining the target weights between the center nodes of the first target subgraph and the second target subgraph, if the first-order neighbor nodes of the center node of the first target subgraph and the first-order neighbor nodes of the center node of the second target subgraph are the same, the target weights between the center nodes of the first target subgraph and the second target subgraph are updated, thereby reducing the impact of false positive or false negative face images to be clustered and improving the accuracy of the clustering results.
[0201] In this embodiment, a set of face images to be clustered is first obtained, and the first-order and second-order neighboring face images to be clustered for each face image in the set are determined. Then, a target subgraph set is constructed based on the first-order and second-order neighboring face images. Next, target subgraph pairs are selected from the target subgraph set, including a first target subgraph and a second target subgraph, where the center node of the second target subgraph is the first-order neighbor node of the first target subgraph. Predictive analysis is then performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs. Finally, the face images to be clustered are clustered according to the target weights.
[0202] Since the center node of the second target subgraph is a first-order neighbor node of the center node of the first target subgraph, the target weight between the center nodes of the first and second target subgraphs is equivalent to the target weight between the center node of the first target subgraph and its first-order neighbor node. Because the target subgraph pair includes both the first and second target subgraphs, and both include second-order neighbor nodes, when predicting the target weight between the center node of the first target subgraph and its first-order neighbor node using the target subgraph pair, the information of the second-order neighbor nodes in both the first and second target subgraphs can be referenced simultaneously. This allows for a more accurate determination of the target weight between the center node of the first target subgraph and its first-order neighbor node, leading to more accurate clustering results for the face images to be clustered based on the target weight.
[0203] To facilitate better implementation of the image clustering method provided in this application, this application also provides an apparatus based on the above-described image clustering method. The meanings of the terms used are the same as in the image clustering method described above, and specific implementation details can be found in the descriptions within the method embodiments.
[0204] For example, such as Figure 11 As shown, the image clustering device may include:
[0205] The determination module 1101 is used to obtain the set of images to be clustered and determine the first-order neighborhood images and the second-order neighborhood images of each image to be clustered in the set of images to be clustered.
[0206] Module 1102 is used to construct a set of target subgraphs based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered.
[0207] The selection module 1103 is used to select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0208] Analysis module 1104 is used to perform predictive analysis on the target subgraph pair to obtain the target weight between the center node of the first target subgraph and the center node of the second target subgraph.
[0209] Clustering module 1105 clusters the images to be clustered according to the target weights.
[0210] Optionally, the analysis module 1104 is specifically used to perform:
[0211] The target subgraph is input into the trained graph network model for prediction analysis to obtain the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph.
[0212] Optionally, clustering module 1105 is specifically used to perform:
[0213] Construct an initial adjacency matrix based on the target weights;
[0214] If the first-order neighboring node of the center node of the first target subgraph and the first-order neighboring node of the center node of the second target subgraph have the same node, then the target confidence is calculated based on the first target weight of the first target subgraph and the second target weight of the second target subgraph.
[0215] The initial adjacency matrix is updated based on the target confidence level to obtain the target adjacency matrix;
[0216] Cluster the image to be clustered based on the target adjacency matrix.
[0217] Optionally, the image clustering apparatus may further include:
[0218] The training module is used for:
[0219] Obtain the training sample set, and determine the first-order neighborhood training samples and the second-order neighborhood training samples of each training sample in the training sample set.
[0220] Using training samples as the center node, first-order neighborhood training samples as first-order neighborhood nodes, and second-order neighborhood training samples as second-order neighborhood nodes, an initial subgraph is constructed to obtain an initial subgraph set.
[0221] Select an initial subgraph pair from the initial subgraph set. The initial subgraph pair includes a first initial subgraph and a second initial subgraph. The center node of the second initial subgraph is the first-order neighbor node of the center node of the first initial subgraph.
[0222] The initial subgraph is input into the graph network model to be trained for identification, and the initial weights between the center nodes of the first and second initial subgraphs are obtained.
[0223] The graph network model to be trained is trained based on the initial weights and the labels corresponding to the training samples, resulting in a trained graph network model.
[0224] Optionally, the graph network model to be trained includes a first graph convolutional network to be trained, a second graph convolutional network to be trained, and a fully connected layer to be trained.
[0225] Accordingly, the training module is specifically used to perform:
[0226] The first initial subgraph in the initial subgraph pair is input into the first graph convolutional network to be trained for feature extraction, resulting in the third feature vector.
[0227] The second initial subgraph in the initial subgraph pair is input into the second graph convolutional network to be trained for feature extraction, resulting in the fourth feature vector.
[0228] The third and fourth eigenvectors are concatenated to obtain the initial eigenvector;
[0229] The initial feature vector is input into the fully connected layer to be trained for recognition, and the initial weights of the center nodes of the first and second initial subgraphs are obtained.
[0230] Optionally, the training module is specifically used to perform:
[0231] Obtain a subset of labeled samples and a subset of unlabeled samples. The identity information corresponding to the unlabeled samples in the subset of unlabeled samples does not overlap with the identity information corresponding to the labeled samples in the subset of labeled samples.
[0232] Calculate the feature similarity between each unlabeled sample;
[0233] Soft labels are assigned to each unlabeled sample based on the feature similarity between the unlabeled samples, resulting in a subset of soft-labeled samples.
[0234] The training sample set is composed of a subset of labeled samples and a subset of soft-labeled samples.
[0235] Optionally, the training module is specifically used to perform:
[0236] Calculate the first feature similarity between labeled samples in the labeled sample set and unlabeled samples in the unlabeled sample set;
[0237] The target labeled sample with a first feature similarity greater than the first threshold is used as the center node of the third initial subgraph, the first-order neighbor labeled sample of the target labeled sample is used as the first-order neighbor node of the third initial subgraph, and the second-order neighbor labeled sample of the target labeled sample is used as the second-order neighbor node of the third initial subgraph to construct the third initial subgraph.
[0238] The fourth initial subgraph is constructed by taking the target unlabeled sample with a first feature similarity greater than the first threshold as the center node of the fourth initial subgraph, taking the first-order neighbor unlabeled sample of the target unlabeled sample as the first-order neighbor node of the fourth initial subgraph, and taking the second-order neighbor unlabeled sample of the target unlabeled sample as the second-order neighbor node of the fourth initial subgraph.
[0239] Construct false positive initial subgraph pairs based on the third and fourth initial subgraphs;
[0240] The graph network model to be trained is trained based on the false positive initial subgraph.
[0241] Optionally, the training module is specifically used to perform:
[0242] Feature extraction is performed on each training sample in the training sample set to obtain the feature values of each training sample.
[0243] The first-order neighborhood training samples of each training sample are determined based on the feature values of each training sample.
[0244] The second feature similarity between the training sample and the first-order neighbor training sample is determined based on the feature value of the training sample and the feature value of the first-order neighbor training sample, and the third feature similarity between each first-order neighbor training sample is determined based on the feature value of each first-order neighbor training sample.
[0245] The training samples with similarity to both the second and third features greater than the second threshold, along with the first-order neighborhood training samples, are used as the initial training samples.
[0246] Use the training samples in the training sample set other than the initial training samples as the target training samples;
[0247] Determine the second-order neighborhood training samples of the target training samples;
[0248] An initial subgraph is constructed using the target training sample as the center node, the first-order neighbor training samples of the target training sample as the first-order neighbor nodes, and the second-order neighbor training samples of the target training sample as the second-order neighbor nodes, thus obtaining the initial subgraph set.
[0249] In practice, the above modules can be implemented as independent entities or combined arbitrarily as the same or several entities. The specific implementation of the above modules and their corresponding beneficial effects can be found in the previous method implementation examples, which will not be repeated here.
[0250] This application also provides an electronic device, which may be a server or a terminal, etc. Figure 12 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically:
[0251] The electronic device may include components such as a processor 1201 with one or more processing cores, a memory 1202 with one or more computer-readable storage media, a power supply 1203, and an input unit 1204. Those skilled in the art will understand that... Figure 12 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0252] The processor 1201 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing computer programs and / or modules stored in the memory 1202, and by calling data stored in the memory 1202, it performs various functions and processes data, thereby performing overall detection of the electronic device. Optionally, the processor 1201 may include one or more processing cores; preferably, the processor 1201 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 1201.
[0253] The memory 1202 can be used to store computer programs and modules. The processor 1201 executes various functional applications and data processing by running the computer programs and modules stored in the memory 1202. The memory 1202 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, computer programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 1202 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 1202 may also include a memory controller to provide the processor 1201 with access to the memory 1202.
[0254] The electronic device also includes a power supply 1203 that supplies power to various components. Preferably, the power supply 1203 can be logically connected to the processor 1201 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 1203 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0255] The electronic device may also include an input unit 1204, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0256] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 1201 in the electronic device loads the executable files corresponding to the processes of one or more computer programs into the memory 1202 according to the following instructions, and the processor 1201 runs the computer programs stored in the memory 1202 to realize various functions, such as:
[0257] Obtain the set of images to be clustered, and determine the first-order neighborhood images and the second-order neighborhood images of each image in the set.
[0258] Based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered, construct a set of target subgraphs;
[0259] Select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0260] Predictive analysis is performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs.
[0261] Cluster the images to be clustered according to the target weights.
[0262] The specific implementation of each of the above operations and their corresponding beneficial effects can be found in the previous embodiments, and will not be repeated here.
[0263] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by a computer program, or by a computer program controlling related hardware. The computer program can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0264] Therefore, embodiments of this application provide a computer-readable storage medium storing a computer program that can be loaded by a processor to execute any of the image clustering methods provided in embodiments of this application. For example, the computer program can perform the following steps:
[0265] Obtain the set of images to be clustered, and determine the first-order neighborhood images and the second-order neighborhood images of each image in the set.
[0266] Based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered, construct a set of target subgraphs;
[0267] Select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph.
[0268] Predictive analysis is performed on the target subgraph pairs to obtain the target weights between the center nodes of the first and second target subgraphs.
[0269] Cluster the images to be clustered according to the target weights.
[0270] The specific implementation of each of the above operations and their corresponding beneficial effects can be found in the previous embodiments, and will not be repeated here.
[0271] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0272] Since the computer program stored in the computer-readable storage medium can execute the steps in any of the information classification methods provided in the embodiments of this application, the beneficial effects that any of the information classification methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0273] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned image clustering method.
[0274] The above provides a detailed description of an image clustering method, apparatus, and electronic device provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. An image clustering method, characterized in that, include: Obtain a set of images to be clustered, and determine the first-order neighboring images and the second-order neighboring images for each image in the set; wherein, the first-order neighboring images refer to the k1 nearest neighboring images of each image to be clustered; and the second-order neighboring images refer to the k2 nearest neighboring images of the first-order neighboring images of the image to be clustered. Based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered, a target sub-graph set is constructed; Target subgraph pairs are selected from the target subgraph set. The target subgraph pairs include a first target subgraph and a second target subgraph. The center node of the second target subgraph is the first-order neighbor node of the center node of the first target subgraph. The first-order neighbor node refers to the first-order neighbor image of the image to be clustered as the first-order neighbor node of the target subgraph. The target subgraph is input into a trained graph network model for prediction analysis to obtain the target weights between the center nodes of the first target subgraph and the center nodes of the second target subgraph. Cluster the images to be clustered according to the target weights; The trained graph network model is obtained in the following manner: A training sample set is obtained, and the first-order neighbor training samples and the second-order neighbor training samples of each training sample in the training sample set are determined. An initial subgraph is constructed using the training samples as center nodes, the first-order neighbor training samples as first-order neighbor nodes, and the second-order neighbor training samples as second-order neighbor nodes, resulting in an initial subgraph set. An initial subgraph pair is selected from the initial subgraph set, comprising a first initial subgraph and a second initial subgraph, where the center node of the second initial subgraph is a first-order neighbor node of the center node of the first initial subgraph. The initial subgraph pair is input into the graph network model to be trained for identification, obtaining the initial weights between the center nodes of the first and second initial subgraphs. The graph network model to be trained is trained according to the initial weights and the labels corresponding to the training samples, resulting in the trained graph network model.
2. The image clustering method according to claim 1, characterized in that, The step of clustering the images to be clustered according to the target weights includes: Construct an initial adjacency matrix based on the target weights; If the first-order neighboring node of the center node of the first target subgraph and the first-order neighboring node of the center node of the second target subgraph have the same node, then the target confidence is calculated based on the first target weight of the first target subgraph and the second target weight of the second target subgraph. The initial adjacency matrix is updated based on the target confidence level to obtain the target adjacency matrix; Cluster the image to be clustered based on the target adjacency matrix.
3. The image clustering method according to claim 1, characterized in that, The graph network model to be trained includes a first graph convolutional network to be trained, a second graph convolutional network to be trained, and a fully connected layer to be trained. Accordingly, the step of inputting the initial subgraph into the graph network model to be trained for identification, and obtaining the initial weights of the center nodes of the first initial subgraph and the second initial subgraph, includes: The first initial subgraph in the initial subgraph pair is input into the first graph convolutional network to be trained for feature extraction to obtain the third feature vector. The second initial subgraph in the initial subgraph pair is input into the second graph convolutional network to be trained for feature extraction to obtain the fourth feature vector; The third feature vector and the fourth feature vector are concatenated to obtain the initial feature vector; The initial feature vector is input into the fully connected layer to be trained for recognition, thereby obtaining the initial weights of the center nodes of the first initial subgraph and the second initial subgraph.
4. The image clustering method according to claim 1, characterized in that, The acquisition of the training sample set includes: Obtain a subset of labeled samples and a subset of unlabeled samples, wherein the identity information corresponding to the unlabeled samples in the subset of unlabeled samples does not overlap with the identity information corresponding to the labeled samples in the subset of labeled samples; Calculate the feature similarity between each of the unlabeled samples; Based on the feature similarity between the unlabeled samples, soft labels are assigned to each unlabeled sample to obtain a subset of soft-labeled samples. The labeled sample subset and the soft-labeled sample subset are combined to form the training sample set.
5. The image clustering method according to claim 4, characterized in that, After obtaining the labeled sample subset and the unlabeled sample subset, the method further includes: Calculate the first feature similarity between the labeled samples in the labeled sample subset and the unlabeled samples in the unlabeled sample subset; The target labeled sample with a first feature similarity greater than a first threshold is used as the center node of the third initial subgraph, the first-order neighbor labeled sample of the target labeled sample is used as the first-order neighbor node of the third initial subgraph, and the second-order neighbor labeled sample of the target labeled sample is used as the second-order neighbor node of the third initial subgraph to construct the third initial subgraph. The fourth initial subgraph is constructed by taking the target unlabeled sample with a first feature similarity greater than a first threshold as the center node of the fourth initial subgraph, taking the first-order neighbor unlabeled sample of the target unlabeled sample as the first-order neighbor node of the fourth initial subgraph, and taking the second-order neighbor unlabeled sample of the target unlabeled sample as the second-order neighbor node of the fourth initial subgraph. Construct a false positive initial subgraph pair based on the third initial subgraph and the fourth initial subgraph; The graph network model to be trained is trained based on the false positive initial subgraph.
6. The image clustering method according to any one of claims 1-5, characterized in that, Before determining the first-order neighborhood training samples and the second-order neighborhood training samples of each training sample in the training sample set, the method further includes: Feature extraction is performed on each training sample in the training sample set to obtain the feature values of each training sample. The first-order neighborhood training samples of each training sample are determined based on the feature values of each training sample. A second feature similarity between the training sample and the first-order neighbor training sample is determined based on the feature value of the training sample and the feature value of the first-order neighbor training sample, and a third feature similarity between each first-order neighbor training sample is determined based on the feature value of each first-order neighbor training sample. The training samples whose second feature similarity and the third feature similarity are both greater than the second threshold, and the first-order neighborhood training samples are used as the initial training samples; Use the training samples in the training sample set other than the initial training samples as the target training samples; Accordingly, the first-order neighborhood training samples and the second-order neighborhood training samples of each training sample in the training sample set are determined. Using the training samples as the center node, the first-order neighborhood training samples as first-order neighborhood nodes, and the second-order neighborhood training samples as second-order neighborhood nodes, an initial subgraph is constructed to obtain an initial subgraph set, including: Determine the second-order neighborhood training samples of the target training sample; An initial subgraph is constructed using the target training sample as the center node, the first-order neighbor training samples of the target training sample as the first-order neighbor nodes, and the second-order neighbor training samples of the target training sample as the second-order neighbor nodes, thus obtaining an initial subgraph set.
7. An image clustering device, characterized in that, include: A determination module is used to acquire a set of images to be clustered, and to determine the first-order neighboring images and the second-order neighboring images of each image to be clustered in the set of images to be clustered; wherein, the first-order neighboring images refer to the k1 nearest neighboring images of each image to be clustered; and the second-order neighboring images refer to the k2 nearest neighboring images of the first-order neighboring images of the image to be clustered. The construction module is used to construct a target subgraph set based on the first-order neighborhood images to be clustered and the second-order neighborhood images to be clustered. The selection module is used to select a pair of target subgraphs from the set of target subgraphs. The pair of target subgraphs includes a first target subgraph and a second target subgraph. The center node of the second target subgraph is a first-order neighbor node of the center node of the first target subgraph. The first-order neighbor node refers to the first-order neighbor image of the image to be clustered as the first-order neighbor node of the target subgraph. An analysis module is used to input the target subgraph pairs into a trained graph network model for prediction analysis, obtaining the target weights between the center nodes of the first target subgraph and the second target subgraph. The trained graph network model is obtained as follows: a training sample set is acquired, and the first-order and second-order neighborhood training samples of each training sample in the training sample set are determined; initial subgraphs are constructed using the training samples as center nodes, the first-order neighborhood training samples as first-order neighborhood nodes, and the second-order neighborhood training samples as second-order neighborhood nodes, resulting in an initial subgraph set; initial subgraph pairs are selected from the initial subgraph set, the initial subgraph pairs including a first initial subgraph and a second initial subgraph, where the center node of the second initial subgraph is the first-order neighborhood node of the center node of the first initial subgraph; the initial subgraph pairs are input into the graph network model to be trained for identification, obtaining the initial weights between the center nodes of the first and second initial subgraphs; the graph network model to be trained is trained according to the initial weights and the labels corresponding to the training samples, resulting in the trained graph network model. The clustering module clusters the images to be clustered according to the target weights.
8. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a computer program, and the processor running the computer program in the memory to perform the image clustering method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program adapted for loading by a processor to perform the image clustering method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the image clustering method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Location determination using street view images
US20200020129A1
KR20210102039A