Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,25 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
|
5 |
+
|
6 |
+
ner_pipeline = pipeline("ner", model="models/dslim/bert-base-NER")
|
7 |
+
|
8 |
+
examples = [
|
9 |
+
"Does Chicago have any stores and does Joe live here?",
|
10 |
+
]
|
11 |
+
|
12 |
+
|
13 |
+
def ner(text):
|
14 |
+
output = ner_pipeline(text)
|
15 |
+
return {"text": text, "entities": output}
|
16 |
+
|
17 |
+
|
18 |
+
demo = gr.Interface(
|
19 |
+
ner,
|
20 |
+
gr.Textbox(placeholder="Enter sentence here..."),
|
21 |
+
gr.HighlightedText(),
|
22 |
+
examples=examples,
|
23 |
+
)
|
24 |
+
|
25 |
+
demo.launch()
|