henryhyunwookim commited on
Commit
575e30b
1 Parent(s): dc81f01

Update app.py

Browse files

add description by llm

Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -1,4 +1,4 @@
1
- from utils.utils import get_logger, initialization, get_result
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 descriptions of the images
30
- image, text = get_result(collection, data_set, query, model, n_results=2)
31
 
32
- # Display the image, its caption, and user query
33
- # show_image(image, text, query)
34
- return image, text
 
35
 
36
 
37
  if __name__ == "__main__":
38
  try:
39
  if collection == None:
40
  collection, data_set, model, logger = initialization(logger)
41
- # main()
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 description:"),
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)