souvikmaji22
commited on
Commit
•
362dfd9
1
Parent(s):
3ed8840
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
get_completion = pipeline("ner", model="dslim/bert-base-NER")
|
5 |
+
|
6 |
+
def ner(input):
|
7 |
+
output = get_completion(input)
|
8 |
+
return {"text": input, "entities": output}
|
9 |
+
|
10 |
+
gr.close_all()
|
11 |
+
demo = gr.Interface(fn=ner,
|
12 |
+
inputs=[gr.Textbox(label="Text to find entities", lines=2)],
|
13 |
+
outputs=[gr.HighlightedText(label="Text with entities")],
|
14 |
+
title="NER with dslim/bert-base-NER",
|
15 |
+
description="Find entities using the `dslim/bert-base-NER` model under the hood!",
|
16 |
+
allow_flagging="never",
|
17 |
+
)
|
18 |
+
demo.launch()
|