Spaces:
Sleeping
Sleeping
traopia
commited on
Commit
·
19ee29e
1
Parent(s):
54ab71a
name chroma
Browse files- src/visual_qa.py +15 -0
src/visual_qa.py
CHANGED
@@ -26,6 +26,21 @@ def initialize_collection(collection_name="clip_image_embeddings"):
|
|
26 |
|
27 |
return collection
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
def main_create_image_collection(df_emb, collection_name="clip_image_embeddings"):
|
30 |
documents = []
|
31 |
embeddings_all = df_emb["fashion_clip_image"].tolist()
|
|
|
26 |
|
27 |
return collection
|
28 |
|
29 |
+
def initialize_collection(collection_name="clip_image_embeddings"):
|
30 |
+
client = chromadb.PersistentClient(path="./chroma_db")
|
31 |
+
|
32 |
+
# Extract just the collection names
|
33 |
+
existing_collections = [col.name for col in client.list_collections()]
|
34 |
+
|
35 |
+
if collection_name in existing_collections:
|
36 |
+
collection = client.get_collection(name=collection_name)
|
37 |
+
print(f"Using existing collection: {collection_name}")
|
38 |
+
else:
|
39 |
+
collection = client.create_collection(name=collection_name)
|
40 |
+
print(f"Created new collection: {collection_name}")
|
41 |
+
|
42 |
+
return collection
|
43 |
+
|
44 |
def main_create_image_collection(df_emb, collection_name="clip_image_embeddings"):
|
45 |
documents = []
|
46 |
embeddings_all = df_emb["fashion_clip_image"].tolist()
|