Spaces:
Runtime error
Runtime error
update layout with acordion
Browse files
app.py
CHANGED
@@ -58,8 +58,9 @@ def Image_similarity_search(image_in, search_query):
|
|
58 |
with gr.Blocks(css = """#label_mid {padding-top: 2px; padding-bottom: 2px;}
|
59 |
#label_results {padding-top: 5px; padding-bottom: 1px;}
|
60 |
#col-container {max-width: 580px; margin-left: auto; margin-right: auto;}
|
|
|
61 |
""") as demo:
|
62 |
-
with gr.
|
63 |
gr.HTML("""<div style="text-align: center; max-width: 700px; margin: 0 auto;">
|
64 |
<div
|
65 |
style="
|
@@ -81,22 +82,22 @@ with gr.Blocks(css = """#label_mid {padding-top: 2px; padding-bottom: 2px;}
|
|
81 |
In this demo, the first step involves making an API call to the BLIP2 Gradio demo to retrieve image captions.
|
82 |
Next, Langchain is used to create an embedding and vector space for the image prompts and their respective "source" from the PlaygroundAI dataset.
|
83 |
Finally, a similarity search is performed over the vector space and the top result is returned.
|
84 |
-
|
85 |
-
</p></div>""")
|
86 |
#with gr.Column(scale=3):
|
87 |
# pass
|
88 |
with gr.Column(elem_id = "col-container"):
|
89 |
-
label_top = gr.HTML(value= "<center>๐ผ๏ธ
|
90 |
image_in = gr.Image(label="Upoload an Image for search", type='filepath', elem_id="image_in")
|
91 |
label_mid = gr.HTML(value= "<p style='text-align: center; color: red;'>Or</center></p>", elem_id='label_mid')
|
92 |
-
label_bottom = gr.HTML(value= "<center>๐Type in your serch query and press Enter
|
93 |
search_query = gr.Textbox(placeholder="Example: A small cat sitting", label="", elem_id="search_query", value='')
|
94 |
#b1 = gr.Button("Search").style(full_width=False)
|
95 |
label_results = gr.HTML(value= "<p style='text-align: center; color: blue; font-weight: bold;'>Search results from PlaygroundAI</center></p>", elem_id="label_results")
|
96 |
img_search = gr.HTML(label = 'Image search results from PlaygroundAI dataset', elem_id="img_search")
|
97 |
pai_prompt = gr.Textbox(label="Image prompt from PlaygroundAI dataset", elem_id="pai_prompt")
|
98 |
-
|
99 |
-
|
|
|
100 |
|
101 |
image_in.change(Image_similarity_search, [image_in, search_query], [pai_prompt, img_search], api_name="PlaygroundAI_image_search" )
|
102 |
search_query.submit(Image_similarity_search, image_in, [pai_prompt, img_search], api_name='PlaygroundAI_text_search' )
|
|
|
58 |
with gr.Blocks(css = """#label_mid {padding-top: 2px; padding-bottom: 2px;}
|
59 |
#label_results {padding-top: 5px; padding-bottom: 1px;}
|
60 |
#col-container {max-width: 580px; margin-left: auto; margin-right: auto;}
|
61 |
+
#accordion {max-width: 580px; margin-left: auto; margin-right: auto;}
|
62 |
""") as demo:
|
63 |
+
with gr.Accordion(label="Details about the working of the App", open=False, elem_id='accordion'):
|
64 |
gr.HTML("""<div style="text-align: center; max-width: 700px; margin: 0 auto;">
|
65 |
<div
|
66 |
style="
|
|
|
82 |
In this demo, the first step involves making an API call to the BLIP2 Gradio demo to retrieve image captions.
|
83 |
Next, Langchain is used to create an embedding and vector space for the image prompts and their respective "source" from the PlaygroundAI dataset.
|
84 |
Finally, a similarity search is performed over the vector space and the top result is returned.
|
85 |
+
""")
|
|
|
86 |
#with gr.Column(scale=3):
|
87 |
# pass
|
88 |
with gr.Column(elem_id = "col-container"):
|
89 |
+
label_top = gr.HTML(value= "<center>๐ผ๏ธ Please upload an Image here ๐ that will be used as your search query</center>", elem_id="label_top")
|
90 |
image_in = gr.Image(label="Upoload an Image for search", type='filepath', elem_id="image_in")
|
91 |
label_mid = gr.HTML(value= "<p style='text-align: center; color: red;'>Or</center></p>", elem_id='label_mid')
|
92 |
+
label_bottom = gr.HTML(value= "<center>๐Type in your serch query and press Enter ๐</center>", elem_id="label_bottom")
|
93 |
search_query = gr.Textbox(placeholder="Example: A small cat sitting", label="", elem_id="search_query", value='')
|
94 |
#b1 = gr.Button("Search").style(full_width=False)
|
95 |
label_results = gr.HTML(value= "<p style='text-align: center; color: blue; font-weight: bold;'>Search results from PlaygroundAI</center></p>", elem_id="label_results")
|
96 |
img_search = gr.HTML(label = 'Image search results from PlaygroundAI dataset', elem_id="img_search")
|
97 |
pai_prompt = gr.Textbox(label="Image prompt from PlaygroundAI dataset", elem_id="pai_prompt")
|
98 |
+
|
99 |
+
gr.HTML('''<center><a href="https://huggingface.co/spaces/ysharma/Blip_PlaygroundAI?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a></center>
|
100 |
+
</p></div>'''))
|
101 |
|
102 |
image_in.change(Image_similarity_search, [image_in, search_query], [pai_prompt, img_search], api_name="PlaygroundAI_image_search" )
|
103 |
search_query.submit(Image_similarity_search, image_in, [pai_prompt, img_search], api_name='PlaygroundAI_text_search' )
|