-
-
Save allenanie/cbaf512d8ad4d0bad8b1697ac4d79b53 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