pip install picachain
Check out Picachain and ChromaDB demo
Create your own image search pipeline with just a few lines of code.
from PIL import Image
import matplotlib.pyplot as plt
# import from picachain
from picachain.datastore import ChromaStore
from picachain.embedding import ClipEmbedding
from picachain.retriever import ImageRetriever
from picachain.search import ImageSearch
img = Image.open("image-path") # query image
images = [Image.open(os.path.join("images-path", image)) for image in os.listdir("images-path")] # image collection
# initiate embedding, datastore and retriever
embedding = ClipEmbedding()
datastore = ChromaStore("test-collection")
retriever = ImageRetriever(datastore, embedding, images)
image_search = ImageSearch(retriever=retriever, embedding=embedding, query_img=img)
result = image_search.search_relevant_images(top_k=3) # get top 3 relevant images
for img, score in result: # [(img, score), (img, score)]
plt.imshow(img)
plt.show()
It is under continuous development so currently supports only ChromaDB. We are working on integrating all popular vector databases such as Pinecone, Weaviate, etc.