my_space / app.py
EvensHelm's picture
Update app.py
bb43fc4 verified
raw
history blame contribute delete
738 Bytes
import gradio as gr
from transformers import pipeline
def ner_interface(text):
"""
Gradio interface function for NER pipeline.
"""
pipe = pipeline("ner", model="NbAiLab/nb-bert-base-ner", aggregation_strategy="simple")
results = pipe(text)
df_results = pd.DataFrame(results)
return df_results
# Create the Gradio interface
iface = gr.Interface(
fn=ner_interface,
inputs=gr.Textbox(lines=10, label="Enter text for NER"),
outputs=gr.DataFrame(label="Extracted Entities"),
title="Named Entity Recognition (NER) Pipeline",
description="Extracts entities (like persons, organizations, and locations) from text using the NbAiLab/nb-bert-base-ner model."
)
# Launch the interface
iface.launch()