ShakhzoDavronov commited on
Commit
5a61610
·
verified ·
1 Parent(s): ca37c0b

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """ner_app.ipynb
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ https://colab.research.google.com/drive/1EOyiqIkIiPPP4oj114POiTpju4Ri8Xxn
8
+ """
9
+
10
+ #!pip install gradio
11
+ #!pip install transformers
12
+
13
+ import gradio as gr
14
+ from transformers import pipeline
15
+
16
+ ner_model=pipeline('ner',model="ShakhzoDavronov/electra-ner-token-classification")
17
+ 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')
18
+
19
+ def ner(text):
20
+ output=ner_model(text,aggregation_strategy='average')
21
+ return {'text':text,'entities':output}
22
+
23
+ input_textbox=gr.Textbox(label='Type text here to get named entities',placeholder='type...',lines=4)
24
+ output_textbox=gr.HighlightedText(label='Named entities')
25
+ 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."]
26
+ demo=gr.Interface(fn=ner, inputs=input_textbox, outputs=output_textbox,examples=samples)
27
+ demo.launch()
28
+