Spaces:
Build error
Build error
Commit
·
8ff78e6
1
Parent(s):
2b3ac0d
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from sentence_transformers import SentenceTransformer
|
| 3 |
+
|
| 4 |
+
# Load the model
|
| 5 |
+
model = SentenceTransformer('sentence-transformers/msmarco-distilbert-dot-v5')
|
| 6 |
+
|
| 7 |
+
# Function to get the embedding
|
| 8 |
+
def embedding(text):
|
| 9 |
+
text_emb = model.encode(text)
|
| 10 |
+
return text_emb
|
| 11 |
+
|
| 12 |
+
# Define the Streamlit app
|
| 13 |
+
gradio_app = gr.Interface(
|
| 14 |
+
embedding,
|
| 15 |
+
inputs=gr.Text(label="Select hot dog candidate"),
|
| 16 |
+
outputs=gr.Text(label="Embedding"),
|
| 17 |
+
title="Embedding",
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
gradio_app.launch()
|