Spaces:
Running
Running
traopia
commited on
Commit
·
9632b77
1
Parent(s):
dfef9ae
Clean large files and re-commit
Browse files- .gitignore +1 -0
- __pycache__/visual_qa.cpython-310.pyc +0 -0
- app.py +4 -2
- playground.ipynb +23 -0
- playground.py +10 -0
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
chroma_db/
|
__pycache__/visual_qa.cpython-310.pyc
ADDED
Binary file (3.45 kB). View file
|
|
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
#example just for fun
|
3 |
-
|
4 |
from src.generate_queries_alternative import main_generate_queries
|
5 |
import time
|
6 |
import pandas as pd
|
@@ -15,7 +15,7 @@ except OSError:
|
|
15 |
download("en_core_web_sm")
|
16 |
nlp = spacy.load("en_core_web_sm")
|
17 |
|
18 |
-
|
19 |
|
20 |
def handle_structured_query(question, sort_by=""):
|
21 |
if not question:
|
@@ -64,6 +64,8 @@ def handle_image_query(text):
|
|
64 |
|
65 |
try:
|
66 |
records = main_text_retrieve_images(text)
|
|
|
|
|
67 |
except Exception as e:
|
68 |
return [("https://via.placeholder.com/300x200?text=Error", f"Error: {e}")]
|
69 |
|
|
|
1 |
import gradio as gr
|
2 |
#example just for fun
|
3 |
+
from src.visual_qa import main_text_retrieve_images
|
4 |
from src.generate_queries_alternative import main_generate_queries
|
5 |
import time
|
6 |
import pandas as pd
|
|
|
15 |
download("en_core_web_sm")
|
16 |
nlp = spacy.load("en_core_web_sm")
|
17 |
|
18 |
+
|
19 |
|
20 |
def handle_structured_query(question, sort_by=""):
|
21 |
if not question:
|
|
|
64 |
|
65 |
try:
|
66 |
records = main_text_retrieve_images(text)
|
67 |
+
print(f"Retrieved {len(records)} records for query: {text}")
|
68 |
+
print(records)
|
69 |
except Exception as e:
|
70 |
return [("https://via.placeholder.com/300x200?text=Error", f"Error: {e}")]
|
71 |
|
playground.ipynb
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"id": "883693d5",
|
7 |
+
"metadata": {
|
8 |
+
"vscode": {
|
9 |
+
"languageId": "plaintext"
|
10 |
+
}
|
11 |
+
},
|
12 |
+
"outputs": [],
|
13 |
+
"source": []
|
14 |
+
}
|
15 |
+
],
|
16 |
+
"metadata": {
|
17 |
+
"language_info": {
|
18 |
+
"name": "python"
|
19 |
+
}
|
20 |
+
},
|
21 |
+
"nbformat": 4,
|
22 |
+
"nbformat_minor": 5
|
23 |
+
}
|
playground.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import chromadb
|
2 |
+
client = chromadb.PersistentClient(path="./chroma_db") # Change path if needed
|
3 |
+
|
4 |
+
# Get a list of existing collection names
|
5 |
+
existing_collections = [col.name for col in client.list_collections()]
|
6 |
+
collection_name = "clip_image_embeddings"
|
7 |
+
if collection_name in existing_collections:
|
8 |
+
collection = client.get_collection(name=collection_name)
|
9 |
+
print(f"Using existing collection: {collection_name}")
|
10 |
+
print(existing_collections)
|