Feature clustering method based on KNN neighborhood IOU enhancement
The feature clustering method enhanced by KNN neighborhood IOU uses cosine distance and IOU ratio to determine node connections, which solves the problem of poor clustering performance when feature similarity is not obvious, and improves clustering accuracy and recall.
Patent Information
- Application Number
- CN202511702075.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-02-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing clustering algorithms perform poorly when the original feature similarity is not sufficiently discriminative, especially in low lighting or occlusion conditions, making it difficult to effectively distinguish between images of the same category and those of different categories.
We employ a feature clustering method based on KNN neighborhood IOU enhancement. By calculating the cosine distance and KNN relationship of data features and combining the IOU ratio, we determine the node connection. We then use the disjoint-set data structure algorithm to construct a graph, correct the node connection method, and improve the clustering accuracy and recall.
When feature similarity is not obvious, it effectively improves the accuracy and recall of clustering algorithms, ensuring that images of the same type are correctly classified into their own categories.
Smart Images

Figure CN121456532A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of face or human body clustering methods, specifically a feature clustering method based on KNN neighborhood IOU enhancement. Background Technology
[0002] Clustering has been widely applied in various fields such as medicine, engineering, biology, linguistics, and psychology. Generally, clustering algorithms are divided into traditional clustering algorithms and deep learning-based clustering algorithms. Traditional clustering algorithms include partition-based clustering, density-based clustering, model-based clustering, spectral clustering, affinity-propagation-based clustering, hierarchical clustering, etc. These algorithms have drawbacks such as sensitivity to initial values, sensitivity to noise, difficulty in handling high-dimensional data, and some require manual parameter selection. Deep learning-based clustering algorithms, on the other hand, are relatively new. They utilize the nonlinear mapping and feature extraction capabilities of neural networks to automatically learn the intrinsic representation of data in an end-to-end manner. These algorithms include autoencoder clustering, variational autoencoder clustering, and graph embedding clustering. Compared to traditional algorithms, they typically offer better performance and greater flexibility, but require more computational resources and more data to train the model.
[0003] Both traditional clustering algorithms and deep learning-based clustering algorithms require clustering based on the similarity or distance between data points. These algorithms typically calculate the distance or similarity measure between features and group data points according to the similarity measure value. Traditional clustering algorithms usually use unsupervised learning methods, such as k-means, hierarchical clustering, and DBSCAN, while deep learning-based clustering algorithms, such as autoencoders, variational autoencoders, and generative adversarial networks, can use neural networks to learn feature representations and optimize clustering results through clustering loss functions.
[0004] However, regardless of whether it's a traditional clustering algorithm or a deep learning-based clustering algorithm, these methods often perform poorly when the original feature similarity is insufficient, such as under conditions of poor lighting, nighttime, or occlusion. Figure 1It can be observed that, in this case, although the feature similarity is not discriminative enough, the ranking results based on the original features are mostly correct. Therefore, an efficient method is needed to combine the original feature distance and the original feature ranking results to jointly determine the clustering connection task. Hence, a feature clustering method based on KNN neighborhood IOU enhancement is proposed to solve the above problem. Summary of the Invention
[0005] (a) Technical problems to be solved To address the shortcomings of existing technologies, this invention provides a feature clustering method based on KNN neighborhood IOU enhancement, which has advantages such as good clustering effect and solves the problem of poor clustering effect.
[0006] (II) Technical Solution To achieve the aforementioned goal of good clustering results, this invention provides the following technical solution: a feature clustering method based on KNN neighborhood IOU enhancement, comprising the following steps: S1. Extract the recognition features from N data points; S2. Calculate the cosine distance between the pairwise features of the data, assuming the two vectors are represented as follows: , And the L2 norm of the identified features is equal to 1, that is , ; S3. Calculate the KNN for each data point, node... KNN abbreviation , ; S4. Traverse each node And for each node in the corresponding KNN, determine the node. and The distance is abbreviation ,judge Check if it is greater than T1. If not, continue, and the node is not connected. S5, Judgment If T2 is not satisfied, then no connection is made; otherwise, the node is computed. and of The value, while the IOU between two nodes refers to the ratio of the number of intersections to the number of unions in their corresponding KNN sets, that is: Then judge If the value is greater than T3, then connect; otherwise, do not connect. S6. Aggregate all connected edges and use the disjoint-set data structure algorithm (a classic algorithm in data structures) to construct a graph with all edges. After connection enhancement, the clustering process is completed.
[0007] Preferably, in step S5, card(S) represents the cardinality of set S, that is, the number of elements in set S.
[0008] Preferably, T1 = 0.70 in step S4, T2 = 0.40 in step S5, and T3 = 0.80 in step S5.
[0009] Preferably, in step S3, K=20 for KNN and the vector dimension is 512.
[0010] (III) Beneficial Effects Compared with existing technologies, this invention provides a feature clustering method based on KNN neighborhood IOU enhancement, which has the following beneficial effects: This feature clustering method based on KNN neighborhood IOU enhancement addresses the issue that conventional clustering methods, after establishing the KNN relationship graph of the original features, directly enhance the connection relationships between features based on the trained neural network, ignoring the impact of inaccurate features. In contrast, this invention transforms the similarity ranking between images into the IOU relationship between nodes, corrects the connection mode of node 6, and correctly classifies it into its own category, thereby making the connection relationships between the same category more reliable and effectively improving the accuracy and recall of the clustering algorithm. Attached Figure Description
[0011] Figure 1 This is a schematic diagram illustrating the extraction of image spatial distribution using a feature clustering method based on KNN neighborhood IOU enhancement proposed in this invention. Figure 2 This is a schematic diagram of the feature clustering method based on KNN neighborhood IOU enhancement proposed in this invention. Detailed Implementation
[0012] The technical solutions of the present invention will be clearly and completely described below with reference to the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] Aiming to provide an efficient method for utilizing ranking results, this paper proposes a feature clustering method based on KNN neighborhood IOU enhancement, which includes the following steps: S1. Extract the recognition features from N data points; S2. Calculate the cosine distance between the pairwise features of the data, assuming the two vectors are represented as follows: , And the L2 norm of the identified features is equal to 1, that is , ; S3. Calculate the KNN for each data point, node... KNN abbreviation , In KNN, K=20 and the vector dimension is 512; S4. Traverse each node And for each node in the corresponding KNN, determine the node. and The distance is abbreviation ,judge If the value is greater than T1, continue if the condition is not met, and the node is not connected. Here, T1 = 0.70. S5, Judgment Check if T2 is satisfied, where T2 = 0.40. If not, do not connect; otherwise, compute the node. and of The value, while the IOU between two nodes refers to the ratio of the number of intersections to the number of unions in their corresponding KNN sets, that is: Then judge If the value is greater than T3, then connect; otherwise, do not connect. Here, card(S) represents the cardinality of set S, that is, the number of elements in set S. S6. Aggregate all connected edges and use the disjoint-set data structure algorithm (a classic algorithm in data structures) to construct a graph with all edges. After connection enhancement, the clustering process is completed.
[0014] The beneficial effects of this invention are: Face or body clustering methods typically begin by feeding images into a pre-trained deep neural network to extract the image's representation in the feature space. Then, the cosine distance between each pair of features is calculated to obtain the corresponding relationship graph. The connection method of the entire relationship graph is set to K-Nearest Neighbor (KNN), known as the k-nearest neighbor algorithm. Figure 1 The first row shows the establishment of KNN relationships, where each digital node represents an image feature, and edges represent KNN connections between features. Then, a deep learning-based clustering method enhances the connections or confidence between nodes through a trainable neural network, increasing the affinity between nodes with higher similarity. Figure 1 As shown in the second row, the final clustering result is formed based on the enhanced connectivity relationships. Figure 1As shown in the third row, however, when the feature similarity is not sufficiently distinguishable, such as in low light conditions at night or under occlusion, images of different classes often have high similarity due to blurring and other factors, resulting in poor clustering performance. However, we observed that in such cases, by using any image as the comparison target, other images are sorted according to their similarity to the target. Images of the same class with higher similarity are sorted first, while images of different classes with lower similarity are sorted last. Based on this, the efficient utilization of the sorting results in this invention combines the original feature distance and the original feature sorting results to jointly determine the clustering connection task.
[0015] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A feature clustering method based on KNN neighborhood IOU enhancement, characterized in that, Includes the following steps: S1. Extract the recognition features from N data points; S2. Calculate the cosine distance between the pairwise features of the data, assuming the two vectors are represented as follows: , And the L2 norm of the identified features is equal to 1, that is , ; S3. Calculate the KNN for each data point, node... KNN abbreviation , ; S4. Traverse each node And for each node in the corresponding KNN, determine the node. and The distance is abbreviation ,judge Check if it is greater than T1. If not, continue, and the node is not connected. S5, Judgment If T2 is not satisfied, then no connection is made; otherwise, the node is computed. and of The value, while the IOU between two nodes refers to the ratio of the number of intersections to the number of unions in their corresponding KNN sets, that is: Then judge If the value is greater than T3, then connect; otherwise, do not connect. S6. Aggregate all connected edges and use the disjoint-set data structure algorithm (a classic algorithm in data structures) to construct a graph with all edges. After connection enhancement, the clustering process is completed.
2. The feature clustering method based on KNN neighborhood IOU enhancement according to claim 1, characterized in that: In step S5, card(S) represents the cardinality of set S, that is, the number of elements in set S.
3. The feature clustering method based on KNN neighborhood IOU enhancement according to claim 1, characterized in that: In step S4, T1 = 0.70; in step S5, T2 = 0.40; and in step S5, T3 = 0.
80.
4. The feature clustering method based on KNN neighborhood IOU enhancement according to claim 1, characterized in that: In step S3, K=20 for KNN and the vector dimension is 512.