Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
import gensim
|
4 |
+
|
5 |
+
model_g = gensim.models.KeyedVectors.load_word2vec_format('./v_glove_1024_2.0' , binary=True)
|
6 |
+
|
7 |
+
#retrieve the most similar words
|
8 |
+
|
9 |
+
def generate(text):
|
10 |
+
result= model_g.most_similar('together',topn=10)
|
11 |
+
return result
|
12 |
+
|
13 |
+
|
14 |
+
examples = [
|
15 |
+
["sad"],
|
16 |
+
["together"],
|
17 |
+
["lake"]
|
18 |
+
]
|
19 |
+
|
20 |
+
title = "Visually Grounded embeddings"
|
21 |
+
description = 'Get the top 10 nearest neighbors from a visually grounded word embedding model described in [this paper](https://arxiv.org/abs/2206.08823).<br>'
|
22 |
+
txt = gr.Textbox(lines=1, label="Query word", placeholder="muffin")
|
23 |
+
out = gr.Textbox(lines=4, label="top 10 nearest neighbors")
|
24 |
+
|
25 |
+
demo = gr.Interface(
|
26 |
+
fn =generate,
|
27 |
+
inputs=txt,
|
28 |
+
outputs=out,
|
29 |
+
examples=examples,
|
30 |
+
title=title,
|
31 |
+
description=description,
|
32 |
+
theme="default",
|
33 |
+
cache_examples="never"
|
34 |
+
)
|
35 |
+
|
36 |
+
demo.launch(enable_queue=True, debug=True)
|