You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
826 B

  1. # import faiss
  2. # # Load the FAISS index
  3. # index = faiss.read_index("face_index.faiss")
  4. # # Print information about the index
  5. # print(f"Number of vectors in the index: {index.ntotal}")
  6. # print(index)
  7. import faiss
  8. import numpy as np
  9. # Load the FAISS index
  10. index = faiss.read_index("face_index.faiss")
  11. # Check the total number of vectors in the index
  12. total_vectors = index.ntotal
  13. print(f"Number of vectors in the index: {total_vectors}")
  14. # Reconstruct vectors one by one
  15. vectors = []
  16. for i in range(total_vectors):
  17. vectors.append(index.reconstruct(i))
  18. # Convert the list of vectors to a NumPy array
  19. vectors_array = np.array(vectors)
  20. # Save the array to a text file for inspection
  21. np.savetxt("faiss_vectors.txt", vectors_array, fmt="%.6f")
  22. print("Vectors saved to faiss_vectors.txt")