Spaces:
Runtime error
Runtime error
Update app.py
Browse filesadd description by llm
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from utils.utils import get_logger, initialization,
|
| 2 |
import gradio as gr
|
| 3 |
import logging
|
| 4 |
|
|
@@ -15,9 +15,6 @@ def main(query):
|
|
| 15 |
logger.info("-------------------------------------------------------")
|
| 16 |
exit = False
|
| 17 |
while not exit:
|
| 18 |
-
# Collect user query
|
| 19 |
-
# query = input('Type your query, or "exit" if you want to exit: ')
|
| 20 |
-
|
| 21 |
if query == "exit":
|
| 22 |
exit = True
|
| 23 |
print("-------------------------------------------------------")
|
|
@@ -26,24 +23,26 @@ def main(query):
|
|
| 26 |
logger.info("Search terminated.")
|
| 27 |
return None, "Search terminated."
|
| 28 |
else:
|
| 29 |
-
# Get search result including the original
|
| 30 |
-
image, text =
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
if __name__ == "__main__":
|
| 38 |
try:
|
| 39 |
if collection == None:
|
| 40 |
collection, data_set, model, logger = initialization(logger)
|
| 41 |
-
|
| 42 |
app = gr.Interface(
|
| 43 |
fn=main,
|
| 44 |
inputs=[gr.Textbox(label="Describe the scene that you are looking for:")],
|
| 45 |
-
outputs=[gr.Image(label="Here's the scene found based on your
|
| 46 |
-
gr.Textbox(label="Original description of the found scene:")
|
|
|
|
| 47 |
title="Search for a scene in the world of GTA!"
|
| 48 |
)
|
| 49 |
app.launch(share=True)
|
|
|
|
| 1 |
+
from utils.utils import get_logger, initialization, get_search_result, get_image_description
|
| 2 |
import gradio as gr
|
| 3 |
import logging
|
| 4 |
|
|
|
|
| 15 |
logger.info("-------------------------------------------------------")
|
| 16 |
exit = False
|
| 17 |
while not exit:
|
|
|
|
|
|
|
|
|
|
| 18 |
if query == "exit":
|
| 19 |
exit = True
|
| 20 |
print("-------------------------------------------------------")
|
|
|
|
| 23 |
logger.info("Search terminated.")
|
| 24 |
return None, "Search terminated."
|
| 25 |
else:
|
| 26 |
+
# Get search result including the original description of the image
|
| 27 |
+
image, text = get_search_result(collection, data_set, query, model, n_results=2)
|
| 28 |
|
| 29 |
+
# Get detailed description of the image generated by multimodal LLM
|
| 30 |
+
description_by_llm = get_image_description(image)
|
| 31 |
+
|
| 32 |
+
return image, text, description_by_llm
|
| 33 |
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
try:
|
| 37 |
if collection == None:
|
| 38 |
collection, data_set, model, logger = initialization(logger)
|
| 39 |
+
|
| 40 |
app = gr.Interface(
|
| 41 |
fn=main,
|
| 42 |
inputs=[gr.Textbox(label="Describe the scene that you are looking for:")],
|
| 43 |
+
outputs=[gr.Image(label="Here's the scene found based on your input:"),
|
| 44 |
+
gr.Textbox(label="Original description of the found scene:"),
|
| 45 |
+
gr.Textbox(label="Detailed description generated by LLM:")],
|
| 46 |
title="Search for a scene in the world of GTA!"
|
| 47 |
)
|
| 48 |
app.launch(share=True)
|