Spaces:
Running
on
Zero
Running
on
Zero
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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="Named Entity Recognition - NER ",
|
| 15 |
+
description="Find entities using the `dslim/bert-base-NER` model under the hood!",
|
| 16 |
+
allow_flagging="never",
|
| 17 |
+
#Here we introduce a new tag, examples, easy to use examples for your application
|
| 18 |
+
examples=["My name is Andrew and I live in California", "My name is Poli and work at HuggingFace"])
|
| 19 |
+
demo.launch()
|