|
import gradio as gr |
|
|
|
import gensim |
|
|
|
model_g = gensim.models.KeyedVectors.load_word2vec_format('v_glove_1024d_2.0' , binary=True) |
|
|
|
|
|
|
|
def generate(text): |
|
result= model_g.most_similar('together',topn=10) |
|
return result |
|
|
|
|
|
examples = [ |
|
["sad"], |
|
["together"], |
|
["lake"] |
|
] |
|
|
|
title = "Visually Grounded embeddings" |
|
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>' |
|
txt = gr.Textbox(lines=1, label="Query word", placeholder="muffin") |
|
out = gr.Textbox(lines=4, label="top 10 nearest neighbors") |
|
|
|
demo = gr.Interface( |
|
fn =generate, |
|
inputs=txt, |
|
outputs=out, |
|
examples=examples, |
|
title=title, |
|
description=description, |
|
theme="default", |
|
cache_examples="never" |
|
) |
|
|
|
demo.launch(enable_queue=True, debug=True) |