navjotk commited on
Commit
25d4bc8
·
verified ·
1 Parent(s): d3c25b3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the NER pipeline
5
+ ner_pipeline = pipeline("ner", model="dslim/bert-base-NER", grouped_entities=True)
6
+
7
+ # Define the prediction function
8
+ def recognize_entities(text):
9
+ results = ner_pipeline(text)
10
+ return str(results)
11
+
12
+ # Gradio UI
13
+ iface = gr.Interface(fn=recognize_entities,
14
+ inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
15
+ outputs="text",
16
+ title="Named Entity Recognition (NER)",
17
+ description="Using dslim/bert-base-NER model to identify named entities in text.")
18
+
19
+ # Launch
20
+ iface.launch()