Zhongdao / gcn_clustering

Code for CVPR'19 paper Linkage-based Face Clustering via GCN
MIT License
360 stars 86 forks source link

how to generate the KNN graph? #2

Closed whxhngns200 closed 5 years ago

Zhongdao commented 5 years ago

KNN graph is calculated from face features. If in your application the accuracy is the most important, you can generate KNN graph by brute force, which requires to compute all pairwise similarity and the complexity is O(n^2). If you want it fast, please use approximate nearest neighbor algorithms. For instance, I use FLANN in this work. You can also check faiss(https://github.com/facebookresearch/faiss). The best complexity of ANN is O(nlogn).

yh1226 commented 5 years ago

can you list the parameters of flann or the code ? thanks!

swg209 commented 5 years ago

Does knn graph means to get μNNs in the paper? If not, how can I get the top μ node in the origin entire collection? Using L2 distance between feature- feature pair to decide? Thx.

gitarya commented 4 years ago

you can use this code below:

import faiss
d = 512
index = faiss.IndexFlatL2(d)
index.add(features)
k = 200
D, I = index.search(features, k)

and I is the knn_graph