zilliztech / feder

Visualize hnsw, faiss and other anns index
401 stars 34 forks source link

Can’t run test code with local index #74

Open luancaarvalho opened 1 year ago

luancaarvalho commented 1 year ago

Hello Feder team!

I'm trying to run your test example, but without using a remote index source location like `https://assets.zilliz.com/hnswlib_hnsw_voc_17k_1f1dfd63a9.index%60. I downloaded the index and put it in my directory. With the remote index, all the visualizations were loaded, but with the local index, the visualizations didn't load and became stuck in an infinite loop. Can you explain why this is happening, please?

Here is the code with both sources:


from federpy.federpy import FederPy

if __name__ == '__main__':
    hnswSource = 'hnswlib'
    hnswIndexFile = 'https://assets.zilliz.com/hnswlib_hnsw_voc_17k_1f1dfd63a9.index'
    # hnswIndexFile = 'hnswlib_hnsw_voc_17k_1f1dfd63a9.index'

    # Lite version, only input indexFile, no viewParams, no images.
    federPy_hnsw_lite = FederPy(hnswIndexFile, hnswSource)

    # federPy_hnsw_lite.overview()
    federPy_hnsw_lite.searchRandTestVec()
alwayslove2013 commented 1 year ago

@luancaarvalho FederPy cannot read local files directly. In fact, FederPy generates an html for display. This hmtl is run by the browser. It will read the index file in the browser and call FederJs to parse it. Note that browsers are not allowed to read local files directly, which violates the CORS protocol. If you want to read a local file, you first have to place the index file on the "network". Maybe you can place it on s3 so that other people on the network can see what you're sharing. Or a simpler example, you can use Python's SimpleHTTPServer to build a simple static file server, then Feder can find your index file from localhost.

amalpushp77 commented 8 months ago

Sharing index file through Google drive is not working. Is there a solution to run on colab notebook?

Aryazaky commented 2 months ago

@alwayslove2013 I have the same problem for colab notebook. I tried everything.

hnswSource = 'hnswlib'
# hnswIndexFile = docs_path + "hnswlib.index"
# local files do not work (https://github.com/zilliztech/feder/issues/74). Tried using a link
# hnswIndexFile = "https://drive.google.com/file/d/14VyVIfUcdq9vwJzh89eF27puWS2HBBEN/view?usp=sharing" 
# files hosted on google drive does not work. Tried filebin
hnswIndexFile = "https://filebin.net/kxv3eaz2nz9lrnee/chroma_hnsw_lite.index" 
# filebin also does not work. Tried using ngrock as a file server. Also doesn't work
hnswIndexFile = "https://5cce-35-184-42-253.ngrok-free.app/file"

federPy_hnsw = FederPy(hnswIndexFile, hnswSource)