Spaces:
Running
Running
File size: 794 Bytes
9632b77 cf0b712 9632b77 cf0b712 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import chromadb
client = chromadb.PersistentClient(path="./chroma_db") # Change path if needed
# Get a list of existing collection names
existing_collections = [col for col in client.list_collections()]
collection_name = "clip_image_embeddings"
if collection_name in existing_collections:
collection = client.get_collection(name=collection_name)
print(f"Using existing collection: {collection_name}")
print(existing_collections)
# Show up to 3 items
results = collection.get(limit=3)
for i in range(len(results["ids"])):
print(f"\nItem {i + 1}:")
print(f"ID: {results['ids'][i]}")
print(f"Document: {results['documents'][i]}")
print(f"Metadata: {results['metadatas'][i]}")
print("Number of items:", len(collection.get()["ids"]))
collection_data = collection.get()
|