Delete Three.py
Browse files
Three.py
DELETED
@@ -1,16 +0,0 @@
|
|
1 |
-
import numpy as np
|
2 |
-
from sklearn.neighbors import NearestNeighbors
|
3 |
-
|
4 |
-
# Convert the feature vectors to a NumPy array
|
5 |
-
features_array = np.array(list(features_dict.values()))
|
6 |
-
|
7 |
-
# Create a NearestNeighbors object and fit it to the features array
|
8 |
-
knn = NearestNeighbors(n_neighbors=11, metric='cosine')
|
9 |
-
knn.fit(features_array)
|
10 |
-
|
11 |
-
# Define a function to retrieve the most similar images to a query image
|
12 |
-
def retrieve_similar_images(query_image_name, knn_model, features_dict):
|
13 |
-
# Get the features for the query image
|
14 |
-
query_features = features_dict[query_image_name]
|
15 |
-
# Reshape the features to match the expected input format for the knn_model
|
16 |
-
query_features = query_features.reshape(1, -
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|