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
How to use image search #67
Comments
Generating image feature vectors is up to you. You can do it a few ways..
|
I have briefly considered adding some functionality to the plugin to ingest images but there are many other things to solve first. It might be implemented as an ingest processor with a small handful of common algos for mapping images to vectors, e.g. phash, sift, a few convnets, etc.. |
{'_index': 'long', '_type': '_doc', '_id': 'ids-1485050', '_score': 0.0625227} I used vgg16 in karas to obtain the image feature vector, and saved the image feature vector in elasticsearch7.40 version. However, when I used elasticsearch to query the image data, I found them all. How can I obtain the image similarity diagram I want to query?How much does the _score attribute have to be similar?I'm using the L1 function here |
I guess you mean they all had roughly the same score? L1 might not be a good similarity function for those vectors. I would try L2. |
Here is an example of using L2 (on raw image pixels, not feature vectors): http://demo.elastiknn.klibisz.com/dataset/cifar-l2 You can see the exact mapping and query for each set of results by clicking on the |
That means I have to save the original image pixels in elasticsearch instead of saving the feature vectors. That's right. How does the elastiknn library create search queries?
|
I mapped to create the elasticsearch index, python as follows:
|
You can use that same mapping with L1, L2, and angular. If you want to use an approximate method you'll have to modify the line You can save either the original pixels or the feature vector. I was just pointing to an example where L2 seems to work well on the original pixels. Most papers I've read also use L2 on feature vectors or they normalize the features vectors to unit norm and use angular. I don't think I've seen L1 used for images. For exact queries, the plugin creates a FunctionScoreQuery that scores every vector in the index against the query vector. So that's obviously not very efficient. For approximate queries it hashes the stored vectors, indexes the hashes (just like words), uses the same hash function to hash the query vector, and runs a boolean match query to lookup stored vectors which share the most hash values with the query vector. There's a lot more info here: http://elastiknn.klibisz.com/api/ |
Thank you. I'll try it first |
I made the following error while creating the elasticsearch index:
Add in the file (https://github.com/alexklibisz/elastiknn/blob/master/client-python/elastiknn/api.py) the following:
|
Try |
Do not "similarity": "12".Again, the following error message:
Create an elasticsearch index file as follows:
api.py
I used elasticsearch version 7.4.0 |
You need to specify the similarity as
The similarity field is required when using the lsh model. |
thank you. I made a mistake between the number 1 and the letter l.You can create it successfully |
Why does the query result differ from what I expected. The query results are as follows:
How are score values scored? All the pictures in elasticsearch have some similarities. For example, all my pictures have the words "children's day" Here are my three pictures: |
I'm not sure what you are expecting. :) |
@yu258 I added the missing mappings and queries in this PR #68 |
One thing to consider when doing image search with L2 is that the floating point operations might overflow if your vector has large values. You might try to scale your vectors values so they are between 0 and 1. |
What's a good python library for generating image feature vectors?Currently, I use the image feature vector which is similar to [0.0,0.2...].In this format |
I've always used the pretrained models from Keras: https://keras.io/api/applications/ |
Closing this. Let me know if there are any other questions and we can open it again if needed. |
When I used image search, I returned all documents from elasticsearch.How does the elastiknn plugin generate image feature vectors?The language I use is python
The text was updated successfully, but these errors were encountered: