gschurck commited on
Commit
2f5bf30
·
1 Parent(s): fb76362

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -11,10 +11,15 @@ def get_image_embedding(image):
11
  img_emb = image_model.encode(image)
12
  print(img_emb)
13
  print(type(img_emb))
14
- return {"prediction": img_emb.tolist()}
15
 
 
 
 
 
16
 
17
- image_input = gr.Image(type="pil")
18
- label_output = gr.JSON()
19
 
20
- gr.Interface(fn=get_image_embedding, inputs=image_input, outputs=label_output).launch()
 
 
11
  img_emb = image_model.encode(image)
12
  print(img_emb)
13
  print(type(img_emb))
14
+ return {"embedding": img_emb.tolist()}
15
 
16
+ def get_text_embedding(text):
17
+ multilingual_text_model = SentenceTransformer('clip-ViT-B-32-multilingual-v1')
18
+ text_emb = multilingual_text_model.encode(text)
19
+ return {"embedding": text_emb}
20
 
21
+ image_embedding = gr.Interface(fn=get_image_embedding, inputs=gr.Image(type="pil"), outputs=gr.JSON())
22
+ text_embedding = gr.Interface(fn=get_text_embedding, inputs=gr.Textbox(), outputs=gr.JSON())
23
 
24
+ space = gr.TabbedInterface([image_embedding, text_embedding], ["Image Embedding", "Text Embedding"])
25
+ space.launch()