import numpy as np from sklearn.neighbors import NearestNeighbors # Convert the feature vectors to a NumPy array features_array = np.array(list(features_dict.values())) # Create a NearestNeighbors object and fit it to the features array knn = NearestNeighbors(n_neighbors=11, metric='cosine') knn.fit(features_array) # Define a function to retrieve the most similar images to a query image def retrieve_similar_images(query_image_name, knn_model, features_dict): # Get the features for the query image query_features = features_dict[query_image_name] # Reshape the features to match the expected input format for the knn_model query_features = query_features.reshape(1, -