Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,14 @@
|
|
1 |
import gradio as gr
|
2 |
from sentence_transformers.util import cos_sim
|
|
|
3 |
|
4 |
-
def
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
iface = gr.Interface(fn=compute, inputs=["text","text"], outputs="text")
|
8 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from sentence_transformers.util import cos_sim
|
3 |
+
import numpy as np
|
4 |
|
5 |
+
def textToFloatVector(text):
|
6 |
+
x = np.array(text1.split(","))
|
7 |
+
vec = x.astype(np.float)
|
8 |
+
return vec
|
9 |
+
|
10 |
+
def compute(text1, text2):
|
11 |
+
return cos_sim(textToFloatVector(text1), textToFloatVector(text2))
|
12 |
|
13 |
iface = gr.Interface(fn=compute, inputs=["text","text"], outputs="text")
|
14 |
iface.launch()
|