Spaces:
Sleeping
Sleeping
mrolando
commited on
Commit
路
77f7257
1
Parent(s):
326aa2c
"first commit"
Browse files- Iso_Logotipo_Ceibal.png +0 -0
- app.py +37 -0
- requirements.txt +2 -0
Iso_Logotipo_Ceibal.png
ADDED
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
import base64
|
4 |
+
|
5 |
+
model_checkpoint2 = "dccuchile/bert-base-spanish-wwm-cased"
|
6 |
+
|
7 |
+
mask_filler = pipeline(
|
8 |
+
"fill-mask", model=model_checkpoint2,tokenizer=model_checkpoint2
|
9 |
+
)
|
10 |
+
|
11 |
+
def fill_mask_interface(sentence):
|
12 |
+
results = mask_filler(sentence)
|
13 |
+
#suggestions = [f"{result['token_str']} (confidence: {result['score']:.4f})" for result in results]
|
14 |
+
dictt ={}
|
15 |
+
for text,score in zip([d['token_str'] for d in results],[d['score'] for d in results]):
|
16 |
+
dictt[text] = score
|
17 |
+
return dictt
|
18 |
+
|
19 |
+
|
20 |
+
with open("Iso_Logotipo_Ceibal.png", "rb") as image_file:
|
21 |
+
encoded_image = base64.b64encode(image_file.read()).decode()
|
22 |
+
|
23 |
+
description = """
|
24 |
+
<img src='data:image/jpg;base64,{}' width=200px>
|
25 |
+
|
26 |
+
Interact煤a con este espacio para probar la predicci贸n de palabras en una frase con una palabra enmascarada. La palabra enmascarada debe ser [MASK] y s贸lo una por frase.
|
27 |
+
""".format(encoded_image)
|
28 |
+
|
29 |
+
textbox = gr.Textbox(label="Agrega tu frase con una palabra enmascarada aqu铆!", placeholder="Hola, [MASK] est谩s?", lines=2)
|
30 |
+
|
31 |
+
gr.Interface(fn=fill_mask_interface,
|
32 |
+
inputs=textbox,
|
33 |
+
outputs="label",
|
34 |
+
title = "Uso de AI para la predicci贸n de palabras enmascaradas.",
|
35 |
+
description = description,
|
36 |
+
examples=[["Hola, c贸mo te lleva el [MASK]?"], ["D贸nde deber铆amos [MASK]?"]]
|
37 |
+
).launch()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|