Spaces:
Sleeping
Sleeping
use florissant only for closest images
Browse files- closest_sample.py +3 -1
closest_sample.py
CHANGED
@@ -37,7 +37,9 @@ def pca_distance(pca,sample,embedding,top_k):
|
|
37 |
s = pca.transform(sample.reshape(1,-1))
|
38 |
all = pca.transform(embedding[:,-1])
|
39 |
distances = np.linalg.norm(all - s, axis=1)
|
40 |
-
|
|
|
|
|
41 |
|
42 |
def return_paths(argsorted,files):
|
43 |
paths= []
|
|
|
37 |
s = pca.transform(sample.reshape(1,-1))
|
38 |
all = pca.transform(embedding[:,-1])
|
39 |
distances = np.linalg.norm(all - s, axis=1)
|
40 |
+
sorted_indices = np.argsort(distances)
|
41 |
+
filtered_indices = sorted_indices[sorted_indices<=2852]
|
42 |
+
return filtered_indices[:top_k]
|
43 |
|
44 |
def return_paths(argsorted,files):
|
45 |
paths= []
|