diff --git a/examples/index.py b/examples/index.py index d035d8f..452b07f 100644 --- a/examples/index.py +++ b/examples/index.py @@ -23,6 +23,9 @@ def create_index(name, images): # Add images in batch (List of image paths locally stored) index.addImageBatch(images[1:]) + # Build the index + index.createIndex() + return index diff --git a/imsearch/index.py b/imsearch/index.py index 0aa38dc..11daa96 100644 --- a/imsearch/index.py +++ b/imsearch/index.py @@ -41,6 +41,7 @@ def __init__(self, name): self._repository_db = get_repository(self.name, 'mongo') def __del__(self): + self._nmslib_index.createIndex() Index.object_counter -= 1 if Index.object_counter == 0 and Index.fe is not None: Index.fe.terminate()