File size: 656 Bytes
25d4bc8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

# Load the NER pipeline
ner_pipeline = pipeline("ner", model="dslim/bert-base-NER", grouped_entities=True)

# Define the prediction function
def recognize_entities(text):
    results = ner_pipeline(text)
    return str(results)

# Gradio UI
iface = gr.Interface(fn=recognize_entities, 
                     inputs=gr.Textbox(lines=5, placeholder="Enter your text here..."),
                     outputs="text",
                     title="Named Entity Recognition (NER)",
                     description="Using dslim/bert-base-NER model to identify named entities in text.")

# Launch
iface.launch()