-
Notifications
You must be signed in to change notification settings - Fork 238
RuntimeError: Cannot open file #1407
Copy link
Copy link
Closed
Description
How to avoid errors caused by repeated execution
from docarray import DocList, BaseDoc
from docarray.index import HnswDocumentIndex, ElasticV7DocIndex, ElasticDocIndex
import numpy as np
from docarray.typing import ImageUrl, ImageTensor, NdArray
class ImageDoc(BaseDoc):
url: ImageUrl
tensor: ImageTensor
embedding: NdArray[128]
# create some data
dl = DocList[ImageDoc](
[
ImageDoc(
url="https://upload.wikimedia.org/wikipedia/commons/2/2f/Alpamayo.jpg",
tensor=np.zeros((3, 224, 224)),
embedding=np.random.random((128,)),
)
for _ in range(100)
]
)
# create a Document Index
index = HnswDocumentIndex[ImageDoc](work_dir='test_index')
# index your data
index.index(dl)
# find similar Documents
query = dl[0]
results, scores = index.find(query, limit=10, search_field='embedding')Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done