Spaces:
Sleeping
Sleeping
mrolando
commited on
Commit
•
05b004f
1
Parent(s):
c161c54
first
Browse files- Iso_Logotipo_Ceibal.png +0 -0
- app.py +60 -0
- requirements.txt +0 -0
Iso_Logotipo_Ceibal.png
ADDED
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from sentence_transformers import SentenceTransformer, util
|
2 |
+
import gradio as gr
|
3 |
+
import base64
|
4 |
+
|
5 |
+
|
6 |
+
model = SentenceTransformer('hiiamsid/sentence_similarity_spanish_es')
|
7 |
+
|
8 |
+
|
9 |
+
|
10 |
+
def process_text(text1,text2,text3,text4):
|
11 |
+
embeddings = model.encode([text1,text2,text3,text4],convert_to_tensor=True)
|
12 |
+
score = util.cos_sim(embeddings,embeddings).numpy()
|
13 |
+
return {text2 : score[0][1].item(),text3 : score[0][2].item(),text4 : score[0][3].item()}
|
14 |
+
|
15 |
+
demo = gr.Blocks(title="Hola")
|
16 |
+
def complete_with_gpt(text1,text2,text3):
|
17 |
+
return text1+text2+text3
|
18 |
+
|
19 |
+
with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
|
20 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
21 |
+
|
22 |
+
with demo:
|
23 |
+
gr.Markdown(
|
24 |
+
"""
|
25 |
+
<center>
|
26 |
+
<h1>
|
27 |
+
Uso de AI para la comparación de frases y palabras.
|
28 |
+
</h1>
|
29 |
+
<img src='data:image/jpg;base64,{}' width=200px>
|
30 |
+
<h3>
|
31 |
+
Con este espacio podrás comparar la similitud entre distintas frases y palabras. El resultado es el porcentaje de similitud que el modelo encuentra entre la primer frase en comparación con las siguientes.
|
32 |
+
</h3>
|
33 |
+
</center>
|
34 |
+
""".format(encoded_image))
|
35 |
+
with gr.Row():
|
36 |
+
with gr.Column():
|
37 |
+
with gr.Row():
|
38 |
+
gr.Markdown("Primero ingresá la primer frase:")
|
39 |
+
with gr.Row():
|
40 |
+
text_input = gr.Textbox( label="")
|
41 |
+
with gr.Row():
|
42 |
+
gr.Markdown("Ahora ingresá las frases a comparar con la primera:")
|
43 |
+
with gr.Row():
|
44 |
+
text_input2 = gr.Textbox(label="Frase 1")
|
45 |
+
with gr.Row():
|
46 |
+
text_input3 = gr.Textbox(label="Frase 2")
|
47 |
+
with gr.Row():
|
48 |
+
text_input4 = gr.Textbox(label="Frase 3")
|
49 |
+
with gr.Row():
|
50 |
+
btn = gr.Button("Calcular")
|
51 |
+
|
52 |
+
with gr.Column():
|
53 |
+
with gr.Row():
|
54 |
+
text_output = gr.Label()
|
55 |
+
|
56 |
+
btn.click(process_text, [text_input,text_input2, text_input3,text_input4], text_output)
|
57 |
+
|
58 |
+
demo.launch()
|
59 |
+
|
60 |
+
|
requirements.txt
ADDED
File without changes
|