Spaces:
Sleeping
Sleeping
Commit
·
4b3d8d5
1
Parent(s):
db7431e
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,7 @@ pipe = None
|
|
| 12 |
sample = None
|
| 13 |
model_repo = 'Solenya-ai/dill'
|
| 14 |
|
| 15 |
-
def search(image=None, query=None
|
| 16 |
global pipe
|
| 17 |
global sample
|
| 18 |
|
|
@@ -30,7 +30,7 @@ def search(image=None, query=None, combination=1, selection=1):
|
|
| 30 |
image_embed = np.array(pipe.encode(image))
|
| 31 |
|
| 32 |
if query is not None and image is not None:
|
| 33 |
-
embed = text_embed*(image_embed**
|
| 34 |
elif image is not None:
|
| 35 |
embed = image_embed
|
| 36 |
else:
|
|
@@ -42,8 +42,7 @@ def search(image=None, query=None, combination=1, selection=1):
|
|
| 42 |
|
| 43 |
iface = gr.Interface(search,
|
| 44 |
[gr.inputs.Image(type="pil"),
|
| 45 |
-
gr.inputs.Textbox(lines=1, placeholder="Type here to search for similar images..."),
|
| 46 |
-
gr.inputs.Slider(-1, 2, default=0.2, step=0.1), gr.inputs.Slider(-1, 2, default=0, step=0.1)],
|
| 47 |
gr.Gallery(columns=3),
|
| 48 |
title="Search for similar images",
|
| 49 |
)
|
|
|
|
| 12 |
sample = None
|
| 13 |
model_repo = 'Solenya-ai/dill'
|
| 14 |
|
| 15 |
+
def search(image=None, query=None):
|
| 16 |
global pipe
|
| 17 |
global sample
|
| 18 |
|
|
|
|
| 30 |
image_embed = np.array(pipe.encode(image))
|
| 31 |
|
| 32 |
if query is not None and image is not None:
|
| 33 |
+
embed = text_embed*(image_embed**0.2)
|
| 34 |
elif image is not None:
|
| 35 |
embed = image_embed
|
| 36 |
else:
|
|
|
|
| 42 |
|
| 43 |
iface = gr.Interface(search,
|
| 44 |
[gr.inputs.Image(type="pil"),
|
| 45 |
+
gr.inputs.Textbox(lines=1, placeholder="Type here to search for similar images...")],
|
|
|
|
| 46 |
gr.Gallery(columns=3),
|
| 47 |
title="Search for similar images",
|
| 48 |
)
|