ayaanzaveri commited on
Commit
f577bfd
1 Parent(s): 012e66e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -6
app.py CHANGED
@@ -1,26 +1,32 @@
1
  import gradio as gr
2
 
3
- title = "Liberty"
4
 
5
  description = "Gradio Demo for BERT. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."
6
 
7
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1810.04805' target='_blank'>BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</a></p>"
8
 
9
  examples = [
10
- ['Paris is the [MASK] of France.','bert-base-uncased']
11
  ]
12
 
13
- io = gr.Interface.load("huggingface/bert-base-uncased")
 
 
 
 
14
 
15
  def inference(inputtext, model):
16
- outlabel = io(inputtext)
 
 
 
17
  return outlabel
18
 
19
 
20
  gr.Interface(
21
  inference,
22
- "bert-base-uncased",
23
- [gr.inputs.Textbox(label="Context",lines=10),gr.inputs.Dropdown(choices=["bert-base-cased","bert-base-uncased"], type="value", default="bert-base-uncased", label="model")],
24
  [gr.outputs.Label(label="Output")],
25
  examples=examples,
26
  article=article,
 
1
  import gradio as gr
2
 
3
+ title = "BERT"
4
 
5
  description = "Gradio Demo for BERT. To use it, simply add your text, or click one of the examples to load them. Read more at the links below."
6
 
7
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1810.04805' target='_blank'>BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding</a></p>"
8
 
9
  examples = [
10
+ ['Paris is the [MASK] of France.','bert-base-cased']
11
  ]
12
 
13
+
14
+ io1 = gr.Interface.load("huggingface/bert-base-cased")
15
+
16
+ io2 = gr.Interface.load("huggingface/bert-base-uncased")
17
+
18
 
19
  def inference(inputtext, model):
20
+ if model == "bert-base-cased":
21
+ outlabel = io1(inputtext)
22
+ else:
23
+ outlabel = io2(inputtext)
24
  return outlabel
25
 
26
 
27
  gr.Interface(
28
  inference,
29
+ [gr.inputs.Textbox(label="Context",lines=10),gr.inputs.Dropdown(choices=["bert-base-cased","bert-base-uncased"], type="value", default="bert-base-cased", label="model")],
 
30
  [gr.outputs.Label(label="Output")],
31
  examples=examples,
32
  article=article,