Spaces:
Sleeping
Sleeping
File size: 1,144 Bytes
5a61610 88f8544 5a61610 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# -*- coding: utf-8 -*-
"""ner_app.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/1EOyiqIkIiPPP4oj114POiTpju4Ri8Xxn
"""
#!pip install gradio
#!pip install transformers
import gradio as gr
from transformers import pipeline
ner_model=pipeline('ner',model="ShakhzoDavronov/electra-ner-token-classification")
ner_model('Amazon announced its plans to open a new headquarters in Virginia, aiming to create over 25,000 jobs in the area by 2030.',aggregation_strategy='average')
def ner(text):
output=ner_model(text,aggregation_strategy='average')
return {'text':text,'entities':output}
input_textbox=gr.Textbox(label='Type text here to get named entities',placeholder='type...',lines=4)
output_textbox=gr.HighlightedText(label='Named entities')
samples=["Elon founded SpaceX.","The conference will be held in San Francisco next April.","Amazon announced its plans to open a new headquarters in Virginia, aiming to create over 25,000 jobs in the area by 2030."]
demo=gr.Interface(fn=ner, inputs=input_textbox, outputs=output_textbox,examples=samples)
demo.launch(share=True)
|