ShaohanTian commited on
Commit
4af2585
·
1 Parent(s): 68b287a
Files changed (2) hide show
  1. app.py +9 -52
  2. requirements.txt +1 -0
app.py CHANGED
@@ -1,45 +1,3 @@
1
- # import gradio as gr
2
-
3
- # title = "SteelBERT"
4
-
5
- # examples = [
6
- # ['Paris is the [MASK] of France.', 'SteelBERT'],
7
- # ["A composite steel plate for marine construction was fabricated using 316L stainless steel.", 'SteelBERT'],
8
- # ["The use of composite [MASK] in construction is growing rapidly.", 'SteelBERT'],
9
- # ["Advances in [MASK] science are leading to stronger and more durable steel products.", 'SteelBERT'],
10
- # ["The corrosion resistance of stainless steel is attributed to the [MASK] of a passive film on the surface.", 'SteelBERT'],
11
- # ["Heat treatment of steel involves a controlled [MASK] and cooling process to alter its mechanical properties.", 'SteelBERT'],
12
- # ["Nano-engineered [MASK] have the potential to revolutionize the steel industry with their superior properties.", 'SteelBERT']
13
- # ]
14
-
15
- # # Load interfaces for different models
16
- # try:
17
- # io1 = gr.Interface.load("MGE-LLMs/SteelBERT")
18
-
19
-
20
- # import gradio as gr
21
-
22
- # title = "BERT"
23
-
24
- # 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."
25
-
26
- # 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>"
27
-
28
- # # examples = [
29
- # # ['Paris is the [MASK] of France.','bert-base-uncased']
30
- # # ]
31
-
32
- # examples = [
33
- # ['Paris is the [MASK] of France.', 'SteelBERT'],
34
- # ["A composite steel plate for marine construction was fabricated using 316L stainless steel.", 'SteelBERT'],
35
- # ["The use of composite [MASK] in construction is growing rapidly.", 'SteelBERT'],
36
- # ["Advances in [MASK] science are leading to stronger and more durable steel products.", 'SteelBERT'],
37
- # ["The corrosion resistance of stainless steel is attributed to the [MASK] of a passive film on the surface.", 'SteelBERT'],
38
- # ["Heat treatment of steel involves a controlled [MASK] and cooling process to alter its mechanical properties.", 'SteelBERT'],
39
- # ["Nano-engineered [MASK] have the potential to revolutionize the steel industry with their superior properties.", 'SteelBERT']
40
- # ]
41
-
42
-
43
  import gradio as gr
44
 
45
  title = "BERT"
@@ -49,29 +7,28 @@ description = "Gradio Demo for BERT. To use it, simply add your text, or click o
49
  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>"
50
 
51
  examples = [
52
- ['Paris is the [MASK] of France.', 'bert-base-cased']
53
  ]
54
 
 
55
  io1 = gr.Interface.load("huggingface/bert-base-cased")
 
56
  io2 = gr.Interface.load("huggingface/bert-base-uncased")
57
 
 
58
  def inference(inputtext, model):
59
  if model == "bert-base-cased":
60
  outlabel = io1(inputtext)
61
  else:
62
  outlabel = io2(inputtext)
63
  return outlabel
64
-
65
- inputs = gr.Textbox(label="Context", lines=10)
66
- model_choice = gr.Dropdown(choices=["bert-base-cased", "bert-base-uncased"], label="Model", default="bert-base-cased")
67
- outputs = gr.Textbox(label="Output")
68
 
69
  gr.Interface(
70
- fn=inference,
71
- inputs=[inputs, model_choice],
72
- outputs=outputs,
73
  examples=examples,
74
  article=article,
75
  title=title,
76
- description=description
77
- ).launch(enable_queue=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
  title = "BERT"
 
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,
33
  title=title,
34
+ description=description).launch(enable_queue=True)
 
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio==3.43.1