Skip to content

Commit

Permalink
fix: change to open_clip embedder
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragts committed Dec 30, 2024
1 parent 9705f34 commit 35061c3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cookbook/agents/48_search_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def search_image():
# image_searcher = load_images_to_vector_db("FashionDataset.csv", limit=30)

# Search with a query image
query_image = "https://assets.myntassets.com/assets/images/18704418/2022/6/11/507490f7-c8f9-492c-b3f8-c7e977d1af701654922515416SochWomenRedThreadWorkGeorgetteAnarkaliKurta1.jpg"
query_image = "http://assets.myntassets.com/assets/images/12413214/2021/11/22/bb925efb-80d9-4cb6-838c-df86f1ba3c3e1637570416652-Varanga-Women-Mustard-Yellow-Floral-Yoke-Embroidered-Straigh-1.jpg"
similar_images = image_searcher.search_similar_images(query_image, limit=10)

# Print results
Expand Down
4 changes: 2 additions & 2 deletions phi/tools/image_to_image_search.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from phi.tools.openai_embeddings import OpenAIEmbeddings
from phi.tools.openclip_embedder import OpenClipEmbedder
from phi.vectordb.chroma import ChromaDb
from phi.document import Document
from typing import List
import numpy as np

class ImageSearcher:
def __init__(self):
self.embeddings = OpenAIEmbeddings()
self.embeddings = OpenClipEmbedder()
self.vector_db = ChromaDb(
collection="image_collection",
embedder=self.embeddings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
raise ImportError("`open-clip-torch` is not installed. Please install using `pip install open-clip-torch`")

class OpenAIEmbeddings(Toolkit):
class OpenClipEmbedder(Toolkit):
def __init__(self, model: str = "hf-hub:laion/CLIP-ViT-g-14-laion2B-s12B-b42K"):
super().__init__(name="openai_embeddings")
self.model_name = model # For storing the original model name for tokenizer to use.
Expand Down

0 comments on commit 35061c3

Please sign in to comment.