Skip to content

Commit

Permalink
reload tree on start after an import
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrannas committed Mar 8, 2024
1 parent 75161f9 commit ae441e2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions panoptic_back/panoptic/plugins/FaissPlugin/faiss_plugin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os.path

from pydantic import BaseModel

from panoptic.core.project.project import Project
Expand Down Expand Up @@ -35,6 +37,16 @@ def __init__(self, project: Project, plugin_path: str):
project.action.find_images.register(self, self.find_images)
project.action.group_images.register(self, self.compute_clusters)

async def start(self):
await super().start()
vectors = await self.project.db.get_vectors(self.name, 'clip')

# TODO: handle this properly with an import hook
if not os.path.exists(os.path.join(self.project.base_path, 'tree_faiss.pkl')) and len(vectors) > 0:
from panoptic.plugins.FaissPlugin.create_faiss_index import compute_faiss_index
await compute_faiss_index(self.project.base_path, self.project.db, self.name, 'clip')
reload_tree(self.project.base_path)

async def compute_image_vector(self, instance: Instance):
task = ComputeVectorTask(self.project, self.name, 'clip', instance)
self.project.task_queue.add_task(task)
Expand Down

0 comments on commit ae441e2

Please sign in to comment.