tatakof commited on
Commit
c346e15
1 Parent(s): 846f5d0

Add app file

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ unmasker = pipeline('fill-mask', model="CenIA/distillbert-base-spanish-uncased")
5
+
6
+ def fill_mask(text):
7
+ text += " [MASK]"
8
+ unmasked = unmasker(text, top_k=8)
9
+ output = {}
10
+ for unmask in unmasked:
11
+ output[unmask["token_str"]] = unmask["score"]
12
+ return output
13
+
14
+ examples = [["quiero comer "], ["me gustaría ir a"]]
15
+
16
+ demo = gr.Interface(fn=fill_mask, inputs=gr.Textbox(lines=1, label="Input"), outputs=gr.Label(label="Output"), examples=examples)
17
+ demo.launch()