Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,16 @@
|
|
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.
|
15 |
-
|
16 |
-
io2 = gr.Interface.load("huggingface/bert-base-uncased")
|
17 |
-
|
18 |
|
19 |
def inference(inputtext, model):
|
20 |
if model == "bert-base-cased":
|
@@ -22,13 +18,17 @@ def inference(inputtext, model):
|
|
22 |
else:
|
23 |
outlabel = io2(inputtext)
|
24 |
return outlabel
|
25 |
-
|
26 |
|
|
|
27 |
gr.Interface(
|
28 |
-
inference,
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
examples=examples,
|
32 |
article=article,
|
33 |
title=title,
|
34 |
-
description=description
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
title = "BERT"
|
|
|
4 |
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."
|
|
|
5 |
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>"
|
6 |
|
7 |
examples = [
|
8 |
+
['Paris is the [MASK] of France.', 'bert-base-cased']
|
9 |
]
|
10 |
|
11 |
+
# Lade die Interfaces für die Modelle
|
12 |
+
io1 = gr.load("huggingface/bert-base-cased")
|
13 |
+
io2 = gr.load("huggingface/bert-base-uncased")
|
|
|
|
|
14 |
|
15 |
def inference(inputtext, model):
|
16 |
if model == "bert-base-cased":
|
|
|
18 |
else:
|
19 |
outlabel = io2(inputtext)
|
20 |
return outlabel
|
|
|
21 |
|
22 |
+
# Aktualisierte Gradio-Syntax
|
23 |
gr.Interface(
|
24 |
+
fn=inference,
|
25 |
+
inputs=[
|
26 |
+
gr.Textbox(label="Context", lines=10),
|
27 |
+
gr.Dropdown(choices=["bert-base-cased", "bert-base-uncased"], value="bert-base-cased", label="model")
|
28 |
+
],
|
29 |
+
outputs=gr.Label(label="Output"),
|
30 |
examples=examples,
|
31 |
article=article,
|
32 |
title=title,
|
33 |
+
description=description
|
34 |
+
).launch(enable_queue=True)
|