Upload app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
|
2 |
#This project is inspired by:
|
3 |
#1. https://github.com/haltakov/natural-language-image-search by Vladimir Haltakov
|
4 |
#2. OpenAI's CLIP
|
@@ -94,21 +94,20 @@ def find_best_matches(image, mode, text):
|
|
94 |
img = PILIMAGE.open(BytesIO(response.content))
|
95 |
matched_images.append(img)
|
96 |
return matched_images
|
97 |
-
|
98 |
-
|
99 |
-
gr.Interface(
|
100 |
-
fn=find_best_matches,
|
101 |
-
inputs=[
|
102 |
-
gr.Image(label="Image to search"),
|
103 |
-
gr.Radio(choices=["T2I", "I2I"], label="Search Type"),
|
104 |
-
gr.Textbox(lines=1, label="Text query", placeholder="Introduce the search text...")
|
105 |
-
],
|
106 |
-
outputs=[
|
107 |
-
gr.Gallery(label="Generated images", show_label=False, elem_id="gallery", scale=2)
|
108 |
-
],
|
109 |
-
title="CLIP Image Search",
|
110 |
-
description="This application displays the TOP THREE images from the Unsplash dataset that best match the search query provided by the user. Moreover, the input can be provided via two modes: text or image."
|
111 |
-
).launch()
|
112 |
|
113 |
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Acknowledgments:
|
2 |
#This project is inspired by:
|
3 |
#1. https://github.com/haltakov/natural-language-image-search by Vladimir Haltakov
|
4 |
#2. OpenAI's CLIP
|
|
|
94 |
img = PILIMAGE.open(BytesIO(response.content))
|
95 |
matched_images.append(img)
|
96 |
return matched_images
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
|
99 |
|
100 |
+
|
101 |
+
gr.Interface(fn=find_best_matches,
|
102 |
+
inputs=[
|
103 |
+
gr.Image(label="Image to search", optional=True),
|
104 |
+
gr.Radio([T2I, I2I]),
|
105 |
+
gr.Textbox(lines=1, label="Text query", placeholder="Introduce the search text...",
|
106 |
+
)],
|
107 |
+
theme="grass",
|
108 |
+
outputs=[gr.Gallery(
|
109 |
+
label="Generated images", show_label=False, elem_id="gallery"
|
110 |
+
).style(grid=[2], height="auto")], enable_queue=True, title="CLIP Image Search",
|
111 |
+
description="This application displays TOP THREE images from Unsplash dataset that best match the search query provided by the user. Moreover, the input can be provided via two modes ie text or image form.").launch()
|
112 |
+
|
113 |
+
|