Giter VIP home page Giter VIP logo

faiss-web-service's Introduction

Faiss Web Service

Getting started

The fastest way to get started is to use the docker hub image with the following command:

docker run --rm -it -p 5000:5000 plippe/faiss-web-service:[FAISS_RELEASE]

Once the container is running, you should be able to ping the service:

# Healthcheck
curl 'localhost:5000/ping'

# Faiss search for ids 1, 2, and 3
curl 'localhost:5000/faiss/search' -X POST -d '{"k": 5, "ids": [1, 2, 3]}'

# Faiss search for a vector
curl 'localhost:5000/faiss/search' -X POST -d '{"k": 5, "vectors": [[54.7, 0.3, 0.6, 0.4, 0.1, 0.7, 0.2, 0.0, 0.6, 0.5, 0.3, 0.2, 0.1, 0.9, 0.3, 0.6, 0.2, 0.9, 0.5, 0.0, 0.9, 0.1, 0.9, 0.1, 0.5, 0.5, 0.8, 0.8, 0.5, 0.2, 0.6, 0.2, 0.2, 0.7, 0.1, 0.7, 0.8, 0.2, 0.9, 0.0, 0.4, 0.4, 0.9, 0.0, 0.6, 0.4, 0.4, 0.6, 0.6, 0.2, 0.5, 0.0, 0.1, 0.6, 0.0, 0.0, 0.4, 0.7, 0.5, 0.7, 0.2, 0.5, 0.5, 0.7]]}'

Custom index

By default, the faiss web service will use the files in the resources folder. Those can be overwritten by mounting new ones.

docker run \
    --rm \
    -it \
    -p 5000:5000 \
    -v [PATH_TO_RESOURCES]:/opt/faiss-web-service/resources \
    plippe/faiss-web-service:[FAISS_RELEASE]

Another solution would be to create a new docker image from plippe/faiss-web-service, that adds your resources.

Production

The application runs with Flask's build in server. Flask's documentation clearly states it is not suitable for production.

faiss-web-service's People

Contributors

plippe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

faiss-web-service's Issues

requirements.txt did not write faiss

Thanks for your code i understand how can i use this.
I see there is no “faiss” in requirements.txt and “anconda” in Dockerfile. Will it be installed when i start in docker?

I found it in Makefile...

curl: (56) Recv failure: Connection reset by peer

[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f731d1c8ebe7 plippe/faiss-web-service:1.2.1-cpu "/opt/faiss-web-se..." About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp focused_pare
[root@localhost ~]# curl 'localhost:5000/ping'
curl: (56) Recv failure: Connection reset by peer
[root@localhost ~]# curl '0.0.0.0:5000/ping'
curl: (56) Recv failure: Connection reset by peer
[root@localhost ~]# curl 'localhost:5000/faiss/search' -X POST -d '{"k": 5, "ids": [1, 2, 3]}'
curl: (56) Recv failure: Connection reset by peer

when run index script,i got the RuntimeError that 'nx >= k' failed

after run the “python train_index.py” command, got the fellow error message:

File "/root/anaconda3/envs/tempCv36/lib/python3.6/site-packages/faiss/init.py", line 157, in replacement_train
self.train_c(n, swig_ptr(x))
File "/root/anaconda3/envs/tempCv36/lib/python3.6/site-packages/faiss/swigfaiss_avx2.py", line 6097, in train
return _swigfaiss_avx2.IndexIDMap_train(self, n, x)
RuntimeError: Error in void faiss::Clustering::train_encoded(faiss::Clustering::idx_t, const uint8_t*, const faiss::Index*, faiss::Index&, const float*) at Clustering.cpp:273: Error: 'nx >= k' failed: Number of training points (796) should be at least as large as number of clusters (1024)

Unable to upgrade faiss

Hi ! Thanks for this very simple yet powerful tool !

Just wondering if someone here has managed to upgrade to faiss 1.5.2 ? When I try to do so, I struggle with endless conflicts within conda, and even when I manage to make it run, uwsgi is missing and screws up everything. In my last try I downgraded python to 3.6, thinking it was the problem (spoiler : it wasn't), and now I got ImportError: cannot import name 'FaissIndex'. Really don't get it.

I'm starting a fresh new project with faiss, and I really want it to be up to date, there is no point starting today with an already outdated version. Hope someone can help :) Thanks for reading.

Shrink docker image

Base docker image is based on the official repository when the only required files are:

  • faiss.py
  • swigfaiss.py
  • _swigfaiss.so

Change base image to python 2.7-alpine, and 3.6-alpine

Bring up to date

Project hasn't been touched in ages.
Update all the libs, and highlight potential issues to fix.

Error response from daemon: oci runtime error: container_linux.go:247

[root@localhost opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/plippe/faiss-web-service 1.2.1-cpu 177ca41c46f0 9 hours ago 1.76 GB
docker.io/plippe/faiss-web-service latest 177ca41c46f0 9 hours ago 1.76 GB
[root@localhost opt]# docker run --rm --detach --publish 5000:5000 plippe/faiss-web-service:1.2.1-cpu
2194a8c6c1a81b499dd89e012d59504b80e37230788a4536b60a143c80476e71
/usr/bin/docker-current: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: "/opt/faiss-web-service/bin/faiss_web_service.sh": stat /opt/faiss-web-service/bin/faiss_web_service.sh: no such file or directory".

how to create ids_vectors.p and index file?

how to create ids_vectors.p and index file?
i have 1000 product picture wanna to index. and then i can search by faiss-web-service, but i don't know how to index.

and my product picture will increase dynamic, so how can i update ids_vectors.p and index file?

image feature is 2-Dimensional, what is ids for one picture ?

i extract feature from image. every picture have 2-Dimensional feature, like [[0.32, 0.52 ...], [0.32, 0.52 ...], [0.32, 0.52 ...]].
when i index for one picture. it like this

xb = # xb extract from one image
index = faiss.IndexFlatL2(xb.shape[1])
index_with_ids = faiss.IndexIDMap(index)
index_with_ids.add_with_ids(xb, ids)

then, what is ids for one picture ?

and, what is xb and ids for many images ? (image feature is 2-Dimensional)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.