From 6fd3944c4f4d4f227d3114da85b25a51d1db2f85 Mon Sep 17 00:00:00 2001 From: gaotingquan Date: Fri, 15 Nov 2024 06:13:26 +0000 Subject: [PATCH] bugfix: dont pass index_type and metric_type in append_index() --- paddlex/inference/components/retrieval/faiss.py | 5 ++++- paddlex/inference/pipelines/pp_shitu_v2.py | 11 ++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/paddlex/inference/components/retrieval/faiss.py b/paddlex/inference/components/retrieval/faiss.py index 5ddc5396b..7b70342f4 100644 --- a/paddlex/inference/components/retrieval/faiss.py +++ b/paddlex/inference/components/retrieval/faiss.py @@ -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 diff --git a/paddlex/inference/pipelines/pp_shitu_v2.py b/paddlex/inference/pipelines/pp_shitu_v2.py index 8ead18390..71946ea0d 100644 --- a/paddlex/inference/pipelines/pp_shitu_v2.py +++ b/paddlex/inference/pipelines/pp_shitu_v2.py @@ -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 )