Skip to content

Commit

Permalink
bugfix: dont pass index_type and metric_type in append_index()
Browse files Browse the repository at this point in the history
  • Loading branch information
TingquanGao committed Nov 15, 2024
1 parent f4399e8 commit 6fd3944
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
5 changes: 4 additions & 1 deletion paddlex/inference/components/retrieval/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,11 @@ def _add_gallery(
else:
index.train(gallery_features)

if not metric_type in cls.BINARY_METRIC_TYPE:
if metric_type not in cls.BINARY_METRIC_TYPE:
index.add_with_ids(gallery_features, ids_now)
# TODO(gaotingquan): how append when using hamming metric type
# else:
# pass

for i, d in zip(list(ids_now), gallery_docs):
ids[i] = d
Expand Down
11 changes: 2 additions & 9 deletions paddlex/inference/pipelines/pp_shitu_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,20 @@ def build_index(
self.rec_model.predict,
metric_type=metric_type,
index_type=index_type,
**kwargs
)

def remove_index(self, remove_ids, index, **kwargs):
return FaissBuilder.remove(remove_ids, index, **kwargs)
def remove_index(self, remove_ids, index):
return FaissBuilder.remove(remove_ids, index)

def append_index(
self,
gallery_imgs,
gallery_label,
index,
id_map=None,
metric_type="IP",
index_type="HNSW32",
**kwargs
):
return FaissBuilder.append(
gallery_imgs,
gallery_label,
self.rec_model.predict,
index,
metric_type=metric_type,
**kwargs
)

0 comments on commit 6fd3944

Please sign in to comment.