Created
August 22, 2019 12:22
-
-
Save mdouze/e30e8f57a98ed841c082cc68baa14b4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################### | |
# serialization of indexes to byte arrays | |
########################################### | |
def serialize_index(index): | |
""" convert an index to a numpy uint8 array """ | |
writer = faiss.VectorIOWriter() | |
faiss.write_index(index, writer) | |
return faiss.vector_to_array(writer.data) | |
def deserialize_index(data): | |
reader = faiss.VectorIOReader() | |
faiss.copy_array_to_vector(data, reader.data) | |
return faiss.read_index(reader) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Eureka!