datasciencedojo commited on
Commit
dd30302
·
1 Parent(s): 0759204

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +16 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ unmasker = pipeline('fill-mask', model='bert-base-uncased')
5
+
6
+ def fill_mask(text):
7
+ unmasked = unmasker(text)
8
+ output = {}
9
+ for unmask in unmasked:
10
+ output[unmask["token_str"]] = unmask["score"]
11
+ return output
12
+
13
+ examples = [["Hello I'm a [MASK] model."], ["[MASK] is my favourite sports."]]
14
+
15
+ demo = gr.Interface(fn=fill_mask, inputs=gr.Textbox(lines=1, label="Input"), outputs=gr.Label(label="Output"), examples=examples)
16
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ gradio
2
+ torch
3
+ timm
4
+ sentencepiece
5
+ transformers