Spaces:
Sleeping
Sleeping
Create app.py
Browse filesApp to retrieve the top results for each kind of query with using the multimodal search
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from search_ocean import search_text, search_image, search_pdf
|
3 |
+
|
4 |
+
def multimodal_search(query, image):
|
5 |
+
results = []
|
6 |
+
if query:
|
7 |
+
text_results = search_text(query)
|
8 |
+
pdf_results = search_pdf(query)
|
9 |
+
results += [f"📝 Text: {r['metadata']['filename']}\n{r['metadata']['content'][:200]}" for r in text_results]
|
10 |
+
results += [f"📄 PDF: {r['metadata']['filename']}\n{r['metadata']['content'][:200]}" for r in pdf_results]
|
11 |
+
if image:
|
12 |
+
image_results = search_image(image)
|
13 |
+
results += [f"🖼️ Image: {r['metadata']['filename']}" for r in image_results]
|
14 |
+
return "\n\n".join(results)
|
15 |
+
|
16 |
+
gr.Interface(
|
17 |
+
fn=multimodal_search,
|
18 |
+
inputs=[
|
19 |
+
gr.Textbox(label="Text Query"),
|
20 |
+
gr.Image(type="pil", label="Image Query")
|
21 |
+
],
|
22 |
+
outputs=gr.Textbox(label="Top Results"),
|
23 |
+
title="Multimodal RAG with Ocean and CLIP",
|
24 |
+
).launch()
|