Spaces:
Sleeping
Sleeping
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() | |