Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,15 +1,12 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
ner = pipeline("ner", model="Davlan/xlm-roberta-base-ner-hrl", grouped_entities=True)
|
| 6 |
|
| 7 |
-
# Inference function
|
| 8 |
def extract_entities(text):
|
| 9 |
results = ner(text)
|
| 10 |
return [(ent['word'], ent['entity_group']) for ent in results]
|
| 11 |
|
| 12 |
-
# Gradio interface
|
| 13 |
with gr.Blocks() as demo:
|
| 14 |
gr.Markdown(instructions)
|
| 15 |
with gr.Row():
|
|
@@ -19,6 +16,5 @@ with gr.Blocks() as demo:
|
|
| 19 |
|
| 20 |
btn.click(fn=extract_entities, inputs=inp, outputs=out)
|
| 21 |
|
| 22 |
-
# Launch
|
| 23 |
if __name__ == "__main__":
|
| 24 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
ner = pipeline("ner", model="Keyurjotaniya007/xlm-roberta-base-xtreme-multilingual-ner-2.0", grouped_entities=True)
|
|
|
|
| 5 |
|
|
|
|
| 6 |
def extract_entities(text):
|
| 7 |
results = ner(text)
|
| 8 |
return [(ent['word'], ent['entity_group']) for ent in results]
|
| 9 |
|
|
|
|
| 10 |
with gr.Blocks() as demo:
|
| 11 |
gr.Markdown(instructions)
|
| 12 |
with gr.Row():
|
|
|
|
| 16 |
|
| 17 |
btn.click(fn=extract_entities, inputs=inp, outputs=out)
|
| 18 |
|
|
|
|
| 19 |
if __name__ == "__main__":
|
| 20 |
demo.launch()
|