Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_with_ids not implemented for this type of index #1212

Closed
2 of 4 tasks
foocker opened this issue May 12, 2020 · 4 comments
Closed
2 of 4 tasks

add_with_ids not implemented for this type of index #1212

foocker opened this issue May 12, 2020 · 4 comments

Comments

@foocker
Copy link

foocker commented May 12, 2020

Problem:

RuntimeError: Error in virtual void faiss::IndexBinary::add_with_ids(faiss::IndexBinary::idx_t, const uint8_t*, const idx_t*) at IndexBinary.cpp:35: add_with_ids not implemented for this type of index

Running on:

  • CPU using yes.
  • GPU version yes, but not use.

Interface:

  • C++
  • Python yes

Reproduction instructions

simple code as follows:
index = faiss.IndexBinaryFlat(dimensions*8) #dimensions=32
features = []
ids = []
ids_count =0
for loop:
ret, feature = way_feature(way, file_name) # eg, cv2.ORB_create()...
ids_list = np.linspace(ids_count, ids_count, num=feature.shape[0], dtype="int64")
features.append(feature)
ids.append(ids_list)

features = np.vstack(features)
ids = np.hstack(ids)
if features.any():
if not index.is_trained:
index.train(features)
index.add_with_ids(features, ids) # change

@mdouze
Copy link
Contributor

mdouze commented May 12, 2020

add_with_ids is not supported for Flat indexes.
See https://github.com/facebookresearch/faiss/wiki/Guidelines-to-choose-an-index#then-flat

@foocker
Copy link
Author

foocker commented May 12, 2020

add_with_ids is not supported for Flat indexes.
See https://github.com/facebookresearch/faiss/wiki/Guidelines-to-choose-an-index#then-flat

thx for your replay.
some points:
surf's feature is float, so i can use "IDMap,Flat", it's work. but orb's feature vector is uint8, i should use binary index, and hamming distance, not cosine or L2, all sence will be add_with_ids.
so i have two questions:
1.binary index, with add_with_ids, using hamming, what index should i choose?
2.when i change orb's feature from surf'feature, surf work well, i got :
TypeError: in method 'Index_add_with_ids', argument 3 of type 'float const *'

@foocker
Copy link
Author

foocker commented May 13, 2020

add_with_ids is not supported for Flat indexes.
See https://github.com/facebookresearch/faiss/wiki/Guidelines-to-choose-an-index#then-flat

thx for your replay.
some points:
surf's feature is float, so i can use "IDMap,Flat", it's work. but orb's feature vector is uint8, i should use binary index, and hamming distance, not cosine or L2, all sence will be add_with_ids.
so i have two questions:
1.binary index, with add_with_ids, using hamming, what index should i choose?
2.when i change orb's feature from surf'feature, surf work well, i got :
TypeError: in method 'Index_add_with_ids', argument 3 of type 'float const *'

i have test some other binary index, in binary wiki, add_with_ids was not implemented。
but IndexBinaryHash is ok, but , what's means of IndexBinaryHash 's second parameter?
is hash radius?nflip , radius=nflip? ---> i guess is num of b(桶).
but when use IndexBinaryHash write_index, i get:
TypeError: Wrong number or type of arguments for overloaded function 'write_index'.
Possible C/C++ prototypes are:
faiss::write_index(faiss::Index const *,char const *)
faiss::write_index(faiss::Index const *,FILE *)
faiss::write_index(faiss::Index const *,faiss::IOWriter *)

sorry, write_index_binary is ok..

@foocker foocker closed this as completed May 22, 2020
@goldwater668
Copy link

@foocker Open CV feature vectors such as surf and sift have been extracted. How to use faiss for vector index? Do you have any reference cases? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants