From 7228cbb3fde3934e7f75091da5f0d7266b30333f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Karla=C5=A1?= Date: Mon, 30 Sep 2024 17:14:22 -0400 Subject: [PATCH] Make faiss dependency optional. --- experiments/datascope/experiments/pipelines/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/experiments/datascope/experiments/pipelines/models.py b/experiments/datascope/experiments/pipelines/models.py index 447749c..a277684 100644 --- a/experiments/datascope/experiments/pipelines/models.py +++ b/experiments/datascope/experiments/pipelines/models.py @@ -1,4 +1,4 @@ -import faiss +# import faiss import numpy as np import tempfile import torch @@ -100,6 +100,8 @@ def __init__(self, n_neighbors=5): self.label_encoder = LabelEncoder() def fit(self, X, y): + import faiss + self.X = X.astype(np.float32) self.y = self.label_encoder.fit_transform(y) d = self.X.shape[1]