towhee.hub.builtin.operators.faiss_search.faiss_search¶
- class towhee.hub.builtin.operators.faiss_search.faiss_search(findex, **kwargs)[source]¶
Bases:
object
Search for embedding vectors in Faiss. Note that the index has data before searching, refer to DataCollection Mixin to_faiss.
- Parameters:
findex (str or faiss.INDEX) – The path to faiss index file(defaults to ‘./index.bin’) or faiss index.
kwargs – The kwargs with index.search, refer to https://github.com/facebookresearch/faiss/wiki. And the parameter k defaults to 10.
Examples:
>>> import towhee >>> res = ( ... towhee.glob['path']('./*.jpg') ... .image_decode['path', 'img']() ... .image_embedding.timm['img', 'vec'](model_name='resnet50') ... .faiss_search['vec', 'results'](findex='./faiss/faiss.index') ... .to_list() ... ) [<Entity dict_keys(['path', 'img', 'vec', 'results'])>, <Entity dict_keys(['path', 'img', 'vec', 'results'])>]
Methods
Attributes
metainfo
- __call__(*args, **kws)¶
Call self as a function.